toheedbs commited on
Commit
e5ba95b
·
verified ·
1 Parent(s): 23557e9
Files changed (1) hide show
  1. model.py +0 -54
model.py DELETED
@@ -1,54 +0,0 @@
1
- import streamlit as st
2
- import os
3
- from PIL import Image
4
- import google.generativeai as genai
5
-
6
- # Define your Google API key directly
7
- api_key = "AIzaSyCLrzCk1tr_GFV3Jjt7HYxcYKoNpYbjl6w"
8
- genai.configure(api_key=api_key)
9
-
10
- ## Let's create a function to load Gemini Pro Vision
11
- model = genai.GenerativeModel('gemini-1.5-flash')
12
-
13
- def get_gemini_response(input, image, prompt):
14
- response = model.generate_content([input, image[0], prompt])
15
- return response.text
16
-
17
- def input_image_details(uploaded_file):
18
- if uploaded_file is not None:
19
- # Read the file into bytes
20
- bytes_data = uploaded_file.getvalue()
21
-
22
- image_parts = [
23
- {
24
- "mime_type": uploaded_file.type,
25
- "data": bytes_data
26
- }
27
- ]
28
- return image_parts
29
- else:
30
- raise FileNotFoundError("No File Uploaded")
31
-
32
- ## Initialize User Interface by using streamlit
33
- st.set_page_config(page_title="Multilanguage Image Insights Generator")
34
- st.header("Nu-pie Image Insights Generator Application")
35
- input = st.text_input("Input Prompt: ", key="input")
36
- uploaded_file = st.file_uploader("Choose an Image...", type=["jpg", "jpeg", "png"])
37
- image = ""
38
- if uploaded_file is not None:
39
- image = Image.open(uploaded_file)
40
- st.image(image, caption="Uploaded Image.", use_column_width=True)
41
-
42
- submit = st.button("Give insights on the Image")
43
-
44
- input_prompt = """
45
- You are an expert in understanding and providing Insights on Dashboard Images in detail.
46
- We will upload an image of a PowerBi Dashboard and you will have to answer any questions related to that uploaded image.
47
- """
48
-
49
- # If submit button is clicked
50
- if submit:
51
- image_data = input_image_details(uploaded_file)
52
- response = get_gemini_response(input_prompt, image_data, input)
53
- st.subheader("The Response is")
54
- st.write(response)