Cannot upload the annotated files

This category is for question related to accounts on https://app.roboflow.com/

Hi,
I cannot upload the annotated files for the images. The annotated files are in txt format. I have also tried uploading XML format. It did not happen. It’s not even taking the files, and not annotating the images.

Am I doing something wrong. Please let me know if any more info is needed for resolving this issue

Please share the following so we may better assist you:

  1. Project type (Object detection, Classification, Polygon, etc.): Object detection
  2. The operating system & browser you are using and their versions: Windows (doesn’t matter)
  3. The screenshot of the error being triggered in your browser’s developer tools/console. Please copy/paste the url below to watch how to pull up your devtools

Hi @Vaibhav_Yalla

Whenever I’ve had trouble with uploading annotation files, it’s usually because they were formatted wrong or were referencing image file names or file paths that were different from what is being uploaded.

Can you check whether the filename in your annotation file and the file name in your uploaded Roboflow image match? Also, check if the file path references an image that’s actually there when it’s uploading. (I’m not sure if Roboflow uses this to match image files, but it might be good to check)

You can check the image name in a Pascal VOC XML here:

<annotation>
	<filename>** the name of the file should be here **</filename>
	<path>** the path of the file should be here **</path>
*rest of the annotation file ...*

and check the image name on an uploaded Roboflow image under the “Attributes” tab:
image

If that doesn’t solve your issue, did you manually create the annotation files yourself or were they created in a different app or website? (if so what was that app or website) If you could also send the text contents of the annotation files, that might be helpful for troubleshooting.

1 Like

Hi Stellasphere,
Thanks for the fast reply.

I think the issue is with the format I have. (The file paths, and the file names are same)

The annotated text file I have is in this format:

1 58 78 427 627
1 440 84 813 627

I think the roboflow needs it in the below format:
1 0.159375 0.20078125 0.2375 0.4015625
1 0.63828125 0.203125 0.7234375 0.40625

Both are different annotations. Do you know how to convert the above (which txt file I have) into this decimal format?

Because when I tried providing these decimal values, its getting annotated.

Hi @Vaibhav_Yalla

That looks to be the YOLO Darknet TXT format. I found this GitHub issue and it looks like that format uses the ratio of the images, not the pixel measurements.

  • <x> <y> <width> <height> - float values relative to width and height of image, it can be equal from (0.0 to 1.0)
  • for example: <x> = <absolute_x> / <image_width> or <height> = <absolute_height> / <image_height>

For your first annotation’s x value, for example, would need to be 58 / *image width*

So, to fix your annotations, you would need to divide your values by the image width or image height.

Hope this helps

1 Like

Exactly correct @stellasphere!

@Vaibhav_Yalla, as suggested above, you’ll need to configure your annotation files to fit the YOLO Darknet TXT format, or the Pascal VOC XML format.

Here’s an example for the YOLO Darknet TXT format: What is the YOLO Darknet TXT Annotation Format?

Here’s an example for Pascal VOC XML: What is the Pascal VOC XML Annotation Format?

All of the formats we accept for import/export are listed here as well: Computer Vision Annotation Formats

  • Each format page offers an example of the annotation format’s structure

Hi,

I am still facing an issue in converting my annotated files to DarkNet TXT.

This one of the annotated file I have:
1 58 78 427 627
1 440 84 813 627
1 822 86 1257 633
1 70 636 593 1175
1 608 644 1251 1183
1 60 1194 703 1735
1 718 1190 1253 1741

This is the correct DarkNet result:
0 0.1971153846153846 0.1935096153846154 0.2764423076923077 0.29086538461538464
0 0.8125 0.19471153846153846 0.31971153846153844 0.2932692307692308
0 0.25841346153846156 0.4951923076923077 0.4110576923076923 0.296875
0 0.7271634615384616 0.4963942307692308 0.4987980769230769 0.29447115384615385
0 0.3004807692307692 0.7992788461538461 0.5060096153846154 0.2956730769230769
0 0.7692307692307693 0.8004807692307693 0.4110576923076923 0.296875
0 0.4891826923076923 0.19591346153846154 0.28966346153846156 0.2932692307692308

This is the result I got when I converted: (which is wrong I guess)
0 0.0453125 0.04271631982475356 0.33359375 0.3433734939759036
0 0.34375 0.04600219058050383 0.63515625 0.3433734939759036
0 0.6421875 0.047097480832420595 0.98203125 0.3466593647316539
0 0.0546875 0.348302300109529 0.46328125 0.6434830230010953
0 0.475 0.35268346111719606 0.97734375 0.6478641840087623
0 0.046875 0.6538882803943045 0.54921875 0.9501642935377875
0 0.5609375 0.651697699890471 0.97890625 0.9534501642935378

I have used this formula:
w = 1280 (width of image)
h = 1826 (height of image)
xc = 58
yc = 78
wc = 427
hc = 627

X = xc/w
Y = yc/h
W = wc/w
H = hc/h
print(X,Y,W,H)

Can anyone please help me with the formula.

Hi @Vaibhav_Yalla

I missed a part of the format when I sent the initial post. The Darknet TXT format takes in X and Y coordinates at the center of the annotation, not the top left.

attention: <x_center> <y_center> - are center of rectangle (are not top-left corner)
From YOLO v4 Darknet Docs: How to train (to detect your custom objects)

Meaning, the calculation for X, for example, should be: (I’m taking xc to mean centered x)

xc = ( x + (annotation_width/2) ) / image_width

I’m not sure where you got the corrected annotations, but when I did the calculations from the first annotation, the values you sent at the bottom, it should be:

xc = (58+(427/2))/1280
xc = 0.212109375

It’s not exactly what your correct X value was, which is why I said I’m not sure where you got them from, but it’s close so I hope this helps solve your issue.

Solution
Hi all,

For annotation my dataset is in Pascal VOC format, as shown below:
1 58 78 427 627
1 440 84 813 627
1 822 86 1257 633
1 70 636 593 1175
1 608 644 1251 1183
1 60 1194 703 1735
1 718 1190 1253 1741

Here there are 7 lines, which means 7 different annotations are present. Let’s consider the first line.
→ ‘1’ represents the name of the annotation
→ ‘58’ represents xmin, ‘78’ represents ymin, ‘427’ represents xmax, and ‘627’ represents ymax.
→ We also need to know the width and height of the actual image (not the annotated one).
For this it was 1280x1826.

What we want is Xc, Yc, width and height from xmin, xmax,ymin,ymax, height_of_image, width_of_image, as shown in the figure below:

To convert the Pascal VOC into Darknet format, we need to find Xc, Yc, height, width.

We have (Given),
xmin = 58
ymin = 78
xmax = 427
ymax = 627
w = 1280
h = 1826

To Find:
xc = ((xmin+xmax)/2)/w
yc = ((ymin+ymax)/2)/h
width = (xmax-xmin)/w
height = (ymax-ymin)/h

After substituting all the lines we will convert in darknet format as shown below:
1 0.189453125 0.19304490690032858 0.28828125 0.30065717415115006
1 0.489453125 0.19468784227820374 0.29140625 0.2973713033953998
1 0.812109375 0.19687842278203724 0.33984375 0.29956188389923327
1 0.258984375 0.49589266155531214 0.40859375 0.29518072289156627
1 0.726171875 0.5002738225629791 0.50234375 0.29518072289156627
1 0.298046875 0.802026286966046 0.50234375 0.296276013143483
1 0.769921875 0.8025739320920043 0.41796875 0.3017524644030668

This can be inserted in RoboFlow.

Reference: