Mushfi commited on
Commit
513ce06
·
1 Parent(s): fc67aa1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
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[22:]))).convert('RGB').resize((128,128))
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
- return {"error": str(e)}
 
 
 
 
 
 
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():