#Downy Mildew Disease detection TensorFlow object detection + Downy Mildew Disease detection
- Install labelImg: pip3 install labelImg
- Directory structure: Object-Detection->data ->training ->images ->train ->test
3.change code xml_to_csv.py def main(): for directory in ['train','test']: image_path = os.path.join(os.getcwd(), 'images/{}'.format(directory)) xml_df = xml_to_csv(image_path) xml_df.to_csv('data/{}_labels.csv'.format(directory), index=None) print('Successfully converted xml to csv.')
-
Run python3 xml_to_csv.py
-
Change code in generate_tfrecord.py
def class_text_to_int(row_label): if row_label == 'downy': return 1 else: return 0
- Run python3 generate_tfrecord.py --csv_input=data/train_labels.csv --output_path=data/train.record --image_dir=images/
python3 generate_tfrecord.py --csv_input=data/test_labels.csv --output_path=data/test.record --image_dir=images/
Now, in your data directory, you should have train.record and test.record.
- Clone fresh tensorflow models git clone https://github.com/tensorflow/models.git
Then, follow the installation instructions:
sudo apt-get install protobuf-compiler python-pil python-lxml sudo pip install jupyter sudo pip install matplotlib
- Go to research foilder and open terminal
protoc object_detection/protos/*.proto --python_out=.
9.set python path
export PYTHONPATH=$PYTHONPATH:pwd
:pwd
/slim
-
Install in to python sudo python3 setup.py install
-
wget http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_coco_11_06_2017.tar.gz
Get Mobilnet configuration files
-
Get the sample config files from models/research/object_detection/samples/configs/ssd_mobilenet_v1_pets.config edit the config file with all the path #change num of classes num_classes: 1 #change the batch size batch_size: 24 #change if you want initial_learning_rate: 0.004
fine_tune_checkpoint: "ssd_mobilenet_v1_coco_11_06_2017/model.ckpt"
input_path: "data/train.record"
label_map_path: "data/object-detection.pbtxt"
input_path: "data/test.record"
label_map_path: "training/object-detection.pbtxt"
After Editing above items, Put the config in the training directory.
-
Inside training dir, add object-detection.pbtxt: Add all your classes.
item { id: 1 name: 'downy' }
-
Add Object-Detection.pbtxt file in into data directory
-
Copy data, image, training, ssd_mobilenet_v1_coco_11_06_2017 (unzipped) in to object-detection directory) merge the data directory with existing directory
-
Run the command: python3 model_main.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config
-
If any error wrt 'nets' then set the python Path again on research directory # From tensorflow/models/research export PYTHONPATH=$PYTHONPATH:
pwd
:pwd
/slim -
find the temp directory where the event files are generated and run #Try-->
tensorboard --logdir='/tmp/tmp8ecnodas'
in browser open--> http://127.0.0.1:6006/
-
run python3 export_inference_graph.py
--input_type image_tensor
--pipeline_config_path training/ssd_mobilenet_v1_pets.config
--trained_checkpoint_prefix training/model.ckpt-23361
--output_directory invoice_inference_graph_23361 -
Run--> jupyter notebook
-
Goto object_detection_tutorial.ipynb directry -->In Variables
MODEL_NAME = 'invoice_graph_2'
PATH_TO_FROZEN_GRAPH = MODEL_NAME + '/frozen_inference_graph.pb'
PATH_TO_LABELS = os.path.join('training', 'object-detection.pbtxt')
NUM_CLASSES=1
-->delete Download Model content(optional)
-->In Detection
PATH_TO_TEST_IMAGES_DIR = 'test_images' TEST_IMAGE_PATHS = [ os.path.join(PATH_TO_TEST_IMAGES_DIR, 'image{}.jpg'.format(i)) for i in range(1, 10) ]#range() as per the number of images
IMAGE_SIZE = (12, 8)
- goto Cell -->Run All Take a look at test results