Spaces:
Sleeping
Sleeping
amazinghaha
commited on
Commit
·
d9a1752
1
Parent(s):
0563034
Update app.py
Browse files
app.py
CHANGED
@@ -51,22 +51,25 @@ def inference():
|
|
51 |
model.eval()
|
52 |
all_loss = 0
|
53 |
length = 0
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
58 |
|
59 |
-
|
60 |
-
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
70 |
|
71 |
|
72 |
|
@@ -131,7 +134,7 @@ def clear_all():
|
|
131 |
global Current_name
|
132 |
Current_name = None
|
133 |
Image_3D = None
|
134 |
-
return np.ones((10,10)),np.ones((10,10)),np.ones((10,10)),
|
135 |
|
136 |
class App:
|
137 |
def __init__(self):
|
|
|
51 |
model.eval()
|
52 |
all_loss = 0
|
53 |
length = 0
|
54 |
+
try:
|
55 |
+
with torch.no_grad():
|
56 |
+
data = torch.from_numpy(data)
|
57 |
+
image = torch.unsqueeze(data, 0)
|
58 |
+
patch_data = torch.unsqueeze(image, 0).to(device).float() # (N, C_{in}, D_{in}, H_{in}, W_{in})
|
59 |
|
60 |
+
# Pre : Prediction Result
|
61 |
+
pre_probs = model(patch_data)
|
62 |
|
63 |
+
# pre_probs = F.sigmoid(pre_probs)#todo
|
64 |
+
pre_flat = pre_probs.view(-1)
|
65 |
+
np.round(pre_flat.numpy()[0], decimals=2)
|
66 |
+
#(1-pre_flat.numpy()[0]).astype(np.float32)
|
67 |
+
#pre_flat.numpy()[0].astype(np.float32)
|
68 |
+
p = float(np.round(pre_flat.numpy()[0], decimals=2))
|
69 |
+
n = float(np.round(1-p, decimals=2))
|
70 |
+
return {'急性期': n, '亚急性期': p}
|
71 |
+
except:
|
72 |
+
return {'': ''}
|
73 |
|
74 |
|
75 |
|
|
|
134 |
global Current_name
|
135 |
Current_name = None
|
136 |
Image_3D = None
|
137 |
+
return np.ones((10,10)),np.ones((10,10)),np.ones((10,10)),'','',{'': ''}
|
138 |
|
139 |
class App:
|
140 |
def __init__(self):
|