Mushfi commited on
Commit
613b720
·
1 Parent(s): 126b8a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -12,15 +12,18 @@ LABELS = ['NORMAL', 'TUBERCULOSIS', 'PNEUMONIA', 'COVID19']
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:
18
- pass
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
  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():