Spaces:
Sleeping

eyeris / app.py
prashantscripts's picture
Update app.py
7e53720 verified
Raw History Blame Contribute Delete
1.13 kB
import os
import gradio as gr
from huggingface_hub import InferenceClient
# Use a Classic Read Token for best API compatibility
client = InferenceClient(
model="google/medgemma-4b-it",
token=os.environ.get("HF_TOKEN")
)
def diagnose(img):
if img is None: return "Please upload an image."
try:
# Multimodal VQA call
response = client.visual_question_answering(
image=img,
question="Identify the eye disease and list solutions."
)
if isinstance(response, list): return response[0]['answer']
return str(response)
except Exception as e:
return f"Error: {str(e)}"
with gr.Blocks() as demo:
gr.Markdown("# Eye Disease Detector")
input_img = gr.Image(type="pil")
output_text = gr.Textbox()
btn = gr.Button("Diagnose")
btn.click(diagnose, input_img, output_text)
if __name__ == "__main__":
# ssr_mode=False fixes 'Method not implemented'
# show_error=True helps you see errors in the UI box instead of just the console
demo.launch(server_name="0.0.0.0", server_port=7860, ssr_mode=False, show_error=True)