- Download & unzip pictures under data directory
wget http://download.tensorflow.org/example_images/flower_photos.tgz
Examples
daisy | dandelion | roses | sunflowers | tulips |
- Split files into two folders: train and test with tools/shuflink
cd data
../tools/shuflink flower_photos train test
cd ..
$python train.py -h
Training models are saved under logs. After training, you should move one of them to model directory and rename it as “flower.model“ for evaluation and prediction.
pip install visdom
python -m visdom.server &
python train.py
http://127.0.0.1:8097
$ python eval.py -h
$ python eval.py
Evaluating data information:
Dataset ImageFolder
Number of datapoints: 918
Root Location: data/test
Transforms (if any): Compose(
Resize(size=256, interpolation=PIL.Image.BILINEAR)
CenterCrop(size=(224, 224))
ToTensor()
Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
)
Target Transforms (if any): None
Class names: ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']
2018-09-28 15:31:19,234 - model.py[line:203] - INFO: Start evaluating ...
2018-09-28 15:31:21,553 - model.py[line:222] - INFO: Evaluating ACC: 99.24%
2018-09-28 15:31:21,553 - model.py[line:223] - INFO: Evaluating finished.
python predict.py -h
python predict.py images/daisy_5794835_d15905c7c8_n.jpg
Image class: 0, daisy, 1.00, images/daisy_5794835_d15905c7c8_n.jpg
-
Python 3.6
-
Pytorch 0.4.0, 1.0
-
Torchvision 0.2.1
-
Pillow 4.2.1
ImageCNN is released under the [Apache 2.0 license]
通用图像分类器.