Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,18 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
|
|
|
| 3 |
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import hf_hub_download
|
| 3 |
+
import torch
|
| 4 |
|
| 5 |
+
# Download model from Hub
|
| 6 |
+
model_path = hf_hub_download(repo_id="ARAMIS-LAB/CNN-AD-CN", filename="model.pth.tar")
|
| 7 |
|
| 8 |
+
# Load ClinicaDL model
|
| 9 |
+
model = torch.load(model_path, map_location="cpu")
|
| 10 |
+
model.eval()
|
| 11 |
|
| 12 |
+
def predict(input_image):
|
| 13 |
+
with torch.no_grad():
|
| 14 |
+
output = model(input_image.unsqueeze(0))
|
| 15 |
+
return output.numpy().tolist()
|
| 16 |
+
|
| 17 |
+
demo = gr.Interface(fn=predict, inputs="image", outputs="label")
|
| 18 |
+
demo.launch()
|