Spaces:
Runtime error
Runtime error
LovnishVerma
commited on
Commit
•
c496c70
1
Parent(s):
d726cc3
Update app.py
Browse files
app.py
CHANGED
@@ -71,12 +71,9 @@ def predict_braintumor(img_input):
|
|
71 |
pred = braintumor_model.predict(img_processed)
|
72 |
|
73 |
# Handle binary decision
|
74 |
-
|
75 |
|
76 |
-
|
77 |
-
return "Brain Tumor Not Found!"
|
78 |
-
else:
|
79 |
-
return "Brain Tumor Found!"
|
80 |
|
81 |
def main():
|
82 |
st.title("Brain Tumor Prediction App")
|
@@ -107,9 +104,12 @@ def main():
|
|
107 |
# Make prediction for Gradio (direct input of image)
|
108 |
result = predict_braintumor(uploaded_img)
|
109 |
|
|
|
|
|
|
|
110 |
# Display prediction
|
111 |
st.subheader("Prediction:")
|
112 |
-
st.success(
|
113 |
|
114 |
if __name__ == "__main__":
|
115 |
# Streamlit part
|
@@ -117,5 +117,11 @@ if __name__ == "__main__":
|
|
117 |
main()
|
118 |
|
119 |
# Gradio part
|
120 |
-
iface = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
iface.launch()
|
|
|
71 |
pred = braintumor_model.predict(img_processed)
|
72 |
|
73 |
# Handle binary decision
|
74 |
+
pred = 1 if pred[0] >= 0.5 else 0
|
75 |
|
76 |
+
return pred
|
|
|
|
|
|
|
77 |
|
78 |
def main():
|
79 |
st.title("Brain Tumor Prediction App")
|
|
|
104 |
# Make prediction for Gradio (direct input of image)
|
105 |
result = predict_braintumor(uploaded_img)
|
106 |
|
107 |
+
# Handle binary decision
|
108 |
+
result_text = "Brain Tumor Found!" if result == 1 else "Brain Tumor Not Found!"
|
109 |
+
|
110 |
# Display prediction
|
111 |
st.subheader("Prediction:")
|
112 |
+
st.success(result_text)
|
113 |
|
114 |
if __name__ == "__main__":
|
115 |
# Streamlit part
|
|
|
117 |
main()
|
118 |
|
119 |
# Gradio part
|
120 |
+
iface = gr.Interface(
|
121 |
+
fn=predict_braintumor,
|
122 |
+
inputs="image",
|
123 |
+
outputs="text",
|
124 |
+
examples=[["examples/1 no.jpg"]],
|
125 |
+
enable_queue=True
|
126 |
+
)
|
127 |
iface.launch()
|