-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
89 lines (61 loc) · 2.75 KB
/
app.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import streamlit as st
from pathlib import Path
import google.generativeai as genai
from api_key import api_key
#configure genai with key
genai.configure(api_key=api_key)
generation_config = {
"temperature": 1,
"top_p": 0.95,
"top_k": 64,
"max_output_tokens": 8192,
"response_mime_type": "text/plain",
}
system_prompt="""
As a highly skilled medical pratitioner specializing in image analysis,you are tasked with examining medicsl images for a renowned hospital.Your expertise is crucial in identifying any anomalies,diseases,or issues that may be present in the images.
Your Responsibilities include:
1.Detailed Analysis: Thoroughly analyze each image, focusing on identifying any abnormal features.
2.Findings Report: Document all observed anomalies or signs of disease. Clearly articulate your findings.
3.Recommendations and Next Steps: Based on your analysis, suggest potential next steps, including further testing or consultations.
4.Treatment Suggestions: If appropriate, recommend possible treatment options or interventions.
Important Notes:
1.Scope of Response: Only respond if the image pertains to human health issues.
2.Clarity of Image: In cases where the image quality impedes clear analysis, note that certain details may be inconclusive.
3.Disclaimer: Accompany your analysis with the disclaimer: "Consult with a Doctor before making any decisions.
4.Your insights are invaluable in guiding clinical decisions. Please proceed with the analysis carefully."
Please provide me an output response with these 4 headings
"""
model = genai.GenerativeModel(
model_name="gemini-1.5-pro",
generation_config=generation_config,
# safety_settings = Adjust safety settings
# See https://ai.google.dev/gemini-api/docs/safety-settings
)
st.set_page_config(page_title="MedInsight",page_icon=":robot:")
st.image("logo.jpg",width=120)
st.title("MedInsights")
st.subheader("An Application That Can Help To Analyze Medical Images!")
uploaded_file=st.file_uploader("Upload The Image For Analysis",type=["png","jpg","jpeg"])
if uploaded_file:
st.image(uploaded_file,width=300,caption="Uploaded Image")
submit_button=st.button("Generate The Analysis")
if submit_button:
#process the uploaded image
image_data=uploaded_file.getvalue()
image_parts=[
{
"mime_type":"image/jpeg",
"data":image_data
},
]
#making prompt ready
prompt_parts=[
image_parts[0],
system_prompt,
]
st.image(image_data,width=250)
st.title("Here Is The Analysis Based On Your Image:")
#generate response
response=model.generate_content(prompt_parts)
print(response.text)
st.write(response.text)