ManasviD commited on
Commit
ac3f10d
·
verified ·
1 Parent(s): cfafec9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -8
app.py CHANGED
@@ -2,14 +2,15 @@ import streamlit as st
2
  import os
3
  import google.generativeai as genai
4
  from PIL import Image
 
5
 
6
-
7
-
8
  ## Function to load Google Gemini Pro Vision API And get response
9
 
10
- def get_gemini_repsonse(input,image,prompt):
11
  model=genai.GenerativeModel('gemini-1.5-flash')
12
- response=model.generate_content([input,image[0],prompt])
13
  return response.text
14
 
15
  def input_image_setup(uploaded_file):
@@ -33,7 +34,7 @@ def input_image_setup(uploaded_file):
33
  st.set_page_config(page_title="Biodiversity Detection App")
34
 
35
  st.header("Biodiversity")
36
- input=st.text_input("Input Prompt: ",key="input")
37
  uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
38
  image=""
39
  if uploaded_file is not None:
@@ -44,20 +45,42 @@ if uploaded_file is not None:
44
  submit=st.button("Find the Species")
45
 
46
  input_prompt="""
47
- you are an expert taxonomist where you need to see the image and return detailed info about the species including its Name,common name,Kingdom,phylum and class,family ,genus,native country .
48
- Also generate a short informatie ,engaging 150 words story like national geographic story about that species,it's life and history with other images of same species (in both text and audio format).
49
  the image you can answer is of only living organisms like animals,plants etc.
50
  Do not return results for non-living objects.
51
  If image does not contain living organism or something which you do not know respond with invalid input.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
 
53
 
 
54
  """
55
 
56
  ## If submit button is clicked
57
 
58
  if submit:
59
  image_data=input_image_setup(uploaded_file)
60
- response=get_gemini_repsonse(input_prompt,image_data,input)
61
 
62
  st.write(response)
63
 
 
2
  import os
3
  import google.generativeai as genai
4
  from PIL import Image
5
+ from dotenv import load_dotenv
6
 
7
+ load_dotenv()
8
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
9
  ## Function to load Google Gemini Pro Vision API And get response
10
 
11
+ def get_gemini_repsonse(input_prompt,image):
12
  model=genai.GenerativeModel('gemini-1.5-flash')
13
+ response=model.generate_content([input_prompt,image[0]])
14
  return response.text
15
 
16
  def input_image_setup(uploaded_file):
 
34
  st.set_page_config(page_title="Biodiversity Detection App")
35
 
36
  st.header("Biodiversity")
37
+ #input=st.text_input("Input Prompt: ",key="input")
38
  uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
39
  image=""
40
  if uploaded_file is not None:
 
45
  submit=st.button("Find the Species")
46
 
47
  input_prompt="""
48
+ you are an expert taxonomist where you need to see the image and return detailed info about the species including its Name, common name, Kingdom, phylum and class,family ,genus,native country in proper order one below the other example name : Below that common name and so on also add an interesting fact about that species at end .
49
+ generate a short informative ,engaging 150 words story like national geographic story about that species,it's life and history don't write national geographic story just diretly write the story.
50
  the image you can answer is of only living organisms like animals,plants etc.
51
  Do not return results for non-living objects.
52
  If image does not contain living organism or something which you do not know respond with invalid input.
53
+ I want answer in this format -
54
+
55
+
56
+ Name: Sciurus vulgaris
57
+
58
+ Common Name: Eurasian red squirrel
59
+
60
+ Kingdom: Animalia
61
+
62
+ Phylum: Chordata
63
+
64
+ Class: Mammalia
65
+
66
+ Family: Sciuridae
67
+
68
+ Genus: Sciurus
69
+
70
+ Native Country: Eurasia (widely distributed across Europe and parts of Asia)
71
+
72
+ Interseting fact:
73
 
74
+ write Story
75
 
76
+
77
  """
78
 
79
  ## If submit button is clicked
80
 
81
  if submit:
82
  image_data=input_image_setup(uploaded_file)
83
+ response=get_gemini_repsonse(input_prompt,image_data)
84
 
85
  st.write(response)
86