pip install graphviz easydev
node와 edge로 이루어진 그래프를 만들며,
간단한 코드로 시각화가 가능하다.
documents
https://graphviz.readthedocs.io/en/stable/
sg = gv.Digraph() # 그래프 생성
anns_rel_n2c = annotation_util.get_rel_n2c()
for obj_idx, obj_info in enumerate(scene_info['visible_object']): # object node, 속성 node/edge 추가
with sg.subgraph(name=str(obj_idx)) as obj_g:
obj_g.node(str(obj_info['id']), label=obj_info['name'], shape='box')
# is_open 추가
obj_g.node(str(obj_info['id'])+'_isOpen', label={-1:'o_un', 0:'close', 1:'open'}[obj_info['is_open']], shape='ellipse', style='filled', color='lightgrey')
obj_g.edge(str(obj_info['id'])+'_isOpen', str(obj_info['id']), dir='none')
# color 추가
obj_g.node(str(obj_info['id']) + '_color', label=obj_info['color'], shape='ellipse', style='filled', color='lightgrey')
obj_g.edge(str(obj_info['id']) + '_color', str(obj_info['id']), dir='none')
for relaion in scene_info['relaion']: # 관계 edge 추가
sg.edge(str(relaion['subject_id']), str(relaion['object_id']), label=' '+anns_rel_n2c[relaion['rel_class']])
sg.render('./gv_temp.gv', view=True, cleanup=True) # 랜더링
'실습 > python' 카테고리의 다른 글
| python2 버전 코드를 python3 버전 코드로 바꾸기 (0) | 2018.08.23 |
|---|---|
| [matplotlib] pyplot 공백 완벽하게 제거하기 (0) | 2018.08.15 |
| [colormap] 색상계 변환 모듈 (0) | 2018.07.25 |
| [OpenCV vs Pillow vs Scikit-Image] 영상 처리 속도 비교 (1) | 2018.07.17 |
| pandas 데이터 처리 및 csv 입출력 (0) | 2018.07.15 |