mirror of
https://github.com/davrot/pytutorial.git
synced 2025-04-16 12:16:42 +02:00
Update README.md
Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
This commit is contained in:
parent
6a4bba51e0
commit
9dba2084ae
1 changed files with 127 additions and 5 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
Initial Image:
|
||||
|
||||

|
||||

|
||||
|
||||
```python
|
||||
import cv2
|
||||
|
@ -159,17 +159,139 @@ plt.show()
|
|||
|
||||

|
||||
|
||||
### Random Rotation
|
||||
```python
|
||||
|
||||
random_rotation_transform = tv.transforms.RandomRotation(degrees=(0, 180))
|
||||
for i in range(1, 10):
|
||||
new_image = random_rotation_transform(torch_image)
|
||||
plt.subplot(3, 3, i)
|
||||
plt.imshow(np.moveaxis(new_image.detach().numpy(), 0, 2))
|
||||
plt.show()
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
### Random Affine
|
||||
|
||||
```python
|
||||
|
||||
random_affine_transform = tv.transforms.RandomAffine(degrees=(0, 180))
|
||||
for i in range(1, 10):
|
||||
new_image = random_affine_transform(torch_image)
|
||||
plt.subplot(3, 3, i)
|
||||
plt.imshow(np.moveaxis(new_image.detach().numpy(), 0, 2))
|
||||
plt.show()
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
### Random Crop
|
||||
|
||||
```python
|
||||
random_crop_transform = tv.transforms.RandomCrop(size=(250, 200))
|
||||
for i in range(1, 10):
|
||||
new_image = random_crop_transform(torch_image)
|
||||
plt.subplot(3, 3, i)
|
||||
plt.imshow(np.moveaxis(new_image.detach().numpy(), 0, 2))
|
||||
plt.show()
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Random Invert
|
||||
```python
|
||||
random_invert_transform = tv.transforms.RandomInvert(p=0.5)
|
||||
for i in range(1, 3):
|
||||
new_image = random_invert_transform(torch_image)
|
||||
plt.subplot(2, 1, i)
|
||||
plt.imshow(np.moveaxis(new_image.detach().numpy(), 0, 2))
|
||||
plt.show()
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Random Posterize
|
||||
|
||||
```python
|
||||
for i in range(1, 5):
|
||||
random_posterize_transform = tv.transforms.RandomPosterize(bits=i, p=1.0)
|
||||
new_image = random_posterize_transform((torch_image * 255).type(dtype=torch.uint8))
|
||||
plt.subplot(2, 2, i)
|
||||
plt.imshow(np.moveaxis(new_image.detach().numpy(), 0, 2))
|
||||
plt.show()
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
### Random Solarize
|
||||
|
||||
```python
|
||||
random_solarize_transform = tv.transforms.RandomSolarize(threshold=0.5)
|
||||
new_image = random_solarize_transform(torch_image)
|
||||
plt.imshow(np.moveaxis(new_image.detach().numpy(), 0, 2))
|
||||
plt.show()
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
### Random Adjust Sharpness
|
||||
|
||||
```python
|
||||
random_sharpness_transform = tv.transforms.RandomAdjustSharpness(
|
||||
sharpness_factor=50, p=1.0
|
||||
)
|
||||
new_image = random_sharpness_transform(torch_image)
|
||||
plt.subplot(1, 2, 1)
|
||||
plt.imshow(np.moveaxis(torch_image.detach().numpy(), 0, 2))
|
||||
plt.subplot(1, 2, 2)
|
||||
plt.imshow(np.moveaxis(new_image.detach().numpy(), 0, 2))
|
||||
plt.show()
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Random Autocontrast
|
||||
|
||||
```python
|
||||
random_autocontrast_transform = tv.transforms.RandomAutocontrast(p=1.0)
|
||||
|
||||
new_image = random_autocontrast_transform(torch_image)
|
||||
plt.subplot(1, 2, 1)
|
||||
plt.imshow(np.moveaxis(torch_image.detach().numpy(), 0, 2))
|
||||
plt.subplot(1, 2, 2)
|
||||
plt.imshow(np.moveaxis(new_image.detach().numpy(), 0, 2))
|
||||
plt.show()
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Random Erasing
|
||||
|
||||
```python
|
||||
random_erasing_transform = tv.transforms.RandomErasing(p=1.0)
|
||||
|
||||
new_image = random_erasing_transform(torch_image)
|
||||
plt.imshow(np.moveaxis(new_image.detach().numpy(), 0, 2))
|
||||
plt.show()
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Auto Augment
|
||||
|
||||
```python
|
||||
random_auto1_transform = tv.transforms.AutoAugment(
|
||||
tv.transforms.AutoAugmentPolicy.CIFAR10
|
||||
)
|
||||
for i in range(1, 10):
|
||||
new_image = random_auto1_transform((torch_image * 255).type(dtype=torch.uint8))
|
||||
plt.subplot(3, 3, i)
|
||||
plt.imshow(np.moveaxis(new_image.detach().numpy(), 0, 2))
|
||||
plt.show()
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
```python
|
||||
|
|
Loading…
Add table
Reference in a new issue