https://github.com/theeluwin/pytorch-quadratum
Additional torchvision image transforms for practical usage.
https://github.com/theeluwin/pytorch-quadratum
computer-vision deep-learning preprocessing pytorch torchvision
Last synced: 6 months ago
JSON representation
Additional torchvision image transforms for practical usage.
- Host: GitHub
- URL: https://github.com/theeluwin/pytorch-quadratum
- Owner: theeluwin
- License: mit
- Created: 2018-05-15T14:47:16.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-03T14:27:30.000Z (almost 6 years ago)
- Last Synced: 2025-09-07T09:42:52.444Z (10 months ago)
- Topics: computer-vision, deep-learning, preprocessing, pytorch, torchvision
- Language: Python
- Size: 13.7 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Quadratum
==========
Additional torchvision image transforms for practical usage.
Just for me. I needed it.
Note that all functors implemented here assumes an input image to be (H, W, C)-size np.uint8, ranged from 0 to 255.
* `Whiten`: make all transparent pixels white.
* `Invert`: invert RGB values.
* `Dominofy`: limits the ratio of an image, like dominos.
* `Contain`: contains an image into the given canvas (or box, whatever), just like, you know, the `background-size: contain;` thingy from CSS.
---
Installation
-----
```bash
pip install quadratum
```
---
Usage
-----
Similar to all the other transform functors:
```python
from quadratum import transforms as qtrfm
from torchvision import transforms as vtrfm
transform = vtrfm.Compose([
qtrfm.Whiten(),
qtrfm.Dominofy(),
qtrfm.Contain(256),
vtrfm.ToPILImage(),
vtrfm.CenterCrop(224),
vtrfm.ToTensor(),
vtrfm.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])
```
or, you can use some pre-defined transformers:
```python
from skimage.io import imread
from quadratum.transformer import Transformer
transform = Transformer('resnet')
image = imread('image.png') # image.shape => (640, 960, 4)
x = transform(image) # x.size() => torch.Size([3, 224, 224])
```
---
The term "quadratum" means "square" in Latin. I wanted to make any noisy user-input images into fine-nice-good-well-godlike-heaven-deep-learning-applicable-preprocessed-square-images.