-
Notifications
You must be signed in to change notification settings - Fork 30
/
instances2rgb.py
executable file
·53 lines (38 loc) · 1.06 KB
/
instances2rgb.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
import matplotlib.pyplot as plt
import imgviz
def instances2rgb():
data = imgviz.data.voc()
captions = [data["class_names"][label_id] for label_id in data["labels"]]
insviz1 = imgviz.instances2rgb(
image=data["rgb"],
bboxes=data["bboxes"],
labels=data["labels"],
captions=captions,
)
insviz2 = imgviz.instances2rgb(
image=data["rgb"],
masks=data["masks"] == 1,
labels=data["labels"],
captions=captions,
)
# -------------------------------------------------------------------------
plt.figure(dpi=200)
plt.subplot(131)
plt.title("rgb")
plt.imshow(data["rgb"])
plt.axis("off")
plt.subplot(132)
plt.title("instances\n(bboxes)")
plt.imshow(insviz1)
plt.axis("off")
plt.subplot(133)
plt.title("instances\n(masks)")
plt.imshow(insviz2)
plt.axis("off")
img = imgviz.io.pyplot_to_numpy()
plt.close()
return img
if __name__ == "__main__":
from base import run_example
run_example(instances2rgb)