Comments (17)
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 convert_pred_yolo.py
from map.
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/obj.data"
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
time.sleep(6)
# Send the signal to all the process groups
#os.killpg(os.getpgid(p.pid), 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")
from map.
Done! Have a look here.
Basically, all you have to do is add the
result.txt
to the folderextra/
and run the commandpython convert_pred_yolo.py
Hey, i am not able to find the page. could you redirect me please so that i can find the file
from map.
Hey, you can look at my repo:
https://github.com/pratikbhave2/darknet
from map.
I don't get it. What is in your repo?
from map.
I have Modified Yolo to run detector test on multiple images and save each image with bounding boxes, as well as co-ordinates of the bounding box in a text file(separate text file). You can run it with the same command
.
./darknet detector test cfg/voc.data yolo-voc.cfg yolo-voc.weights -dont_show -ext_output < data/train.txt > result.txt
from map.
Hello!
@EscVM I could help you parse that. Do you think you could send me the full file result.txt
to here [email protected] ?
Another option, as mentioned by @pratikbhave2, is to modify the files to save the predictions into separate files.
from map.
Thank you @pratikbhave2 and @Cartucho. I'll try both solutions.
from map.
Btw I did the python script with a lot of comments so everything should be easy to understand!
from map.
Thank so much @Cartucho ! I really need to improve my Python skills 🤕
from map.
@Cartucho thanks alot for posts. just a question this is how my result.txt file looks like.
when i execute the script (python convert_pred_yolo.py) , i get this error below
from map.
@buzdarbalooch Hello!
Do you think you could send me a sample of the files? So that I can reproduce the error?
from map.
Done! Have a look here.
Basically, all you have to do is add the
result.txt
to the folderextra/
and run the commandpython convert_pred_yolo.py
so how to get result.txt in faster rcnn
from map.
Hey, you can look at my repo:
Hey when i run using your repo in yolov3 i am getting segmentation error.. could you help me out please?
/bin/bash: line 1: 1655 Segmentation fault (core dumped) ./darknet detector test data/obj.data cfg/yolov3_custom_test.cfg /mydrive/weapon_dataset/backup/yolov3_custom_train_last.weights -dont_show -save_labels < data/train.txt > result.txt
from map.
Hey, you can look at my repo:
https://github.com/pratikbhave2/darknetHey when i run using your repo in yolov3 i am getting segmentation error.. could you help me out please?
/bin/bash: line 1: 1655 Segmentation fault (core dumped) ./darknet detector test data/obj.data cfg/yolov3_custom_test.cfg /mydrive/weapon_dataset/backup/yolov3_custom_train_last.weights -dont_show -save_labels < data/train.txt > result.txt
I get the same error
from map.
i changed the code from vadimen a little bit, it no need for wait 6s every time, parent process continue after child process exit
and i copy the ground truth to prediction dir too as a comparison
it worked for me
import os
from os import getcwd
import subprocess
import time
import shutil
wd = getcwd()
image_paths_file = "data/train-second/test.txt"
obj_dat = "data/train-second/obj.data"
yolo_cnf = "cfg/yolov4-custom-3.cfg"
yolo_wghts = "backup/yolov4-custom-3_best.weights"
path_to_ground_truth = "data/pic_with_box"
im_paths = open(image_paths_file).read().strip().split('\n')
cfgfilename = yolo_cnf.split('/')[1].split('.')[0]
print(cfgfilename)
path_to_save_predictions = "predictions-%s/"%(cfgfilename)
if not os.path.exists(path_to_save_predictions):
os.makedirs(path_to_save_predictions)
for im in im_paths:
if len(im) == 0:
continue
cmd = "./darknet detector test %s %s %s -dont_show %s"%(obj_dat, yolo_cnf, yolo_wghts, im)
print('cmd = %s'%(cmd))
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, preexec_fn=os.setsid)
# wait max 6s
p.wait(6)
# make sure child process exit normally
if p.poll() != 0:
print("picture %s predict fails\n"%(im))
break
image_name = (im.split('/')[-1]).split('.')[0]
os.rename("predictions.jpg", os.path.join(path_to_save_predictions, image_name+'.jpg'))
# cp groud truth near the predictions dir
# already draw box and saved in path_to_ground_truth dir, if not want to copy, just comment the next line
shutil.copy(path_to_ground_truth+'/'+image_name+'.jpg', path_to_save_predictions+'/'+image_name+"-truth.jpg")
print(image_name)
from map.
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/obj.data" 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 time.sleep(6) # Send the signal to all the process groups #os.killpg(os.getpgid(p.pid), 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")
Thanks for the code. It works well. How to get output of bounding box coordinates for each image in this file itself?
I'm trying but not possible. Request to assist me.
from map.
Related Issues (20)
- Having trouble putting inputs in correct format HOT 1
- Query regarding Average Precision Curve
- If there are no targets being detected, these pictures will not be put into calculation. Will this influence the accuracy? HOT 1
- map is 0 HOT 1
- Incorrect mAP when boxes are normalized to [0-1]
- map for validation set?
- How to use this py to calculate coco dataset‘s mAp?
- how to set up individual IoU threshold value?
- Segmentation evaluation?
- 有问题询问
- Does the order make an effect? HOT 4
- How to get the Map 0.5:0.95 HOT 2
- Animation with big images
- different mAP with Alexey darknet HOT 2
- I'm confused, there is no approximation ?
- Map goog
- mAP for each frame HOT 1
- Deprecation warnings with Matplotlib 3.4 HOT 1
- Does it accept empty file?
- convert_dr_yolo.py script not creating any files in detection-results folder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from map.