1111api = Namespace ('annotation' , description = 'Annotation related operations' )
1212
1313create_annotation = reqparse .RequestParser ()
14- create_annotation .add_argument ('image_id' , type = int , required = True , location = 'json' )
14+ create_annotation .add_argument (
15+ 'image_id' , type = int , required = True , location = 'json' )
1516create_annotation .add_argument ('category_id' , type = int , location = 'json' )
1617create_annotation .add_argument ('metadata' , type = dict , location = 'json' )
1718create_annotation .add_argument ('segmentation' , type = list , location = 'json' )
@@ -41,8 +42,9 @@ def post(self):
4142 image = current_user .images .filter (id = image_id , deleted = False ).first ()
4243 if image is None :
4344 return {"message" : "Invalid image id" }, 400
44-
45- logger .info (f'{ current_user .username } has created an annotation for image { image_id } ' )
45+
46+ logger .info (
47+ f'{ current_user .username } has created an annotation for image { image_id } ' )
4648
4749 try :
4850 annotation = AnnotationModel (
@@ -69,7 +71,7 @@ def get(self, annotation_id):
6971
7072 if annotation is None :
7173 return {"message" : "Invalid annotation id" }, 400
72-
74+
7375 return query_util .fix_ids (annotation )
7476
7577 @login_required
@@ -80,10 +82,12 @@ def delete(self, annotation_id):
8082 if annotation is None :
8183 return {"message" : "Invalid annotation id" }, 400
8284
83- image = current_user .images .filter (id = annotation .image_id , deleted = False ).first ()
85+ image = current_user .images .filter (
86+ id = annotation .image_id , deleted = False ).first ()
8487 image .flag_thumbnail ()
8588
86- annotation .update (set__deleted = True , set__deleted_date = datetime .datetime .now ())
89+ annotation .update (set__deleted = True ,
90+ set__deleted_date = datetime .datetime .now ())
8791 return {'success' : True }
8892
8993
@@ -92,5 +96,3 @@ def delete(self, annotation_id):
9296# def get(self, annotation_id):
9397# """ Returns the binary mask of an annotation """
9498# return query_util.fix_ids(AnnotationModel.objects(id=annotation_id).first())
95-
96-
0 commit comments