Spaces:
Sleeping
Sleeping
File size: 1,125 Bytes
6a37d76 4305ded 6ea53f2 6a37d76 7e53720 6ea53f2 6a37d76 7e53720 6ea53f2 7e53720 835a81b 7e53720 835a81b 7e53720 e0215b7 6ea53f2 7e53720 9ee775a 7e53720 e0215b7 7e53720 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 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) |