-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpre_trained_reg.py
43 lines (34 loc) · 969 Bytes
/
pre_trained_reg.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
from model_light import*
from tqdm import tqdm
from config import*
model = build_regess_model()
print("loading model weights from ",model_direc)
model.load_weights(model_direc)
sz=img_size[0]
def change_t(boxe):
a=[]
a.append(boxe[0]*sz)
a.append(boxe[1]*sz)
a.append(boxe[2]*sz)
a.append(boxe[3]*sz)
return a
def change_t2(boxe):
a=[]
a.append(boxe[1]*640/224)
a.append(boxe[3]*640/224)
a.append(boxe[0]*480/224)
a.append(boxe[2]*480/224)
return a
st=os.listdir(test_direc)
pred=[]
print("making predictions")
for i in tqdm(st):
img=read_for_validation(test_direc+i)
a = np.expand_dims(img, axis=0)
bbx=change_t2(change_t(model.predict(a).squeeze()))
pred.append(bbx)
df = pd.DataFrame(pred,index=st)
df.reset_index(inplace=True)
df.columns=['image_name','x1','x2','y1','y2']
print("check your folder a new file containing co-ordinats is created in working dir")
df.to_csv('regression.csv',index=None)