diff --git a/README.md b/README.md index 9232904df..cd3072e49 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,15 @@ To use your webcam/camera, simply replace `videofile.avi` with keyword `camera`. To save a video with predicted bounding box, add `--saveVideo` option. +## Evaluating accuracy +To evaluate the performance of your model, you can use **mean Average Precision (mAP)** metric from [this repository here](https://github.com/Cartucho/mAP). It works well with darkflow's predicted `json` files. + +1) Clone [mAP](https://github.com/Cartucho/mAP) repository +2) Flow your darkflow model with `--json` option. Then move the predicted `json` files into the `predicted` folder of mAP repo. +3) Move your ground truth annotation files into `ground-truth` folder. (E.g. `.xml` files generated from [labelImg](https://github.com/tzutalin/labelImg) or `.txt` files generated from [BBox-Label-Tool](https://github.com/puzzledqs/BBox-Label-Tool)) +4) Read the `README.md` and `extra/README.md` of that repository for further information, you'll need to run some `extra/` scripts based on your circumstance. +5) Run `python main.py` of mAP repo. + ## Using darkflow from another python application Please note that `return_predict(img)` must take an `numpy.ndarray`. Your image must be loaded beforehand and passed to `return_predict(img)`. Passing the file path won't work. diff --git a/darkflow/utils/pascal_voc_clean_xml.py b/darkflow/utils/pascal_voc_clean_xml.py index 70eb3e0fc..9666c5f60 100644 --- a/darkflow/utils/pascal_voc_clean_xml.py +++ b/darkflow/utils/pascal_voc_clean_xml.py @@ -19,7 +19,8 @@ def pascal_voc_clean_xml(ANN, pick, exclusive = False): cur_dir = os.getcwd() os.chdir(ANN) annotations = os.listdir('.') - annotations = glob.glob(str(annotations)+'*.xml') + # annotations = glob.glob(str(annotations)+'*.xml') + annotations = glob.glob('*.xml') size = len(annotations) for i, file in enumerate(annotations): @@ -36,7 +37,10 @@ def pascal_voc_clean_xml(ANN, pick, exclusive = False): in_file = open(file) tree=ET.parse(in_file) root = tree.getroot() - jpg = str(root.find('filename').text) + # jpg = str(root.find('filename').text) + from pathlib import Path + jpg = str(Path(file).with_suffix('.jpg').name) + # print('jpg:', jpg) imsize = root.find('size') w = int(imsize.find('width').text) h = int(imsize.find('height').text) diff --git a/preview.png b/preview.png index 2827ee6a5..d2e84828e 100644 Binary files a/preview.png and b/preview.png differ diff --git a/sample_img/sample_computer.jpg b/sample_img/sample_computer.jpg index 1a3b717ac..57795e6a5 100644 Binary files a/sample_img/sample_computer.jpg and b/sample_img/sample_computer.jpg differ diff --git a/sample_img/sample_dog.jpg b/sample_img/sample_dog.jpg index 77b038122..a22b880b1 100644 Binary files a/sample_img/sample_dog.jpg and b/sample_img/sample_dog.jpg differ diff --git a/sample_img/sample_eagle.jpg b/sample_img/sample_eagle.jpg index 8b7509505..310091db4 100644 Binary files a/sample_img/sample_eagle.jpg and b/sample_img/sample_eagle.jpg differ diff --git a/sample_img/sample_giraffe.jpg b/sample_img/sample_giraffe.jpg index a93e8b883..2a171e7ea 100644 Binary files a/sample_img/sample_giraffe.jpg and b/sample_img/sample_giraffe.jpg differ diff --git a/sample_img/sample_horses.jpg b/sample_img/sample_horses.jpg index 3a761f46b..3985d38ff 100644 Binary files a/sample_img/sample_horses.jpg and b/sample_img/sample_horses.jpg differ diff --git a/sample_img/sample_person.jpg b/sample_img/sample_person.jpg index 61d377fff..ba4a95ae6 100644 Binary files a/sample_img/sample_person.jpg and b/sample_img/sample_person.jpg differ diff --git a/sample_img/sample_scream.jpg b/sample_img/sample_scream.jpg index 43f2c36a8..82b34e393 100644 Binary files a/sample_img/sample_scream.jpg and b/sample_img/sample_scream.jpg differ diff --git a/test/training/images/1.jpg b/test/training/images/1.jpg index 3d4294383..1f8e56cce 100644 Binary files a/test/training/images/1.jpg and b/test/training/images/1.jpg differ diff --git a/test/training/images/2.jpg b/test/training/images/2.jpg index 1ee3cd5f3..7b721798f 100644 Binary files a/test/training/images/2.jpg and b/test/training/images/2.jpg differ