image preprocessing
Project description
imagepreprocessing
- Creates train ready data for keras or yolo in a single line
- Makes prediction with using keras model
- Plots confusion matrix
Install
pip install imagepreprocessing
Usage
from imagepreprocessing import create_training_data_keras, create_training_data_yolo, create_only_path_files_yolo, make_prediction, create_confusion_matrix
Create training data for keras
source_path = "datasets/deep_learning/food-101/only3"
save_path = "food10class1000sampleeach"
create_training_data(source_path, save_path, img_size = 299, validation_split=0.1, percent_to_use=0.1, grayscale = True, files_to_exclude=["excludemoe","hi.txt"])
File name: apple_pie - 1/3 Image:100/100
File name: baby_back_ribs - 2/3 Image:100/100
File name: baklava - 3/3 Image:100/100
validation x: 30 validation y: 30
train x: 270 train y: 270
shape of train x: (270, 299, 299, 1)
shape of train y: (270, 3)
shape of validate x: (30, 299, 299, 1)
shape of validate y: (30, 3)
file saved -> C:\Users\can\Desktop\food3class100sampleeach_x_train.pkl
file saved -> C:\Users\can\Desktop\food3class100sampleeach_y_train.pkl
file saved -> C:\Users\can\Desktop\food3class100sampleeach_x_validation.pkl
file saved -> C:\Users\can\Desktop\food3class100sampleeach_y_validation.pkl
Make prediction with a keras model and plot confusion matrix
images_path = "deep_learning/test_images/food2"
model_path = "deep_learning/saved_models/alexnet.h5"
predictions = make_prediction(images_path, model_path)
class_names = ["apple", "melon", "orange"]
labels = [0,0,0,1,1,1,2,2,2]
create_confusion_matrix(predictions, labels, class_names=class_names)
1.jpg : 0
2.jpg : 0
3.jpg : 0
4.jpg : 1
5.jpg : 1
6.jpg : 2
7.jpg : 2
8.jpg : 2
9.jpg : 1
Confusion matrix, without normalization
[[3 0 0]
[0 2 1]
[0 1 2]]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file imagepreprocessing-0.3.0.tar.gz.
File metadata
- Download URL: imagepreprocessing-0.3.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a05d0ff6abcfcd83f9fa2759ee829466e7485467bf7baac6dedef72b4d9cecfd
|
|
| MD5 |
0f96b0761adbf7153d534c543ac916c8
|
|
| BLAKE2b-256 |
f0055d9106eab059201f233eb54ee50fa3e7553124c3341d5fa47644c8822938
|