Saturday, November 9, 2019

Data Science Study Notes: Tutorial to run darkflow


This tutorial is simply to help user without too much computer science background(like me) to run darkflow demo on macbook system.

Step 1: install the following by opening a terminal:

Pip install - upgrade pip 
Pip Install tensorflow
Pip Install opencv-python

2. Download the github repository from the git location:
https://github.com/thtrieu/darkflow
Simply click the "clone or download" button to manually download the full zip file: darkflow-master.zip, copy that file to your personal working directory, for example, /User/your_user_name/, then unzip that file in the same directory. You will get many file/folder under the folder: darkflow-master folder.

3. Run the following code in your terminal "/User/your_user_name/" to install this software first, otherwise you will get some error message like
...
"xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'gcc' failed with exit status 1
...

It means that you need to install XCode command line, open a Terminal and run this command:
xcode-select --install
This will usually take a few mins to install the software.

4. Double check the code in the beginning of the executable file flow.exe:
Previously it might be something like this:
#! /usr/bin/env python
Change that to:
#! /usr/bin/env python3

5. Run the following code to install the module:
python3 setup.py build_ext --inplace

At the end of the installation, you should get some message like:
...
building 'darkflow.cython_utils.nms' extension
...
copying build/lib.macosx-10.7-x86_64-3.7/darkflow/cython_utils/nms.cpython-37m-darwin.so -> darkflow/cython_utils
copying build/lib.macosx-10.7-x86_64-3.7/darkflow/cython_utils/cy_yolo2_findboxes.cpython-37m-darwin.so -> darkflow/cython_utils
copying build/lib.macosx-10.7-x86_64-3.7/darkflow/cython_utils/cy_yolo_findboxes.cpython-37m-darwin.so -> darkflow/cython_utils

You might get some warning message, which is fine; However, if you got some error message, then you probably need to fix it first.

6. Double check to see if you have those weight file in the folder "bin" under your home folder "darkflow-master", otherwise manually go to this place to download the file:
"https://drive.google.com/drive/folders/0B1tW_VtY7onidEwyQ2FtQVplWEU", choose the last one to download and save to the folder "bin".

7. Once everything is ready, then run the following code to test the demo:
python flow --model cfg/yolo.cfg --load bin/yolo.weights --demo camera 

8. Click Esc on your keyboard to Exit the demo.

Here are two related article on towardsdatascience and medium:
1. https://towardsdatascience.com/yolov2-object-detection-using-darkflow-83db6aa5cf5f
2. https://medium.com/coinmonks/detecting-custom-objects-in-images-video-using-yolo-with-darkflow-1ff119fa002f


No comments:

Post a Comment

Data Science Study Notes: RFM model to identify the best customers

80% of your sales come from 20% of your customers. As a small business owner, even if you’ve never heard of the Pareto Principle, you know ...