@@ -112,6 +112,22 @@ def tasks_dump(self, task_id, fileformat, filename, **kwargs):
112
112
with open (filename , 'wb' ) as fp :
113
113
fp .write (response .content )
114
114
115
+ def tasks_upload (self , task_id , fileformat , filename , ** kwargs ):
116
+ """ Upload annotations for a task in the specified format
117
+ (e.g. 'YOLO ZIP 1.0')."""
118
+ url = self .api .tasks_id_annotations_format (task_id , fileformat )
119
+ while True :
120
+ response = self .session .put (
121
+ url ,
122
+ files = {'annotation_file' :open (filename , 'rb' )}
123
+ )
124
+ response .raise_for_status ()
125
+ if response .status_code == 201 :
126
+ break
127
+
128
+ log .info ('Upload job for Task ID {} \
129
+ with annotation file {} finished' .format (task_id , filename ))
130
+
115
131
116
132
class CVAT_API_V1 ():
117
133
""" Build parameterized API URLs """
@@ -135,6 +151,10 @@ def tasks_id_data(self, task_id):
135
151
def tasks_id_frame_id (self , task_id , frame_id ):
136
152
return self .tasks_id (task_id ) + '/frames/{}' .format (frame_id )
137
153
154
+ def tasks_id_annotations_format (self , task_id , fileformat ):
155
+ return self .tasks_id (task_id ) + '/annotations?format={}' \
156
+ .format (fileformat )
157
+
138
158
def tasks_id_annotations_filename (self , task_id , name , fileformat ):
139
159
return self .tasks_id (task_id ) + '/annotations/{}?format={}' \
140
160
.format (name , fileformat )
0 commit comments