File size: 1,013 Bytes
c4561d9
 
 
 
 
 
 
 
a99b223
e48228e
a99b223
 
 
 
c4561d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a99b223
c4561d9
 
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
import streamlit as st
import os
from PIL import Image

import google.generativeai as genai
secret_key = os.getenv("SECRET_KEY")
genai.configure(api_key=secret_key)

def get_gemini_response(image):
    model = genai.GenerativeModel('gemini-1.5-flash')
    input='''You are a prompt generator.You will get an image.
    Your work is to write a prompt such that an image generator model would create most identical picture
    as the image given to you'''
    response = model.generate_content([input,image])  
    return response.text

st.set_page_config(page_title="Prompt generation from image")
st.header("Application")

uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])

image=""  

if uploaded_file is not None:
    image = Image.open(uploaded_file)
    st.image(image, caption="Uploaded Image.", use_column_width=True)

submit=st.button("Generate Prompt")

if submit:
    response=get_gemini_response(image)
    st.subheader("The Generated Prompt is")
    st.write(response)