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

YOLOv4 annotations bounding box #206

Open
adnankarol opened this issue Feb 18, 2021 · 1 comment
Open

YOLOv4 annotations bounding box #206

adnankarol opened this issue Feb 18, 2021 · 1 comment

Comments

@adnankarol
Copy link

adnankarol commented Feb 18, 2021

@AlexeyAB
Output of YOLO
class1: 30% (left_x: 1594 top_y: 5 width: 823 height: 398)
class2: 89% (left_x: 1624 top_y: 11 width: 766 height: 384)

Ground Truth File
class2 0.6834710743801653 -0.0007513148009012858 0.9954545454545455 0.9984973703981965
class1 0.6875436293114982 0.00983195749251466 0.9105397751844504 0.989553997972583

I need to Transform the Output of YOLO to Ground Truth File ---- MAIN DOUBT

Format for Ground Truth File :
x1min y1min x2max y2max

Format of YOLO :
<x_center> <y_center>

One formula which I had was for YOLO to Ground Truth

x1min = (xc - (0.5 * w))/img_w
x2max = (xc + (0.5 * w))/img_w
y1min = (yc - (0.5 * h))/img_h
y2max = (yc + (0.5 * h))/img_h

This gave output as
class1 0.48863636363636365 -0.485 0.8287190082644628 0.51
class2 0.5128099173553718 -0.4525 0.8293388429752067 0.5075

This is close but not exactly the same as Ground Truth

@thegamercoder19
Copy link

Hi, first you have negative bounding boxes. Try imgaug. x1,y1 is top-most coords and w = x2-x1. Center coords are just x1 + 0.5w. So if you want to convert yolov3 keras format to yolo darknet:
import cv2 im = cv2.imread('path/to/your/image.ext') wr, hr = im.shape w = x2-x1 h = y2-y1 cx = x1+0.5*w cy = y1+0.5*h cx, cy = cx / wr, cy / hr w, h = w / wr, h / hr with open("annotation.txt","w+") as f: f.write(f"class {cx} {cy} {w} {h}\n"); f.close()

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

No branches or pull requests

2 participants