Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ LABELS = ['NORMAL', 'TUBERCULOSIS', 'PNEUMONIA', 'COVID19']
|
|
| 10 |
|
| 11 |
def predict_input_image(img):
|
| 12 |
try:
|
| 13 |
-
img = Image.open(BytesIO(base64.b64decode(img)))
|
| 14 |
img = np.array(img)
|
| 15 |
except:
|
| 16 |
pass
|
|
@@ -20,9 +20,6 @@ def predict_input_image(img):
|
|
| 20 |
prediction=model.predict(img_4d)[0]
|
| 21 |
return {LABELS[i]: float(prediction[i]) for i in range(4)}
|
| 22 |
|
| 23 |
-
def k():
|
| 24 |
-
return gr.update(value=None)
|
| 25 |
-
|
| 26 |
with gr.Blocks(title="Chest X-Ray Disease Classification", css="") as demo:
|
| 27 |
with gr.Row():
|
| 28 |
textmd = gr.Markdown('''
|
|
@@ -33,11 +30,9 @@ with gr.Blocks(title="Chest X-Ray Disease Classification", css="") as demo:
|
|
| 33 |
with gr.Column(scale=1, min_width=600):
|
| 34 |
image = gr.inputs.Image(shape=(128,128))
|
| 35 |
with gr.Row():
|
| 36 |
-
clear_btn = gr.Button("Clear")
|
| 37 |
submit_btn = gr.Button("Submit", elem_id="warningk", variant='primary')
|
| 38 |
label = gr.outputs.Label(num_top_classes=4)
|
| 39 |
|
| 40 |
-
clear_btn.click(k, inputs=[], outputs=image)
|
| 41 |
submit_btn.click(predict_input_image, inputs=image, outputs=label, api_name="prediction_place")
|
| 42 |
|
| 43 |
demo.launch()
|
|
|
|
| 10 |
|
| 11 |
def predict_input_image(img):
|
| 12 |
try:
|
| 13 |
+
img = Image.open(BytesIO(base64.b64decode(img))).convert('RGB').resize((128,128))
|
| 14 |
img = np.array(img)
|
| 15 |
except:
|
| 16 |
pass
|
|
|
|
| 20 |
prediction=model.predict(img_4d)[0]
|
| 21 |
return {LABELS[i]: float(prediction[i]) for i in range(4)}
|
| 22 |
|
|
|
|
|
|
|
|
|
|
| 23 |
with gr.Blocks(title="Chest X-Ray Disease Classification", css="") as demo:
|
| 24 |
with gr.Row():
|
| 25 |
textmd = gr.Markdown('''
|
|
|
|
| 30 |
with gr.Column(scale=1, min_width=600):
|
| 31 |
image = gr.inputs.Image(shape=(128,128))
|
| 32 |
with gr.Row():
|
|
|
|
| 33 |
submit_btn = gr.Button("Submit", elem_id="warningk", variant='primary')
|
| 34 |
label = gr.outputs.Label(num_top_classes=4)
|
| 35 |
|
|
|
|
| 36 |
submit_btn.click(predict_input_image, inputs=image, outputs=label, api_name="prediction_place")
|
| 37 |
|
| 38 |
demo.launch()
|