Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,6 +20,7 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
| 20 |
|
| 21 |
class_mapping = {'tb': 0, 'healthy': 1, 'sick_but_no_tb': 2}
|
| 22 |
reverse_mapping = {v: k for k, v in class_mapping.items()}
|
|
|
|
| 23 |
|
| 24 |
def load_model():
|
| 25 |
# config = read_params(config_path)
|
|
@@ -99,9 +100,9 @@ def predict(inp):
|
|
| 99 |
inp = transforms.ToTensor()(inp).unsqueeze(0)
|
| 100 |
with torch.no_grad():
|
| 101 |
prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)
|
| 102 |
-
|
| 103 |
-
prediction = reverse_mapping[prediction]
|
| 104 |
-
return
|
| 105 |
|
| 106 |
|
| 107 |
import gradio as gr
|
|
|
|
| 20 |
|
| 21 |
class_mapping = {'tb': 0, 'healthy': 1, 'sick_but_no_tb': 2}
|
| 22 |
reverse_mapping = {v: k for k, v in class_mapping.items()}
|
| 23 |
+
labels = class_mapping.keys()
|
| 24 |
|
| 25 |
def load_model():
|
| 26 |
# config = read_params(config_path)
|
|
|
|
| 100 |
inp = transforms.ToTensor()(inp).unsqueeze(0)
|
| 101 |
with torch.no_grad():
|
| 102 |
prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)
|
| 103 |
+
confidences = {labels[i]: float(prediction[i]) for i in range(3)}
|
| 104 |
+
# prediction = reverse_mapping[prediction]
|
| 105 |
+
return confidences
|
| 106 |
|
| 107 |
|
| 108 |
import gradio as gr
|