Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,8 @@ model = models.densenet121(pretrained=True)
|
|
10 |
|
11 |
# Modify the classifier layer to output probabilities for 14 classes (pathologies)
|
12 |
num_classes = 14
|
13 |
-
model.
|
14 |
-
nn.Linear(model.
|
15 |
nn.Sigmoid(), # Use Sigmoid for multi-label classification
|
16 |
)
|
17 |
|
@@ -49,7 +49,7 @@ def predict_disease(image):
|
|
49 |
# Gradio Interface
|
50 |
interface = gr.Interface(
|
51 |
fn=predict_disease,
|
52 |
-
inputs=gr.
|
53 |
outputs="label", # Output is a dictionary of labels with probabilities
|
54 |
title="CheXNet Pneumonia Detection",
|
55 |
description="Upload a chest X-ray to detect the probability of 14 different diseases.",
|
@@ -57,4 +57,4 @@ interface = gr.Interface(
|
|
57 |
|
58 |
# Launch the Gradio app
|
59 |
if __name__ == "__main__":
|
60 |
-
interface.launch()
|
|
|
10 |
|
11 |
# Modify the classifier layer to output probabilities for 14 classes (pathologies)
|
12 |
num_classes = 14
|
13 |
+
model.classifier = nn.Sequential(
|
14 |
+
nn.Linear(model.classifier.in_features, num_classes),
|
15 |
nn.Sigmoid(), # Use Sigmoid for multi-label classification
|
16 |
)
|
17 |
|
|
|
49 |
# Gradio Interface
|
50 |
interface = gr.Interface(
|
51 |
fn=predict_disease,
|
52 |
+
inputs=gr.components.Image(type='pil'), # Updated input component
|
53 |
outputs="label", # Output is a dictionary of labels with probabilities
|
54 |
title="CheXNet Pneumonia Detection",
|
55 |
description="Upload a chest X-ray to detect the probability of 14 different diseases.",
|
|
|
57 |
|
58 |
# Launch the Gradio app
|
59 |
if __name__ == "__main__":
|
60 |
+
interface.launch()
|