Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from keras.models import load_model
|
| 3 |
+
import cv2
|
| 4 |
+
import numpy as np
|
| 5 |
+
model = load_model('covid_trained_model.h5')
|
| 6 |
+
def sigmoid_to_binary(output_value, threshold=0.705):
|
| 7 |
+
if output_value >= threshold:
|
| 8 |
+
return 1
|
| 9 |
+
else:
|
| 10 |
+
return 0
|
| 11 |
+
def covid(img):
|
| 12 |
+
resized_image = cv2.resize(img, (224, 224))
|
| 13 |
+
reshaped_image = np.expand_dims(resized_image, axis=0)
|
| 14 |
+
pred = model.predict(reshaped_image)
|
| 15 |
+
binary = sigmoid_to_binary(pred[0,0])
|
| 16 |
+
if(binary == 0):
|
| 17 |
+
return "COVID POSITIVE +"
|
| 18 |
+
return "COVID NEGATIVE -"
|
| 19 |
+
gr.Interface(fn=covid,inputs="image",outputs="text",title="Covid19 Detector by CHEST X-Ray",description="Please upload your CHEST X-RAY in below input field").launch()
|