Enhance torchvision for multi-channel images, 16-bit image, segmentation...
Project description
# torchvision-enhance
torchvision-enhance is used to enhance the offical PyTorch vision library torchvision. Here is the enhanced parts:
- support multi-channel(> 4 channels, e.g. 8 channels) images
- support 16-bit TIF file
- more easier to semantic segmentation transform
## Support transforms
- RandomFlip
- RandomVFlip
- RandomHFlip
- RandomRotate
- RandomShift
- RandomCrop
- CenterCrop
- Resize
- Pad
- GaussianBlur
- PieceTransform
- Lambda
- ToTensor
- Normalize
## Install
```
pip install torchvision-enhance
```
or install from the source
```
git clone
pip install -r requirements.txt
python setup.py install
```
## Dependencies
- numpy
- scipy
- Pillow
- PyTorch
- opencv
- scikit-image
## Usage
For more useage, check out the [example-classification.py](./test/example-classification.py) and [example-segmentation.py](./test/example-segmentation.py)
``` python
from torchvision_x.datasets import image_loader
from torchvision_x.transforms import transforms_seg,functional
transform = transforms_seg.SegCompose([
# transforms_seg.SegFlip(),
transforms_seg.SegVFlip(),
# transforms_seg.SegHFlip(),
# transforms_seg.SegRandomFlip(),
# transforms_seg.SegRandomRotate(90),
# transforms_seg.SegRandomShift(40),
# transforms_seg.SegRandomCrop((256,256)),
# transforms_seg.SegCenterCrop(224),
# transforms_seg.SegResize(224),
# transforms_seg.SegPad(20),
# transforms_seg.SegNoise(dtype='uint16', var=0.001), #TODO
# transforms_seg.SegGaussianBlur(sigma=2, dtype='uint8', multichannel=False),
# transforms_seg.SegPieceTransform(),
# transforms_seg.SegLambda(lambda x: functional.to_tensor(x))
transforms_seg.SegToTensor(),
transforms_seg.SegNormalize((0.5,0.5,0.5),(0.5,0.5,0.5)),
])
trainset = image_loader.SemanticSegmentationLoader(
rootdir='sample-data/', lstpath='sample-data/segmentation_jpg.lst',
filetype='jpg', transform=transform,
)
trainloader = DataLoader(dataset=trainset,batch_size=batch_size,shuffle=False)
for step, (inputs, targets) in enumerate(trainloader):
print('batch: {} ........'.format(step))
print(type(inputs), inputs.shape)
print(type(targets), targets.shape)
```
## TODO
- Noise
torchvision-enhance is used to enhance the offical PyTorch vision library torchvision. Here is the enhanced parts:
- support multi-channel(> 4 channels, e.g. 8 channels) images
- support 16-bit TIF file
- more easier to semantic segmentation transform
## Support transforms
- RandomFlip
- RandomVFlip
- RandomHFlip
- RandomRotate
- RandomShift
- RandomCrop
- CenterCrop
- Resize
- Pad
- GaussianBlur
- PieceTransform
- Lambda
- ToTensor
- Normalize
## Install
```
pip install torchvision-enhance
```
or install from the source
```
git clone
pip install -r requirements.txt
python setup.py install
```
## Dependencies
- numpy
- scipy
- Pillow
- PyTorch
- opencv
- scikit-image
## Usage
For more useage, check out the [example-classification.py](./test/example-classification.py) and [example-segmentation.py](./test/example-segmentation.py)
``` python
from torchvision_x.datasets import image_loader
from torchvision_x.transforms import transforms_seg,functional
transform = transforms_seg.SegCompose([
# transforms_seg.SegFlip(),
transforms_seg.SegVFlip(),
# transforms_seg.SegHFlip(),
# transforms_seg.SegRandomFlip(),
# transforms_seg.SegRandomRotate(90),
# transforms_seg.SegRandomShift(40),
# transforms_seg.SegRandomCrop((256,256)),
# transforms_seg.SegCenterCrop(224),
# transforms_seg.SegResize(224),
# transforms_seg.SegPad(20),
# transforms_seg.SegNoise(dtype='uint16', var=0.001), #TODO
# transforms_seg.SegGaussianBlur(sigma=2, dtype='uint8', multichannel=False),
# transforms_seg.SegPieceTransform(),
# transforms_seg.SegLambda(lambda x: functional.to_tensor(x))
transforms_seg.SegToTensor(),
transforms_seg.SegNormalize((0.5,0.5,0.5),(0.5,0.5,0.5)),
])
trainset = image_loader.SemanticSegmentationLoader(
rootdir='sample-data/', lstpath='sample-data/segmentation_jpg.lst',
filetype='jpg', transform=transform,
)
trainloader = DataLoader(dataset=trainset,batch_size=batch_size,shuffle=False)
for step, (inputs, targets) in enumerate(trainloader):
print('batch: {} ........'.format(step))
print(type(inputs), inputs.shape)
print(type(targets), targets.shape)
```
## TODO
- Noise
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
torchvision-enhance-0.1.3.tar.gz
(13.4 kB
view details)
File details
Details for the file torchvision-enhance-0.1.3.tar.gz
.
File metadata
- Download URL: torchvision-enhance-0.1.3.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f03d638216b33d299d4238fb8f9a5c9968373c33c651e9f8620fd1bf0980eee |
|
MD5 | a0e6ad8f987525d69a027e9e6529d50e |
|
BLAKE2b-256 | a4ae7e1ac9784927b4ae5174c6f6533acacfa964982c30f77cd379ebfbaa7fd6 |