Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -18,9 +18,11 @@ def img2label(left, right):
|
|
18 |
# 读取模型
|
19 |
model = torch.load('densenet_FD_e4_l5e-4_b32.pkl', map_location='cpu').to(device)
|
20 |
|
|
|
21 |
with torch.no_grad():
|
22 |
output = model(left=left_img.unsqueeze(0), right=right_img.unsqueeze(0))
|
23 |
|
|
|
24 |
output = torch.sigmoid(output.squeeze(0))
|
25 |
output_ = output.cpu().numpy().tolist()
|
26 |
res_dict = {LABELS[i]: output_[i] for i in range(len(output_))}
|
@@ -56,6 +58,7 @@ if __name__ == '__main__':
|
|
56 |
transforms.Normalize(norm_mean, norm_std)
|
57 |
])
|
58 |
|
|
|
59 |
LABELS = {0: '正常',
|
60 |
1: '糖尿病',
|
61 |
2: '青光眼',
|
|
|
18 |
# 读取模型
|
19 |
model = torch.load('densenet_FD_e4_l5e-4_b32.pkl', map_location='cpu').to(device)
|
20 |
|
21 |
+
# 模型推理
|
22 |
with torch.no_grad():
|
23 |
output = model(left=left_img.unsqueeze(0), right=right_img.unsqueeze(0))
|
24 |
|
25 |
+
# 结果处理
|
26 |
output = torch.sigmoid(output.squeeze(0))
|
27 |
output_ = output.cpu().numpy().tolist()
|
28 |
res_dict = {LABELS[i]: output_[i] for i in range(len(output_))}
|
|
|
58 |
transforms.Normalize(norm_mean, norm_std)
|
59 |
])
|
60 |
|
61 |
+
# 标签设置
|
62 |
LABELS = {0: '正常',
|
63 |
1: '糖尿病',
|
64 |
2: '青光眼',
|