Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/icoxfog417/mlimages
prepare the image data set for machine learning
https://github.com/icoxfog417/mlimages
computer-vision machine-learning
Last synced: 6 days ago
JSON representation
prepare the image data set for machine learning
- Host: GitHub
- URL: https://github.com/icoxfog417/mlimages
- Owner: icoxfog417
- License: mit
- Created: 2016-02-20T07:18:24.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T20:25:39.000Z (almost 2 years ago)
- Last Synced: 2024-10-31T06:49:47.386Z (11 days ago)
- Topics: computer-vision, machine-learning
- Language: Python
- Size: 1.11 MB
- Stars: 24
- Watchers: 5
- Forks: 12
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mlimages
gather and create image dataset for machine learning.
![imagenet](./doc/mlimages.PNG)
## How to use
```
pip install mlimages
```Or clone the repository. Then you can execute examples.
If you want to do fine tuning, you can download pretrained model in `examples/pretrained` by [git lfs](https://git-lfs.github.com/).This tool dependes on Python 3.5 that has async/await feature!
## Gather Images
Please make python file in your project folder as below.
```py
import mlimages.scripts.gather_command as cmdif __name__ == "__main__":
ps = cmd.make_parser()
args = ps.parse_args()
cmd.main(args)
```### Imagenet
Confirm the **WordnetID** on the [ImageNet site](http://image-net.org/synset)
![imagenet](./doc/imagenet.PNG)
Then download it.
```
python your_script_file.py -p path/to/data/folder -imagenet --wnid n11531193
```## Labeling
You can create training data from images data folder.
Please make python file in your project folder as below.
```py
import mlimages.scripts.label_command as cmdif __name__ == "__main__":
ps = cmd.make_parser()
args = ps.parse_args()
cmd.main(args)
```Then run it.
```
python label.py path/to/images/folder --out path/to/training_data.txt
```## Training
Now, you have images and training_data.txt.
But you have to do some pre-processing to train your model. For example...* resize image
* normalize image
* sometimes change color...:sob:
Don't warry. mlimages supports you!
```py
from mlimages.model import LabelFile, ImagePropertylf = LabelFile("path/to/training_data.txt", img_root="path_to_your_image_folder")
prop = ImageProperty(width=32, gray_scale=True)td = lf.to_training_data(prop)
td.make_mean_image("path/to/mean_image") # store mean image to normalizefor d in td.generate():
# d is numpy array that adjusted according to ImageProperty, and normalized by mean_image!
# only you have to do is train the model by it!
print(d)```
And also, you can restore the image from data.
```py
image = td.result_to_image(numpy_array, label)
```