# How to programmatically add polygon annotations text files with a matching image?

**URL:** <https://discuss.roboflow.com/t/how-to-programmatically-add-polygon-annotations-text-files-with-a-matching-image/1443>\
**Category:** 🤝  Community Help\
**Created:** [February 10, 2023, 12:06pm UTC](https://discuss.roboflow.com/t/how-to-programmatically-add-polygon-annotations-text-files-with-a-matching-image/1443 "2023-02-10T12:06:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RoniLALANN](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/ronilalann/32/1192_2.png) [@RoniLALANN](https://discuss.roboflow.com/u/RoniLALANN)\
**Post date:** [February 10, 2023, 12:06pm UTC](https://discuss.roboflow.com/t/how-to-programmatically-add-polygon-annotations-text-files-with-a-matching-image/1443/1 "2023-02-10T12:06:14Z")

</div>

Hi, I tried loading images with text files annotated as polygon (x1,y,…x4,y4).  
I had two problems:

1. The annotations are not drawn on the image as a polygon but as a BB. I want to put in YOLOv5 ob.
2. Some of the images have no objects, so the annotation file is empty. The software recognizes this as annotation images. How to solve?

Please share the following so we may better assist you:

1. Project type (Object detection-Polygon)
2. The operating system & browser you are using and their versions: windows10  
Thanks,  
Roni

---

<div class="post-metadata">

**Author:** ![RoniLALANN](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/ronilalann/32/1192_2.png) [@RoniLALANN](https://discuss.roboflow.com/u/RoniLALANN)\
**Post date:** [February 11, 2023, 1:55pm UTC](https://discuss.roboflow.com/t/how-to-programmatically-add-polygon-annotations-text-files-with-a-matching-image/1443/2 "2023-02-11T13:55:46Z")

</div>

1. Some of the images have no objects, so the annotation file is empty. The software recognizes this image to be without annotations.

---

<div class="post-metadata">

**Author:** ![trevorhlynn](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/trevorhlynn/32/1690_2.png) [@trevorhlynn](https://discuss.roboflow.com/u/trevorhlynn)\
**Post date:** [February 14, 2023, 4:44pm UTC](https://discuss.roboflow.com/t/how-to-programmatically-add-polygon-annotations-text-files-with-a-matching-image/1443/3 "2023-02-14T16:44:13Z")

</div>

Hello!

Full resources for Uploading via API are here [Upload API - Roboflow](https://docs.roboflow.com/adding-data/upload-api)

This video is a detailed walk through which shows uploading multiple detection formats [Upload an Annotation with the Roboflow API - YouTube](https://youtu.be/PL50dgdbV1Q)

For images without objects, you’ll need to indicate if they are unannotated or if they are NULL. Unannotated would put them into a queue to be annotated and NULL would indicate your objects of interest are not in the image.

---

<div class="post-metadata">

**Author:** ![RoniLALANN](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/ronilalann/32/1192_2.png) [@RoniLALANN](https://discuss.roboflow.com/u/RoniLALANN)\
**Post date:** [February 14, 2023, 5:35pm UTC](https://discuss.roboflow.com/t/how-to-programmatically-add-polygon-annotations-text-files-with-a-matching-image/1443/4 "2023-02-14T17:35:42Z")

</div>

Thank you very much for the answer! I’ll go over it .  
Have a nice day and thanks again!  
Roni

‫בתאריך יום ג׳, 14 בפבר׳ 2023 ב-18:54 מאת ‪trevorhlynn via Roboflow‬‏ \<‪[notifications@roboflow1.discoursemail.com](mailto:notifications@roboflow1.discoursemail.com)‬‏\>:‬

---

<div class="post-metadata">

**Author:** ![RoniLALANN](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/ronilalann/32/1192_2.png) [@RoniLALANN](https://discuss.roboflow.com/u/RoniLALANN)\
**Post date:** [February 16, 2023, 8:34am UTC](https://discuss.roboflow.com/t/how-to-programmatically-add-polygon-annotations-text-files-with-a-matching-image/1443/5 "2023-02-16T08:34:24Z")

</div>

Hi Trevor,  
Well, I watched the video. I’ll give it a try although I’ve already tried programmatically uploading files and it didn’t recognize them as OBB text files. Is there no parameter in the API for polygon type annotation?  
Another problem: I have some text files that are NULL. How can these files be uploaded programmatically? Last time I tried, the images just came up without the corresponding empty text files.

Thank You!  
Roni

---

<div class="post-metadata">

**Author:** ![Mohamed](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/mohamed/32/62_2.png) [@Mohamed](https://discuss.roboflow.com/u/Mohamed)\
**Post date:** [March 2, 2023, 7:21pm UTC](https://discuss.roboflow.com/t/how-to-programmatically-add-polygon-annotations-text-files-with-a-matching-image/1443/6 "2023-03-02T19:21:00Z")

</div>

YOLOv5 format doesn’t keep annotation records for null annotations. You’ll need to mark those images null in the platform.

Did your YOLOv5-obb format match the example on the annotation formats examples page?

- [What is the YOLOv5 Oriented Bounding Boxes Annotation Format?](https://roboflow.com/formats/yolov5-obb)

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/2X/d/de9ce0ac646a463bbb071570c3735333f4efebb1.png)

We do have a CLI option for upload, too: [Command Line Interface - Roboflow](https://docs.roboflow.com/command-line-interface#using-the-roboflow-cli)
