medImg_Analyzer / app.py
funnyPhani's picture
Update app.py
077e2dc verified
raw history blame
No virus
1.36 kB
import google.generativeai as genai
import gradio as gr
# import PIL.Image
def medicalImageAnalyzer(image,prompt):
# img = PIL.Image.open(image.name)
model = genai.GenerativeModel('gemini-1.0-pro-vision-latest')
response = model.generate_content(["As a medical analyzer, your task is to thoroughly examine the image and provide a comprehensive analysis. Here's a refined version of your prompt: You are a medical analyst tasked with analyzing the provided image. Your goal is to provide a detailed analysis based on the input image and describe both the dos and don'ts associated with it. Please proceed with your analysis. This prompt conveys a clear and concise instruction for the medical analyzer, outlining their role and the objective of the analysis. It prompts them to provide both detailed insights into the image and practical recommendations based on their findings.", prompt,image], stream=True)
response.resolve()
return response.text
# Define the Gradio interface
iface = gr.Interface(
fn=medicalImageAnalyzer,
inputs=[gr.inputs.Image(type="pil", label="Upload a medical image"),
gr.inputs.Textbox(label="Enter a prompt")],
outputs="text",
title="Medical Image Analyzer",
description="Upload a medical image for analysis."
)
# Launch the interface
iface.launch(debug=False,inline = False)