For a detailed project report (German), click here
- Start by installing tensorflow.
pip install tensorflow==2.3
- Clone the github repository labelImg into the main directory. Make sure you follow all the steps provided in the repository.
- Create a new directory, call it Tensorflow/
- Switch to the directory Tensorflow
- Clone the Model Garen Repo into the directory Tensorflow/
- Create a new directory in the directory Tensorflow/, call it protoc/
- Install Protobuf and extract it in the just created folder
- You should now have 2 folders in the directory Tensorflow (models/ and protoc/)
- Make sure you are in the Tensorflow directory and run the command
protoc/bin/protoc models/research/object_detection/protos/*.proto --python_out=.
to compile all proto files - Install COCO API (only needed for evaluation) by running the command
pip install cython
andpip install git+https://github.com/philferriere/cocoapi.git
- Change directory to Tensorflow/models/research and running the following commands:
cp object_detection/packages/tf2/setup.py .
This will copy the installation file to the current directorypython -m pip install .
This will install it.- Test if your installation was succesful by running
python object_detection/builders/model_builder_tf2_test.py
Now you can start preparing the data.
- Change to the main directory (one folder above Tensorflow)
- Annotate your images using
python labelImg/labelImg.py
, make sure to place the annotations into the folder workspace/annotations - After you are done annotating your images, convert them to tfrecords using
python pascal_xml_to_tfrecords.py
- Create a new folder inside workspace, call it pre_trained_models/
- Go to the model zoo, and select a model you want to work with (e.g EfficientDet D0), extract the model into the pre_trained_models/ folder
- Inside the workspace/models/ directory, create another directory with with the name of just downloaded model (e.g efficientdet_d0/v1/)
- From the pre_trained_models/ folder, copy-and-paste the pipeline.config file into this folder.
- Open the models/efficientdet_d0/pipeline.config file and adjust it to your needs (see this github repo for example)
- You are now ready to train your network.
cd workspace python model_main_tf2.py --pipeline_config_path=./models/efficientdet_d0/v1/pipeline.config --model_dir=./models/efficientdet_d0/v1/ --checkpoint_every_n=10 --num_workers=4 --alsologtostderr
tensorboard --logdir=workspace/models/efficientdet_d0/v1/train
python exporter_main_v2.py --trained_checkpoint_dir=./models/efficientdet_d0/v1/ --pipeline_config_path=./models/efficientdet_d0/v1/pipeline.config --output_directory exported_models
python .\inference.py
python model_main_tf2.py --pipeline_config_path=./models/efficientdet_d0/v1/pipeline.config --model_dir=./models/efficientdet_d0/v1/ --checkpoint_dir=./models/efficientdet_d0/v1/--num_workers=4 --sample_1_of_n_eval_examples=1