Update app.py
Browse files11 unmodified lines12131415161718192021222324252611 unmodified linesdef predict_input_image(img):try:img = Image.open(BytesIO(base64.b64decode(img))).convert('RGB').resize((128,128))img = np.array(img)except:passimg_4d=img.reshape(-1,128,128,3)/img.max()print(img_4d.min())print(img_4d.max())prediction=model.predict(img_4d)[0]return {LABELS[i]: float(prediction[i]) for i in range(4)}with gr.Blocks(title="Chest X-Ray Disease Classification", css="") as demo:with gr.Row():11 unmodified lines12131415161718192021222324252627282911 unmodified linesdef predict_input_image(img):try:try:img = Image.open(BytesIO(base64.b64decode(img))).convert('RGB').resize((128,128))img = np.array(img)except:passimg_4d=img.reshape(-1,128,128,3)/img.max()print(img_4d.min())print(img_4d.max())prediction=model.predict(img_4d)[0]return {LABELS[i]: float(prediction[i]) for i in range(4)}except Exception as e:return {"error": str(e)}with gr.Blocks(title="Chest X-Ray Disease Classification", css="") as demo:with gr.Row():
app.py+12-9