Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

gpsmit
Copy link

@gpsmit gpsmit commented Nov 15, 2018

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 added 2 commits November 15, 2018 11:14
…or complete headless operation with input and output file locations
…or complete headless operation with input and output file locations
@gpsmit gpsmit changed the title Created headless detector test phase with valid JSON for every input all outputted to single JSON file Created headless detector test phase with JSON predictions and bounding boxes for every input image; all outputted to single JSON file Nov 15, 2018
added new command line detector test_headless explanation in readme
@rcfrias
Copy link

rcfrias commented Nov 23, 2018

would this also work with videos? I am looking for a similar json output for analysing video streams.

@gpsmit
Copy link
Author

gpsmit commented Nov 23, 2018

Sorry i responded a bit to quickly. I dont think it will work out of the box. Test_headless expects an input file of images. You could split up the video into separate frames and feed them via the input file. That would work. But a direct feed not im afraid

@gpsmit
Copy link
Author

gpsmit commented Feb 20, 2019

Updated the stb libraries to newer version, and started using stbi_assert instead of default assert.
The default assert caused darknet to dump its core on certain images. stbi_assert is a bit friendlier

@haviduck
Copy link

I would also love to see a video or stream being output in json. Just like the webserver stream where you push out json arrays. It would actually complete my current usecase.

@AlexeyAB
Copy link
Owner

@haviduck
Run Darknet by using this command:
./darknet detector demo ./cfg/coco.data ./cfg/yolov3.cfg ./yolov3.weights test50.mp4 -json_port 8070 -mjpeg_port 8090 -ext_output -dont_show

It will be launched as server. So you can connect to the port 8070 and 8090 by using web-browser Chrome/Firefox.

@haviduck
Copy link

Sorry for my bad explanation. As of right npw we do get a stream of good json im a browser when parsing a video. However, instead of streaming it id love to be able to store that entire array in a named json file. Regardless, thank u for a truly great repo

@tdurand
Copy link

tdurand commented Aug 7, 2019

@haviduck This solves your need: #3723

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants