Skip to content

Commit

Permalink
doc file was changed
Browse files Browse the repository at this point in the history
  • Loading branch information
hakanaktas1 committed Jun 4, 2023
1 parent 8b383a9 commit 7139ffa
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 16 deletions.
39 changes: 34 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<img src ="icons\logo.png"/>
<br>
<p>


[![PyPI](https://img.shields.io/badge/aug--tool-v0.0.1-blue)](https://pypi.org/project/aug-tool/)
[![Supported Python Versions](https://img.shields.io/badge/python%20-3-blue)](https://pypi.python.org/pypi/Augmentor)
[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE)

# AUG-TOOL: Image Augmentation Tool for Machine Learning Projects

Seamlessly integrate powerful language models like ChatGPT into scikit-learn for enhanced text analysis tasks.
Aug Tool is a Python library available on PyPI that simplifies image data augmentation for machine learning tasks, compatible with TensorFlow, PyTorch, and the YOLO library.

## Installation

Expand All @@ -29,10 +29,10 @@ To install "aug-tool", you can use pip, the Python package manager. Open a termi

* Supports various image augmentation techniques suitable for real environment conditions, such as adding noise, scaling, shifting, and more.
* Provides convenient integration with popular machine learning libraries such as **TensorFlow**, **Keras**, **PyTorch**, etc.
* Allows augmentation of both images and their annotation files in formats such as XML, or TXT. (json will be added soon)
* Allows augmentation of both images and their annotation files in formats such as XML, or TXT.
* Customizable augmentation parameters, including rotation angle, scaling factor, flipping direction, and more.

* Supports augmentation of multiple images and annotation files in batch mode.


## Documentation
### Simple usage:
Expand All @@ -56,4 +56,33 @@ Augmentation(open_data_path=open_file_name,
# Continue with further processing or analysis
```

### Package Structure:
### Package Structure Diagram:

```python
src/ #root file
└── aug_tool/ #main package
├── __init__.py
├── dataOpener/ #sub package1
│ ├── __init__.py
│ ├── dataOp.py
│ ├── imgOp.py
│ ├── annOp.py
│ ├── xmlOp.py
│ └── txtOp.py
├── dataAugmentor/ #sub package2
│ ├── __init__.py
│ ├── dataAug.py
│ ├── imgAug.py
│ ├── annAug.py
│ ├── xmlAug.py
│ └── txtAug.py
├── dataSaver/ #sub package3
│ ├── __init__.py
│ ├── dataSav.py
│ ├── imgSav.py
│ ├── annSav.pys
│ ├── xmlSav.py
│ └── txtSav.py
└── augmentation.py
```
### Class Diagram:
Binary file modified icons/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/logo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 27 additions & 11 deletions src/aug-tool/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,39 @@

class Augmentation(object):
def __init__(self, open_data_path:str, save_file_name:str, number_of_aug:int, x_shift:int, y_shift:int) -> None:
"""
This is an initialization function that takes in parameters for data augmentation and saves the
augmented data and annotations to a specified file path.
:param open_data_path: The path to the directory containing the original data to be augmented
:type open_data_path: str
:param save_file_name: The name of the folder where the augmented data will be saved
:type save_file_name: str
:param number_of_aug: The number of times the image and its corresponding annotation will be
augmented
:type number_of_aug: int
:param x_shift: The amount of horizontal shift to apply during image augmentation
:type x_shift: int
:param y_shift: y_shift is a parameter that determines the maximum number of pixels by which an
image can be shifted vertically during data augmentation
:type y_shift: int
"""

self.open_data_path = open_data_path
self.save_file_name = save_file_name
self.ann = None
self.img = None


self.create_dest_folder(self.target_file_name)

for data_path in self.create_list_of_data(open_data_path = open_data_path):

self.label_factory(data_path[:-4])
self.image_factory(data_path)
image = self.label_factory(data_path[:-4])
label = self.image_factory(data_path)

for num in range(number_of_aug):

data_name = data_path.split("\\")[-1][:-4] + "_aug" + str(num + 1)

aug_image = dataAugmentor.ImgAug(image=self.img,
aug_image = dataAugmentor.ImgAug(image=image,
x_shift=x_shift,
y_shift=y_shift).image_aug

Expand All @@ -37,7 +53,7 @@ def __init__(self, open_data_path:str, save_file_name:str, number_of_aug:int, x_
if self.ann.ext == ".xml":

ann_aug = dataAugmentor.XmlAug(name=data_name,
annotate= self.ann.data,
annotate= label.data,
x_shift=x_shift,
y_shift=y_shift)

Expand All @@ -49,7 +65,7 @@ def __init__(self, open_data_path:str, save_file_name:str, number_of_aug:int, x_
elif self.ann.ext == ".txt":

ann_aug = dataAugmentor.TxtAug(
annotate= self.ann.data,
annotate= label.data,
x_shift=x_shift,
y_shift=y_shift,
width=aug_image.width,
Expand Down Expand Up @@ -116,17 +132,17 @@ def target_file_name(self) -> str:
def label_factory(self, path:str):

if os.path.exists(path + ".xml"):
self.ann = dataOpener.XmlFileOpener(path + ".xml")
return dataOpener.XmlFileOpener(path + ".xml")

elif os.path.exists(path + ".txt"):
self.ann = dataOpener.TxtFileOpener(path + ".txt")
return dataOpener.TxtFileOpener(path + ".txt")

else:
logging.exception('There is no any annotation file that has ext such as .xml or .txt in this directory')

def image_factory(self, path:str):
try:
self.img = dataOpener.ImgOpener(path).data
return dataOpener.ImgOpener(path).data
except:
logging.exception('Could not open image file. (Check its extension.)')

Expand Down

0 comments on commit 7139ffa

Please sign in to comment.