|
1 | 1 | # DupliPy 0.1.9 |
| 2 | + |
| 3 | + |
2 | 4 |
|
3 | 5 | An open source Python library for text formatting, augmentation, and similarity calculation tasks in NLP. |
4 | 6 |
|
@@ -114,6 +116,43 @@ bleu_value = bleu_score(text1, text2) |
114 | 116 | print(bleu_value) # Output: 0.434 |
115 | 117 | ``` |
116 | 118 |
|
| 119 | +### Image Augmentation |
| 120 | + |
| 121 | +```python |
| 122 | +from PIL import Image |
| 123 | +from duplipy.replication import flip_horizontal, flip_vertical, rotate, random_rotation, resize, crop, random_crop |
| 124 | + |
| 125 | +# Load an image for testing |
| 126 | +image_path = "path/to/image.jpg" |
| 127 | +image = Image.open(image_path) |
| 128 | + |
| 129 | +# Flip the image horizontally |
| 130 | +flipped_horizontal_image = flip_horizontal(image) |
| 131 | + |
| 132 | +# Flip the image vertically |
| 133 | +flipped_vertical_image = flip_vertical(image) |
| 134 | + |
| 135 | +# Rotate the image by a specific angle (e.g., 45 degrees) |
| 136 | +rotated_image = rotate(image, 45) |
| 137 | + |
| 138 | +# Apply a random rotation to the image within a specified range of angles (e.g., -30 to 30 degrees) |
| 139 | +randomly_rotated_image = random_rotation(image, max_angle=30) |
| 140 | + |
| 141 | +# Resize the image to a specific target size (e.g., 224x224 pixels) |
| 142 | +resized_image = resize(image, target_size=(224, 224)) |
| 143 | + |
| 144 | +# Crop a random region from the image (e.g., 150x150 pixels) |
| 145 | +randomly_cropped_image = random_crop(image, crop_size=(150, 150)) |
| 146 | + |
| 147 | +# Save the augmented images (optional, if you want to view the results) |
| 148 | +flipped_horizontal_image.save("path/to/flipped_horizontal.jpg") |
| 149 | +flipped_vertical_image.save("path/to/flipped_vertical.jpg") |
| 150 | +rotated_image.save("path/to/rotated.jpg") |
| 151 | +randomly_rotated_image.save("path/to/randomly_rotated.jpg") |
| 152 | +resized_image.save("path/to/resized.jpg") |
| 153 | +randomly_cropped_image.save("path/to/randomly_cropped.jpg") |
| 154 | +``` |
| 155 | + |
117 | 156 | ## Contributing |
118 | 157 |
|
119 | 158 | Contributions are welcome! If you encounter any issues, have suggestions, or want to contribute to DupliPy, please open an issue or submit a pull request on [GitHub](https://github.com/infinitode/duplipy). |
|
0 commit comments