Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save the predictions of YOLO (You Only Look Once) Object detection in a jsonb field in a database

I want to run Darknet(YOLO) on a number of images and store its predictions in PostgreSQL Database.

This is the structure of my table:

sample=> \d+ prediction2;
                       Table "public.prediction2"
   Column    | Type  | Modifiers | Storage  | Stats target | Description 
-------------+-------+-----------+----------+--------------+-------------
 path        | text  | not null  | extended |              | 
 pred_result | jsonb |           | extended |              | 
Indexes:
    "prediction2_pkey" PRIMARY KEY, btree (path)

Darknet(YOLO)'s source files are written in C.

I have already stored Caffe's predictions in the database as follows. I have listed one of the rows of my database here as an example.

 path                                            |   pred_result                                                                                                                                           
-------------------------------------------------+------------------------------------------------------------------------------------------------------------------
 /home/reena-mary/Pictures/predict/gTe5gy6xc.jpg | {"bow tie": 0.00631, "lab coat": 0.59257, "neck brace": 0.00428, "Windsor tie": 0.01155, "stethoscope": 0.36260}

I want to add YOLO's predictions to the jsonb data of pred_result i.e for each image path and Caffe prediction result already stored in the database, I would like to append Darknet (YOLO's) predictions.

The reason I want to do this is to add search tags to each image. So, by running Caffe and Darknet on images, I want to be able to get enough labels that can help me make my image search better.

Kindly help me with how I should do this in Darknet.

like image 236
Reena Puthota Avatar asked Dec 10 '25 05:12

Reena Puthota


1 Answers

This is an issue I also encountered. Actually YOLO does not provide a JSON output interface, so there is no way to get the same output as from Caffe.

However, there is a pull request that you can merge to get workable output here: https://github.com/pjreddie/darknet/pull/34/files. It outputs CSV data, which you can convert to JSON to store in the database.

You could of course also alter the source code of YOLO to make your own implementation that outputs JSON directly.

like image 148
Simon Avatar answered Dec 13 '25 08:12

Simon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!