Open zeynepiskndr opened 1 year ago
Have you fixed it?
Unfortunately no!
problem solved
problem solved
how to solve it?
I noticed that the format in the annotation file is not appropriate. The segmentation section was empty and I ran some code. This piece of code worked for me.
import json
from pprint import pprint
def convert_bbox_to_polygon(bbox):
x = bbox[0]
y = bbox[1]
w = bbox[2]
h = bbox[3]
polygon = [x,y,(x+w),y,(x+w),(y+h),x,(y+h)]
return([polygon])
def main():
file_path = "annotation_file_name.json"
f = open(file_path)
data = json.load(f)
for line in data["annotations"]:
segmentation = convert_bbox_to_polygon(line["bbox"])
line["segmentation"] = segmentation
with open("annotation_file_name_edit.json", 'w') as f:
f.write(json.dumps(data))
print('DONE')
main()
I noticed that the format in the annotation file is not appropriate. The segmentation section was empty and I ran some code. This piece of code worked for me.
import json from pprint import pprint def convert_bbox_to_polygon(bbox): x = bbox[0] y = bbox[1] w = bbox[2] h = bbox[3] polygon = [x,y,(x+w),y,(x+w),(y+h),x,(y+h)] return([polygon]) def main(): file_path = "annotation_file_name.json" f = open(file_path) data = json.load(f) for line in data["annotations"]: segmentation = convert_bbox_to_polygon(line["bbox"]) line["segmentation"] = segmentation with open("annotation_file_name_edit.json", 'w') as f: f.write(json.dumps(data)) print('DONE') main()
Thanks!
我注意到注释文件中的格式不合适。分段部分是空的,我运行了一些代码。 这段代码对我有用。
import json from pprint import pprint def convert_bbox_to_polygon(bbox): x = bbox[0] y = bbox[1] w = bbox[2] h = bbox[3] polygon = [x,y,(x+w),y,(x+w),(y+h),x,(y+h)] return([polygon]) def main(): file_path = "annotation_file_name.json" f = open(file_path) data = json.load(f) for line in data["annotations"]: segmentation = convert_bbox_to_polygon(line["bbox"]) line["segmentation"] = segmentation with open("annotation_file_name_edit.json", 'w') as f: f.write(json.dumps(data)) print('DONE') main()
I will report the same error in Mask RCNN. I am using a dataset similar to VOC. Can you provide a solution?
I noticed that the format in the annotation file is not appropriate. The segmentation section was empty and I ran some code. This piece of code worked for me.
import json from pprint import pprint def convert_bbox_to_polygon(bbox): x = bbox[0] y = bbox[1] w = bbox[2] h = bbox[3] polygon = [x,y,(x+w),y,(x+w),(y+h),x,(y+h)] return([polygon]) def main(): file_path = "annotation_file_name.json" f = open(file_path) data = json.load(f) for line in data["annotations"]: segmentation = convert_bbox_to_polygon(line["bbox"]) line["segmentation"] = segmentation with open("annotation_file_name_edit.json", 'w') as f: f.write(json.dumps(data)) print('DONE') main()
Thank you a lot!
Checklist
Describe the bug
Reproduction
Environment
python mmdet/utils/collect_env.py
to collect necessary environment information and paste it here. /opt/conda/lib/python3.10/site-packages/requests/init.py:109: RequestsDependencyWarning: urllib3 (2.0.4) or chardet (None)/charset_normalizer (3.2.0) doesn't match a supported version! warnings.warn( sys.platform: linux Python: 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0] CUDA available: False numpy_random_seed: 2147483648 GCC: gcc (Debian 10.2.1-6) 10.2.1 20210110 PyTorch: 1.13.1+cu117 PyTorch compiling details: PyTorch built with:TorchVision: 0.14.1+cu117 OpenCV: 4.8.0 MMEngine: 0.8.4 MMDetection: 3.1.0+f78af77
Error traceback If applicable, paste the error trackback here.