opencv_torchvision_transform
-
This is an opencv based rewriting of the "transforms" in torchvision package.
-
All functions depend on only cv2 and pytorch (PIL-free). As the article says, cv2 is three times faster than PIL.
-
Most functions in transforms are reimplemented, except that:
-
ToPILImage(opencv we used :)), Scale and RandomSizedCrop which are deprecated in the original version are ignored.
-
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 master/cvtorchvision/cvtransforms/cvtransforms.py). The original method(RandomAffine) is still retained and reimplemented with opencv.
-
My rotate function is clockwise, however the original one is anticlockwise.
-
Adding some new methods which can be found in Support(the bolded ones).
-
All the outputs of the opencv version are almost the same as the original one's(test in master/cvtorchvision/cvtransforms/cvfunctional.py: if name == 'main':...).
-
Support:
-
Compose, ToTensor, ToCVImage, Normalize
-
Resize, CenterCrop, Pad
-
Lambda(doesn't work well in multiprocess in wihdows)
-
RandomApply, RandomOrder, RandomChoice, RandomCrop,
-
RandomHorizontalFlip, RandomVerticalFlip, RandomResizedCrop,
-
FiveCrop, TenCrop, LinearTransformation, ColorJitter,
-
RandomRotation, RandomAffine, RandomAffine6, RandomPerspective
-
RandomGaussianNoise", "RandomPoissonNoise", "RandomSPNoise
-
Grayscale, RandomGrayscale
How to use:
-
git clone https://github.com/YU-Zhiyang/opencv_torchvision_transforms.git .
-
Add cvtorchvision to your python path.
-
Add "from cvtorchvision import cvtransforms" in your pythion file.
-
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.
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 cvtransform.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 to fix bugs !
Watches, Stars and Forks won鈥檛 be rejected :smile:
Thanks HongChu who helps a lot.
Metadata
Release files for opencv-torchvision-transforms-yuzhiyang 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| opencv_torchvision_transforms_yuzhiyang-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for opencv_torchvision_transforms_yuzhiyang-0.0.1-py3-none-any.whl |
Release files / opencv_torchvision_transforms_yuzhiyang-0.0.1-py3-none-any.whl
| Download URL | opencv_torchvision_transforms_yuzhiyang-0.0.1-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
67f793d6d9d368b9a4c6fbfff517ad86c59606174caeafb3f2695b0406ba4e20
|
|
BLAKE2b-256 checksum How to use checksums |
c2cc49c7801943377c2c20c2bcb538ce53fd684cfcc270e749b24b89cd931cfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.3.2 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.5.2
|
Security for opencv-torchvision-transforms-yuzhiyang 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.