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