-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinspect_grape_data.py
62 lines (42 loc) · 1.18 KB
/
inspect_grape_data.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
54
55
56
57
58
59
60
61
62
import os
import sys
import json
import datetime
import numpy as np
import skimage.draw
from mrcnn.visualize import display_images
from mrcnn import visualize
path ="D:\DLCode\wgisd\data\CDY_2019"
image_path=path+'.jpg'
image = skimage.io.imread(image_path)
list=[]
list.append(image)
#display_images(images=list,cols=1)
mask_path=path+'.npz'
masks = np.load(mask_path)['arr_0']
bbox_path=path+'.txt'
bboxes = np.loadtxt(bbox_path)
bboxes=bboxes[:,1:]
bboxes2=np.zeros(bboxes.shape,dtype=np.int)
bboxes2[:,0]=bboxes[:,1]*1365-bboxes[:,3]*1365*0.5
bboxes2[:,1]=bboxes[:,0]*2048-bboxes[:,2]*2048*0.5
bboxes2[:,2]=bboxes[:,1]*1365+bboxes[:,3]*1365*0.5
bboxes2[:,3]=bboxes[:,0]*2048+bboxes[:,2]*2048*0.5
'''
bboxes2[:,0]=bboxes[:,0]*2048
bboxes2[:,1]=bboxes[:,1]*1365
bboxes2[:,2]=bboxes[:,2]*2048
bboxes2[:,3]=bboxes[:,3]*1365
'''
print(bboxes2)
print(masks.shape)
print(bboxes.shape)
#print(bboxes)
#display_images([image]+[masks[:,:,i] for i in range(masks.shape[-1])])
#class_ids
#class_ids=[0,0,]
class_ids=np.ones(masks.shape[-1],dtype=np.int)
class_names=["BG","grape"]
print(class_ids.shape)
visualize.display_instances(image, bboxes2, masks,class_ids,class_names)
print("show image..")