darknet icon indicating copy to clipboard operation
darknet copied to clipboard

Created headless detector test phase with JSON predictions and bounding boxes for every input image; all outputted to single JSON file

Open gpsmit opened this issue 5 years ago • 7 comments

This is loosely based on daltskin's fork, which outputted json data per image, but it turned out it wasn't really valid json and missed the file name information within the json structure. My need is to bulk process images, with an input file (containing image-paths) and output detections for every image to a single JSON file, which we can then process with other tooling. Furthermore I wasn't really pleased with the stdin implementation of feeding files and the overhead of having to perform the 'load the alphabet' and 'save predictions to image' steps which I don't need in my pipeline.

Therefore I created a new test phase: test_headless which takes a names file, cfg file and weights file, with an input file (with image paths) and output json file, like so: ./darknet detector test_headless data/openimages.names cfg/yolov3-openimages.cfg ../yolov3-openimages.weights -in_filename input.txt -out_filename output.json

I would love to see this merged in your fork as I think it will be useful for others. Let me know If I need to make further changes to the code, I tried to keep it as clean as possible without having to adjust existing code:

example output for one image:

{
    "darknet headless output": [
        {
            "fileName": "/Users/gpsmit/Downloads/marine.jpg",
            "predictions": [
                {
                    "height": 332,
                    "labels": [
                        {
                            "label": "Clothing",
                            "score": 30.192739
                        }
                    ],
                    "left_x": 4,
                    "top_y": 137,
                    "width": 482
                },
                {
                    "height": 375,
                    "labels": [
                        {
                            "label": "Person",
                            "score": 40.249172
                        }
                    ],
                    "left_x": 13,
                    "top_y": 84,
                    "width": 471
                },
                {
                    "height": 216,
                    "labels": [
                        {
                            "label": "Weapon",
                            "score": 32.131096
                        }
                    ],
                    "left_x": 237,
                    "top_y": 190,
                    "width": 652
                }
            ]
        }
    ]
}

gpsmit avatar Nov 15 '18 10:11 gpsmit