Update app.py
Browse files
app.py
CHANGED
|
@@ -12,15 +12,18 @@ LABELS = ['NORMAL', 'TUBERCULOSIS', 'PNEUMONIA', 'COVID19']
|
|
| 12 |
|
| 13 |
def predict_input_image(img):
|
| 14 |
try:
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
with gr.Blocks(title="Chest X-Ray Disease Classification", css="") as demo:
|
| 26 |
with gr.Row():
|
|
|
|
| 12 |
|
| 13 |
def predict_input_image(img):
|
| 14 |
try:
|
| 15 |
+
try:
|
| 16 |
+
img = Image.open(BytesIO(base64.b64decode(img))).convert('RGB').resize((128,128))
|
| 17 |
+
img = np.array(img)
|
| 18 |
+
except:
|
| 19 |
+
pass
|
| 20 |
+
img_4d=img.reshape(-1,128,128,3)/img.max()
|
| 21 |
+
print(img_4d.min())
|
| 22 |
+
print(img_4d.max())
|
| 23 |
+
prediction=model.predict(img_4d)[0]
|
| 24 |
+
return {LABELS[i]: float(prediction[i]) for i in range(4)}
|
| 25 |
+
except Exception as e:
|
| 26 |
+
return {"error": str(e)}
|
| 27 |
|
| 28 |
with gr.Blocks(title="Chest X-Ray Disease Classification", css="") as demo:
|
| 29 |
with gr.Row():
|