funnyPhani commited on
Commit
cdc68b4
1 Parent(s): 680af40

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import google.generativeai as genai
2
+ import gradio as gr
3
+ import PIL.Image
4
+
5
+ def medicalImageAnalyzer(image,prompt):
6
+ # img = PIL.Image.open(image.name)
7
+ model = genai.GenerativeModel('gemini-1.0-pro-vision-latest')
8
+ 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)
9
+ response.resolve()
10
+ return response.text
11
+
12
+ # Define the Gradio interface
13
+ iface = gr.Interface(
14
+ fn=medicalImageAnalyzer,
15
+ inputs=[gr.inputs.Image(type="pil", label="Upload a medical image"),
16
+ gr.inputs.Textbox(label="Enter a prompt")],
17
+ outputs="text",
18
+ title="Medical Image Analyzer",
19
+ description="Upload a medical image for analysis."
20
+ )
21
+
22
+ # Launch the interface
23
+ iface.launch(debug=False)
24
+