shikharyashmaurya commited on
Commit
a99b223
1 Parent(s): 0a20eb1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -14
app.py CHANGED
@@ -6,25 +6,17 @@ import google.generativeai as genai
6
  secret_key = os.getenv("SECRET_KEY")
7
  genai.configure(api_key=secret_key)
8
 
9
- def get_gemini_response(input,image):
10
  model = genai.GenerativeModel('gemini-pro-vision')
11
- if input!="":
12
- input='''You are a prompt generator.You will get an image.
13
- Your work is to write a prompt such that an image generator model would create most identical picture
14
- as the image given to you'''
15
- response = model.generate_content([input,image])
16
- else:
17
- new_input=''
18
- new_input='''You are a prompt generator.You will get an image.
19
- Your work is to write a prompt such that an image generator model would create most identical picture
20
- as the image given to you and the extra feature provide that you mant in image are as follows '''+input
21
- response = model.generate_content([new_input,image])
22
  return response.text
23
 
24
  st.set_page_config(page_title="Prompt generation from image")
25
  st.header("Application")
26
 
27
- input=st.text_input("Any special change in image you want to specify: ",key="input")
28
  uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
29
 
30
  image=""
@@ -36,6 +28,6 @@ if uploaded_file is not None:
36
  submit=st.button("Generate Prompt")
37
 
38
  if submit:
39
- response=get_gemini_response(input,image)
40
  st.subheader("The Generated Prompt is")
41
  st.write(response)
 
6
  secret_key = os.getenv("SECRET_KEY")
7
  genai.configure(api_key=secret_key)
8
 
9
+ def get_gemini_response(image):
10
  model = genai.GenerativeModel('gemini-pro-vision')
11
+ input='''You are a prompt generator.You will get an image.
12
+ Your work is to write a prompt such that an image generator model would create most identical picture
13
+ as the image given to you'''
14
+ response = model.generate_content([input,image])
 
 
 
 
 
 
 
15
  return response.text
16
 
17
  st.set_page_config(page_title="Prompt generation from image")
18
  st.header("Application")
19
 
 
20
  uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
21
 
22
  image=""
 
28
  submit=st.button("Generate Prompt")
29
 
30
  if submit:
31
+ response=get_gemini_response(image)
32
  st.subheader("The Generated Prompt is")
33
  st.write(response)