LEWOPO commited on
Commit
d10dda6
1 Parent(s): 3e7db90

Upload 3 files

Browse files
Files changed (3) hide show
  1. .env +1 -0
  2. app.py +46 -0
  3. requirements.txt +4 -0
.env ADDED
@@ -0,0 +1 @@
 
 
1
+ GOOGLE_API_KEY="AIzaSyAPdHwt5d5HyENSPNCq0vdms45i5DgUJ6E"
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dotenv import load_dotenv
2
+ load_dotenv()
3
+
4
+ import streamlit as st
5
+ import os
6
+ import google.generativeai as genai
7
+ from PIL import Image
8
+ genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))
9
+
10
+
11
+ def get_gemini_response(input_prompt,image):
12
+ model=genai.GenerativeModel('gemini-pro-vision')
13
+ response = model.generate_content([input_prompt,image[0]])
14
+ return response.text
15
+ def input_image_setup(uploaded_file):
16
+ if uploaded_file is not None:
17
+ bytes_data = uploaded_file.getvalue()
18
+ image_parts = [{'mime_type':uploaded_file.type,
19
+ 'data':bytes_data}]
20
+ return image_parts
21
+ else:
22
+ raise FileNotFoundError('No File Uploaded')
23
+ st.set_page_config(page_title = 'Gemini health App')
24
+ st.header('POWO_KAMDEM-Estimation food')
25
+ uploaded_file = st.file_uploader('Choose an image.',type=['jpg','jpeg','png'])
26
+ if uploaded_file is not None:
27
+ image=Image.open(uploaded_file)
28
+ st.image(image,caption="uploaded_file",use_column_width=True)
29
+ submit=st.button('donne moi le nombre de calories')
30
+ input_prompt="""
31
+ You are an expert in nutritionist where you need to see the food items from the image
32
+ and calculate the total calories, also provide the details of every food items with calories intake
33
+ is below format
34
+
35
+ 1. Item 1 - no of calories
36
+ 2. Item 2 - no of calories
37
+ ----
38
+ ----
39
+ Finally you can also mention whether the food is healthy or not and also mention the percentage split of the ratio of carbohydrates,fats,fibers,sugar,and other important things required in your diet,and mention if the food needs to go to trash or not
40
+
41
+ """
42
+ if submit:
43
+ image_data = input_image_setup(uploaded_file)
44
+ response = get_gemini_response(input_prompt,image_data)
45
+ st.subheader('The response is')
46
+ st.write(response)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Pillow==10.2.0
2
+ protobuf==4.25.3
3
+ python-dotenv==1.0.1
4
+ streamlit==1.32.0