Spaces:
Sleeping
Sleeping
updated app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ torch_model.fc = nn.Sequential(
|
|
17 |
tf_model = tf.keras.models.load_model('./models/tensorflow_model.keras')
|
18 |
torch_model.load_state_dict(torch.load('./models/pytorch_model.pth', weights_only=True, map_location='cpu'))
|
19 |
torch_model.eval()
|
20 |
-
|
21 |
selected_model = st.selectbox(
|
22 |
label = 'Select the model to make a prediction',
|
23 |
options = ['TensorFlow', 'PyTorch'],
|
@@ -34,9 +34,6 @@ if uploaded_file is not None:
|
|
34 |
# Convert to PIL Image
|
35 |
image = Image.open(uploaded_file).convert("RGB")
|
36 |
|
37 |
-
# Display Uploaded Image
|
38 |
-
st.image(image, caption="Uploaded X-ray", use_container_width=True)
|
39 |
-
|
40 |
image_size = 256 # Match model input size
|
41 |
if selected_model == "PyTorch":
|
42 |
# PyTorch Preprocessing
|
@@ -62,5 +59,10 @@ if uploaded_file is not None:
|
|
62 |
prediction = tf_model.predict(image_array)[0][0] # Extract single value
|
63 |
|
64 |
# Display Prediction
|
65 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
66 |
|
|
|
17 |
tf_model = tf.keras.models.load_model('./models/tensorflow_model.keras')
|
18 |
torch_model.load_state_dict(torch.load('./models/pytorch_model.pth', weights_only=True, map_location='cpu'))
|
19 |
torch_model.eval()
|
20 |
+
st.title("Pneumonia detection using CNNs")
|
21 |
selected_model = st.selectbox(
|
22 |
label = 'Select the model to make a prediction',
|
23 |
options = ['TensorFlow', 'PyTorch'],
|
|
|
34 |
# Convert to PIL Image
|
35 |
image = Image.open(uploaded_file).convert("RGB")
|
36 |
|
|
|
|
|
|
|
37 |
image_size = 256 # Match model input size
|
38 |
if selected_model == "PyTorch":
|
39 |
# PyTorch Preprocessing
|
|
|
59 |
prediction = tf_model.predict(image_array)[0][0] # Extract single value
|
60 |
|
61 |
# Display Prediction
|
62 |
+
st.header(
|
63 |
+
f"**According to the model, there is a {prediction*100:.2f}% chance of having pneumonia!**",
|
64 |
+
divider='blue'
|
65 |
+
)
|
66 |
+
# Display Uploaded Image
|
67 |
+
st.image(image, caption="Uploaded X-ray", use_container_width=True)
|
68 |
|