All Projects → YU-Zhiyang → Opencv_transforms_torchvision

YU-Zhiyang / Opencv_transforms_torchvision

Licence: mit
opencv reimplement for transforms in torchvision

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Opencv transforms torchvision

Photobooth
A flexible photobooth software
Stars: ✭ 227 (+60.99%)
Mutual labels:  opencv, pillow
Pibooth
The pibooth project provides a Photo Booth application out-of-the-box for Raspberry Pi and opencv compatible devices
Stars: ✭ 398 (+182.27%)
Mutual labels:  opencv, pillow
Lambda Packs
Precompiled packages for AWS Lambda
Stars: ✭ 997 (+607.09%)
Mutual labels:  opencv, pillow
Opentrack
Head tracking software for MS Windows, Linux, and Apple OSX
Stars: ✭ 1,950 (+1282.98%)
Mutual labels:  opencv
Vision landing
Precision landing using visual targets
Stars: ✭ 131 (-7.09%)
Mutual labels:  opencv
Gesture Recognition
✋ Recognizing "Hand Gestures" using OpenCV and Python.
Stars: ✭ 136 (-3.55%)
Mutual labels:  opencv
Rpa Python
Python package for doing RPA
Stars: ✭ 2,449 (+1636.88%)
Mutual labels:  opencv
Skindetector
A Python based skin detection system using OpenCV
Stars: ✭ 130 (-7.8%)
Mutual labels:  opencv
Qtevm
C++ implementation of EVM(Eulerian Video Magnification), based on OpenCV and Qt.
Stars: ✭ 138 (-2.13%)
Mutual labels:  opencv
Attendace management system
In this system we can fill attendance by face recognition
Stars: ✭ 135 (-4.26%)
Mutual labels:  opencv
Intelegent lock
lock mechanism with face recognition and liveness detection
Stars: ✭ 134 (-4.96%)
Mutual labels:  opencv
Native Opencv Android Template
A tutorial for setting up OpenCV 4.5.0 (and other 4.x.y version) for Android in Android Studio with Native Development Kit (NDK) support.
Stars: ✭ 131 (-7.09%)
Mutual labels:  opencv
Vidgear
A High-performance cross-platform Video Processing Python framework powerpacked with unique trailblazing features 🔥
Stars: ✭ 2,048 (+1352.48%)
Mutual labels:  opencv
Spacextract
Extraction and analysis of telemetry from rocket launch webcasts (from SpaceX and RocketLab)
Stars: ✭ 131 (-7.09%)
Mutual labels:  opencv
Awesome Android Ndk
🔥 全面深入地掌握NDK技术,成为下一波5G时代的浪潮儿~
Stars: ✭ 138 (-2.13%)
Mutual labels:  opencv
Robin
RObust document image BINarization
Stars: ✭ 131 (-7.09%)
Mutual labels:  opencv
Cvscanner
An OpenCV based library for Android to scan ID documents or Passports.
Stars: ✭ 138 (-2.13%)
Mutual labels:  opencv
Lidar camera calibration
Light-weight camera LiDAR calibration package for ROS using OpenCV and PCL (PnP + LM optimization)
Stars: ✭ 133 (-5.67%)
Mutual labels:  opencv
Yolo Powered robot vision
Stars: ✭ 133 (-5.67%)
Mutual labels:  opencv
Node Camera
Access and stream web camera in nodejs using opencv and websockets.
Stars: ✭ 135 (-4.26%)
Mutual labels:  opencv

opencv_torchvision_transform

  1. This is an opencv based rewriting of the "transforms" in torchvision package.

  2. All functions depend on only cv2 and pytorch (PIL-free). As the article says, cv2 is three times faster than PIL.

  3. Most functions in transforms are reimplemented, except that:

    1. ToPILImage (opencv we used :)), Scale and RandomSizedCrop which are deprecated in the original version are ignored.

    2. The affine transform in the original one only has 5 degrees of freedom, I implement an Affine transform with 6 degress of freedom called RandomAffine6 (can be found in cvtransforms.py). The original method RandomAffine is still retained and reimplemented with opencv.

    3. My rotate function is clockwise, however the original one is anticlockwise.

    4. Adding some new methods which can be found in Support (the bolded ones).

    5. All the outputs of the opencv version are almost the same as the original one's (test in cvfunctional.py).

Support:

  • Compose, ToTensor, ToCVImage, Normalize

  • Resize, CenterCrop, Pad

  • Lambda (doesn't work well in multiprocess in Windows)

  • RandomApply, RandomOrder, RandomChoice, RandomCrop,

  • RandomHorizontalFlip, RandomVerticalFlip, RandomResizedCrop,

  • FiveCrop, TenCrop, LinearTransformation, ColorJitter,

  • RandomRotation, RandomAffine, *RandomAffine6, *RandomPerspective

  • *RandomGaussianNoise, *RandomPoissonNoise, *RandomSPNoise

  • Grayscale, RandomGrayscale

How to use:

  1. git clone https://github.com/YU-Zhiyang/opencv_torchvision_transforms.git .

  2. Add cvtorchvision to your python path.

  3. Add from cvtorchvision import cvtransforms in your python file.

  4. You can use all functions as the original version, for example:

    transform = cvtransforms.Compose([
     
             cvtransforms.RandomAffine(degrees=10, translate=(0.1, 0.1), scale=(0.9, 1.1), shear=(-10, 0),
     
             cvtransforms.Resize(size=(350, 350), interpolation='BILINEAR'),
     
             cvtransforms.ToTensor(),
     
             cvtransforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
             ])
    

more details can be found in the examples of official tutorials.

Good News:

You can install this package via pip install opencv-torchvision-transforms-yuzhiyang (Old version only)

Attention:

The multiprocessing used in dataloader of pytorch is not friendly with lambda function in Windows as lambda function can't be pickled (https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled).

So the Lambda in cvtransforms.py may not work properly in Windows.

Requirements

python >=3.5.2

numpy >=1.10 ('@' operator may not be overloaded before this version)

pytorch>=0.4.1

torchvision>=0.2.1

opencv-contrib-python-3.4.2 (test with this version, but any version of opencv3 is ok, I think)

Postscript

Welcome to point out and help fixing bugs!

Thanks HongChu who helps a lot.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].