ansrb553326
@ansrb553326
Reviews Written
-
Average Rating
-
CASELAB CO., LTD
Posts
Q&A
(windows) jupyter notebook ์ค์ตํ๊ฒฝ
๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค!
- 0
- 2
- 283
Q&A
์์์์ ์ค๋ช ํ๋ ์ฝ๋๊ฐ ์ jupyter notebook์ ์๋์??
# ! conda install -c conda-forge xmltodict # # xmltodict๋ XML ํ์ผ์ parsingํ์ฌ Dictionary์ list ํํ๋ก ๋ฐํํด์ค. import xmltodict import os import random VOC_ROOT_DIR = "../../data/voc/VOCdevkit/VOC2012" ANNO_DIR = os.path.join(VOC_ROOT_DIR, "Annotations") JPEG_DIR = os.path.join(VOC_ROOT_DIR, "JPEGImages") xml_files = os.listdir(ANNO_DIR) print(xml_files[:5]); print(len(xml_files)) ## xmltodict.parse()๋ฅผ ์ด์ฉํ์ฌ xml ํ์ผ์ Dictionary์ listํํ๋ก ๋ณํ sample_xml = os.path.join(ANNO_DIR, '2007_000032.xml') print('sample xml file : ', sample_xml) with open(sample_xml, 'rb') as f: # notice the "rb" mode parsed_dict = xmltodict.parse(f, xml_attribs = True) parsed_dict #### Annotation ๋ด์ Object๋ค์ bounding box ์ ๋ณด๋ฅผ ์ด์ฉํ์ฌ Bounding box ์๊ฐํ lmg_filename = parsed_dict['annotation']['filename'] lmg_filename = os.path.join(JPEG_DIR, lmg_filename) print(lmg_filename) lmg = cv2.imread(lmg_filename) lmg_rgb = cv2.cvtColor(lmg, cv2.COLOR_BGR2RGB) lmg_rgb_copy = img_rgb.copy() green_rgb = (125,255,51) for obj in parsed_dict['annotation']['object']: class_name = obj['name'] bndbox = obj['bndbox'] left = int(bndbox['xmin']) top = int(bndbox['ymin']) right = int(bndbox['xmax']) bottom = int(bndbox['ymax']) cv2.rectangle(lmg_rgb_copy, (left, top), (right, bottom), color=green_rgb, thickness=2) plt.figure(figsize=(8,8)) plt.imshow(lmg_rgb_copy) plt.show() ------------- ์ด ๋ถ๋ถ์ ๋ง์ํ์๋ ๊ฒ ๊ฐ์ต๋๋ค. 7:00 ~
- 0
- 5
- 227




