Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi, I was trying to use your code with YOLOv3, but I have some problems to make predictions txt files. With ./darknet detector test cfg/ yolo-voc.cfg yolo-voc.weights -dont_show -ext_output < data/train.txt > result.txt I can generate a unique txt file with all results, but I really don’t have idea how to parse it. This is an example of result.txt file: <Total BFLOPS 65.864

seen 64 Enter Image Path: data/horses.jpg: Predicted in 42.076185 seconds. horse: 88% (left_x: 3 top_y: 185 width: 150 height: 167) horse: 99% (left_x: 5 top_y: 198 width: 307 height: 214) horse: 96% (left_x: 236 top_y: 180 width: 215 height: 169) horse: 99% (left_x: 440 top_y: 209 width: 156 height: 142) Enter Image Path: data/person.jpg: Predicted in 41.767213 seconds. dog: 99% (left_x: 58 top_y: 262 width: 147 height: 89) person: 100% (left_x: 190 top_y: 95 width: 86 height: 284) horse: 100% (left_x: 394 top_y: 137 width: 215 height: 206) Enter Image Path: >

Thank you so much for your help.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

vadimencommented, Apr 1, 2021

here is a simple code, works for yolov3 of v4 or any other, adjust the paths, time or even the command for yourself

import os
import subprocess
import time

image_paths_file = '/home/darknet/vadim_configs/test.txt'
path_to_save_images = '/home/darknet/results/'

im_paths = open(image_paths_file, "r").readlines()

obj_dat = "/home/darknet/vadim_configs/"
yolo_cnf = "/home/darknet/vadim_configs/yolov4-custom.cfg"
yolo_wghts = "/home/darknet/backup/yolov4-custom_best.weights"

for im in im_paths:
    cmd = "./darknet detector test {} {} {} -dont_show \"{}\"".format(obj_dat, yolo_cnf, yolo_wghts, im)

    # The os.setsid() is passed in the argument preexec_fn so
    # it's run after the fork() and before  exec() to run the shell.

    p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, preexec_fn=os.setsid)

    # it must be adjuste to your inference speed
    # on my rtx2080 takes 6 seconds max
    # Send the signal to all the process groups
    #os.killpg(os.getpgid(, signal.SIGTERM)

    image_name = (im.split('/')[-1]).split('.')[0]
    os.rename("predictions.jpg", os.path.join(path_to_save_images, image_name+'.jpg'))
    print("img was saved")
Cartuchocommented, Sep 12, 2018

Done! Have a look here.

Basically, all you have to do is add the result.txt to the folder extra/ and run the command python

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found