Cocodataset - Ipynb - Colaboratory
Cocodataset - Ipynb - Colaboratory
ipynb - Colaboratory
1 # https://machinelearningspace.com/coco-dataset-a-step-by-step-guide-to-loading-and-visual
2 # 1. Downloading and Extracting the COCO dataset
3 # 2. Understanding`| the structure of the COCO Format
4 # 3. Creating the COCOParser Class
5 # 4. Loading and Visualizing the Dataset
6
7
8 !wget http://images.cocodataset.org/zips/train2017.zip -O coco_train2017.zip
9 !wget http://images.cocodataset.org/zips/val2017.zip -O coco_val2017.zip
10 !wget http://images.cocodataset.org/annotations/annotations_trainval2017.zip -O coco_ann20
7 # remove zipfile
8 zfileTOremove=f"{extract_path}"+".zip"
9 if os.path.isfile(zfileTOremove):
10 os.remove(zfileTOremove)
11 else:
12 print("Error: %s file not found" % zfileTOremove)
13 except BadZipFile as e:
14 print("Error:", e)
15 extract_train_path = "./coco_train2017"
16 extract_val_path = "./coco_val2017"
17 extract_ann_path="./coco_ann2017"
18 extract_zip_file(extract_train_path)
19 extract_zip_file(extract_val_path)
20 extract_zip_file(extract_ann_path)
1 coco_annotations_file="/content/coco_ann2017/annotations/instances_val2017.jso
2 coco_images_dir="/content/coco_val2017/val2017"
3 coco= COCOParser(coco_annotations_file, coco_images_dir)
img_ids : [397133, 37777, 252219, 87038, 174482, 403385, 6818, 480985, 458054, 331352, 2
sel_im_idxs : [2312 2702 2390 3853]
2
4
20
36
https://colab.research.google.com/drive/1g1kG0eozZCZWdUFbcav9KhXz8Ebsw1ji?hl=id#scrollTo=NXBY90f6GdW1&printMode=true 4/5
8/3/23, 10:17 AM cocodataset.ipynb - Colaboratory
https://colab.research.google.com/drive/1g1kG0eozZCZWdUFbcav9KhXz8Ebsw1ji?hl=id#scrollTo=NXBY90f6GdW1&printMode=true 5/5