Skip to content

Commit b2e06f4

Browse files
authored
Update readme.md
Added usage examples for image augmentation and some badges.
1 parent cbf158b commit b2e06f4

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

readme.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# DupliPy 0.1.9
2+
![PyPI Version](https://img.shields.io/pypi/v/duplipy)
3+
![Python Version](https://img.shields.io/badge/python-3.11-blue.svg)
24

35
An open source Python library for text formatting, augmentation, and similarity calculation tasks in NLP.
46

@@ -114,6 +116,43 @@ bleu_value = bleu_score(text1, text2)
114116
print(bleu_value) # Output: 0.434
115117
```
116118

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+
117156
## Contributing
118157

119158
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

Comments
 (0)