Switch to Gemini 1.5 Flash
Browse files- .streamlit/config.toml +1 -1
- app.py +17 -11
- requirements.txt +4 -4
.streamlit/config.toml
CHANGED
@@ -6,7 +6,7 @@ textColor="#0A2C37"
|
|
6 |
font="sans serif"
|
7 |
|
8 |
[server]
|
9 |
-
maxUploadSize =
|
10 |
|
11 |
[browser]
|
12 |
gatherUsageStats = false
|
|
|
6 |
font="sans serif"
|
7 |
|
8 |
[server]
|
9 |
+
maxUploadSize = 1
|
10 |
|
11 |
[browser]
|
12 |
gatherUsageStats = false
|
app.py
CHANGED
@@ -30,10 +30,11 @@ IMAGE_PROMPT = (
|
|
30 |
)
|
31 |
|
32 |
GENERATION_CONFIG = {
|
33 |
-
"temperature": 0
|
34 |
-
"top_p":
|
35 |
-
"top_k":
|
36 |
"max_output_tokens": 2048,
|
|
|
37 |
}
|
38 |
SAFETY_SETTINGS = [
|
39 |
{
|
@@ -70,7 +71,7 @@ def get_gemini_model():
|
|
70 |
"""
|
71 |
|
72 |
return genai.GenerativeModel(
|
73 |
-
model_name='gemini-
|
74 |
generation_config=GENERATION_CONFIG,
|
75 |
safety_settings=SAFETY_SETTINGS
|
76 |
)
|
@@ -96,7 +97,9 @@ load_dotenv()
|
|
96 |
genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))
|
97 |
|
98 |
st.title('Sys2Doc')
|
99 |
-
st.header(
|
|
|
|
|
100 |
|
101 |
uploaded_file = st.file_uploader(
|
102 |
'Choose an image file (PNG, JPG, or JPEG) that depicts your system,'
|
@@ -109,11 +112,16 @@ img_url = st.text_input(
|
|
109 |
label='URL of the image',
|
110 |
value=random.choice(SAMPLE_IMAGE_URLS),
|
111 |
)
|
112 |
-
st.markdown(
|
|
|
|
|
|
|
113 |
|
114 |
if uploaded_file is not None or (img_url is not None and len(img_url) > 0):
|
115 |
# Show the uploaded image & related info
|
116 |
-
|
|
|
|
|
117 |
try:
|
118 |
if uploaded_file:
|
119 |
the_img = PIL.Image.open(uploaded_file)
|
@@ -130,15 +138,13 @@ if uploaded_file is not None or (img_url is not None and len(img_url) > 0):
|
|
130 |
# 'file_info': the_img.info
|
131 |
}
|
132 |
|
133 |
-
if the_img.mode in ('RGBA', 'P'):
|
134 |
the_img = the_img.convert('RGB')
|
135 |
|
136 |
st.header('Image')
|
137 |
|
138 |
-
|
139 |
st.write(file_details)
|
140 |
-
except Exception:
|
141 |
-
pass
|
142 |
|
143 |
st.image(the_img, width=250)
|
144 |
description = get_image_description(the_img)
|
|
|
30 |
)
|
31 |
|
32 |
GENERATION_CONFIG = {
|
33 |
+
"temperature": 0,
|
34 |
+
"top_p": 0.5,
|
35 |
+
"top_k": 10,
|
36 |
"max_output_tokens": 2048,
|
37 |
+
"response_mime_type": "text/plain",
|
38 |
}
|
39 |
SAFETY_SETTINGS = [
|
40 |
{
|
|
|
71 |
"""
|
72 |
|
73 |
return genai.GenerativeModel(
|
74 |
+
model_name='gemini-1.5-flash',
|
75 |
generation_config=GENERATION_CONFIG,
|
76 |
safety_settings=SAFETY_SETTINGS
|
77 |
)
|
|
|
97 |
genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))
|
98 |
|
99 |
st.title('Sys2Doc')
|
100 |
+
st.header(
|
101 |
+
'Generate Documentation Based on System Diagram—powered by Gemini 1.5 Flash'
|
102 |
+
)
|
103 |
|
104 |
uploaded_file = st.file_uploader(
|
105 |
'Choose an image file (PNG, JPG, or JPEG) that depicts your system,'
|
|
|
112 |
label='URL of the image',
|
113 |
value=random.choice(SAMPLE_IMAGE_URLS),
|
114 |
)
|
115 |
+
st.markdown(
|
116 |
+
'(*If an image is uploaded and a URL is also provided,'
|
117 |
+
' Sys2Doc will consider the uploaded image*)'
|
118 |
+
)
|
119 |
|
120 |
if uploaded_file is not None or (img_url is not None and len(img_url) > 0):
|
121 |
# Show the uploaded image & related info
|
122 |
+
the_img = None
|
123 |
+
file_details = None
|
124 |
+
|
125 |
try:
|
126 |
if uploaded_file:
|
127 |
the_img = PIL.Image.open(uploaded_file)
|
|
|
138 |
# 'file_info': the_img.info
|
139 |
}
|
140 |
|
141 |
+
if the_img and the_img.mode in ('RGBA', 'P'):
|
142 |
the_img = the_img.convert('RGB')
|
143 |
|
144 |
st.header('Image')
|
145 |
|
146 |
+
if file_details:
|
147 |
st.write(file_details)
|
|
|
|
|
148 |
|
149 |
st.image(the_img, width=250)
|
150 |
description = get_image_description(the_img)
|
requirements.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
google-generativeai
|
2 |
python-dotenv~=1.0.0
|
3 |
-
Pillow~=10.
|
4 |
-
streamlit
|
5 |
-
requests~=2.
|
|
|
1 |
+
google-generativeai==0.8.1
|
2 |
python-dotenv~=1.0.0
|
3 |
+
Pillow~=10.4.0
|
4 |
+
streamlit==1.38.0
|
5 |
+
requests~=2.32.3
|