-
Notifications
You must be signed in to change notification settings - Fork 18
/
draw_box_example.py
36 lines (29 loc) · 1002 Bytes
/
draw_box_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
#########################################################
#
# Alejandro German
#
# https://github.com/seralexger/clothing-detection-dataset
#
#########################################################
from PIL import Image
import json
import glob
import random
import matplotlib.pyplot as plt
import matplotlib.patches as patches
files_list = glob.glob('data/*.json')
img_data = json.loads(open(files_list[random.randint(0, len(files_list)-1)]).read())
normal_img = Image.open('dataset/' + img_data['file_name'])
#fig,ax = plt.subplots(1)
fig=plt.figure(figsize=(8, 8))
columns = 4
rows = 5
for index,item in enumerate(img_data['arr_boxes']):
box = patches.Rectangle((item['x'], item['y']), item['width'], item['height'],linewidth=2,edgecolor=(random.uniform(0.0,1.0), random.uniform(0.0,1.0),random.uniform(0.0,1.0)) ,facecolor='none', label = item['class'])
ax = fig.add_subplot(111)
ax.add_patch(box)
ax.axis('off')
plt.legend()
plt.imshow(normal_img)
plt.show()