Jaskirat-04 commited on
Commit
f293d45
1 Parent(s): 841da74

Upload 6 files

Browse files
Files changed (7) hide show
  1. .gitattributes +2 -0
  2. app.py +151 -0
  3. eg1.png +3 -0
  4. eg2.png +3 -0
  5. eg3.jpg +0 -0
  6. eg4.webp +0 -0
  7. gemini.jpg +0 -0
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ eg1.png filter=lfs diff=lfs merge=lfs -text
37
+ eg2.png filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import PIL.Image
2
+ import gradio as gr
3
+ import base64
4
+ import time
5
+ import os
6
+ import google.generativeai as genai
7
+
8
+ # Set Google API key
9
+ genai.configure(api_key = os.environ['GOOGLE_API_KEY'])
10
+
11
+ # Create the Model
12
+ txt_model = genai.GenerativeModel('gemini-pro')
13
+ vis_model = genai.GenerativeModel('gemini-pro-vision')
14
+
15
+ # Image to Base 64 Converter
16
+ def image_to_base64(image_path):
17
+ with open(image_path, 'rb') as img:
18
+ encoded_string = base64.b64encode(img.read())
19
+ return encoded_string.decode('utf-8')
20
+
21
+ # Function that takes User Inputs and displays it on ChatUI
22
+ def query_message(history,txt,img):
23
+ if not img:
24
+ history += [(txt,None)]
25
+ return history
26
+ base64 = image_to_base64(img)
27
+ data_url = f"data:image/jpeg;base64,{base64}"
28
+ history += [(f"{txt} ![]({data_url})", None)]
29
+ return history
30
+
31
+ # Function that takes User Inputs, generates Response and displays on Chat UI
32
+ def llm_response(history,text,img):
33
+ if not img:
34
+ response = txt_model.generate_content(text)
35
+ history += [(None,response.text)]
36
+ return history
37
+
38
+ else:
39
+ img = PIL.Image.open(img)
40
+ response = vis_model.generate_content([text,img])
41
+ history += [(None,response.text)]
42
+ return history
43
+
44
+ # Interface Code
45
+ with gr.Blocks() as app:
46
+ # heading = gr.title("Pet Diet Plan Generator", level=1) # Add a heading
47
+ # heading = gr.Markdown("# Pet Diet Plan Generator")
48
+
49
+ # Subheading
50
+ # subheading = gr.Markdown("### Answer the following questions to generate a personalized diet plan.")
51
+ gr.HTML(
52
+ """
53
+ <div style="text-align: center; max-width: 1600px; margin: 20px auto;">
54
+ <h2 style="font-weight: 900; font-size: 4rem; margin: 0rem">
55
+ GEMINI PRO CHATBOT
56
+ </h2>
57
+
58
+ <h2 style="text-align: center; justify-content: center; display:flex; align-items: center; font-weight: 850; font-size: 1.1rem; margin-top: 0.5rem; margin-bottom: 0.5rem">
59
+
60
+ Gemini Pro isn't just a language model; it's a creative powerhouse, a code-wielding wizard , and a tireless knowledge explorer, all rolled into one. It fuels your artistic expression, supercharges your productivity, and bridges the code gap. Dive into scientific mysteries with its help, or imagine AI-powered healthcare. This ever-evolving entity, with its cutting-edge edge, redefines our relationship with technology .
61
+ </h2><br><br>
62
+ <div>
63
+ <h1 > Welcome to the Gemini Pro revolution! 📈</h1>
64
+
65
+ <h5 style="margin: 0;">If you like our project, please give us a star on Github to stay updated with the latest developments.</h5><br>
66
+ <div style="display: flex; justify-content: center; align-items: center; text-align: center;>
67
+ <a href="https://github.com/HumanAIGC/OutfitAnyone"><img src="https://img.shields.io/badge/jaskirat-singh-red"></a>
68
+ <a href='https://github.com/Jaskirat-singh04/'><img src='https://img.shields.io/badge/Project-gemini%20pro-green' alt='Project Page'></a>
69
+ <a href='https://www.linkedin.com/in/jaskiratsingh04'><img src='https://img.shields.io/badge/Linked%20In-jaskirat%20-blue'></a>
70
+ </div><br>
71
+ </div>
72
+ <br><br>
73
+ <img src="https://images.tech.co/wp-content/uploads/2023/12/06145436/Google-Gemini-AI-708x400.jpg" alt="textdiffuser-2" style="width: 100%; height: 70%; object-fit: cover;">
74
+
75
+ </div><br><br>
76
+
77
+ <h2 style="font-weight: 900; display: flex; text-align: left; justify-content: center; font-size: 3rem; align-items:center; margin: 0rem">
78
+ CAPABILITIES
79
+ </h2><br>
80
+ <div style= "display:flex;">
81
+
82
+ <h2 style="text-align: left; justify-content: center; display:flex; font-weight: 850; font-size: 0.9rem; margin-top: 0.5rem; margin-bottom: 0.5rem; margin-right: 0.3rem; @media (max-width: 600px) {
83
+ font-size: 0.8rem;
84
+ }" >
85
+ <b></b> ✅Writes in any style, from poems to scripts, sparking your imagination and breaking writer's block.Analyzes data, uncovers patterns, and proposes hypotheses.<br>
86
+ </h2>
87
+ <h2 style="text-align: left; justify-content: center; display:flex; font-weight: 850; font-size: 0.9rem; margin-top: 0.5rem; margin-bottom: 0.5rem; margin-right: 0.3rem">
88
+ <b></b> ✅Translates languages, summarizes documents, and answers questions, freeing you to focus on the big picture.Seamlessly handles text, code, and even images.<br>
89
+ </h2>
90
+ <h2 style="text-align: left; justify-content: center; display:flex; font-weight: 850; font-size: 0.9rem; margin-top: 0.5rem; margin-bottom: 0.5rem; margin-right: 0.3rem">
91
+ <b></b>✅ Generates and translates code in different languages, speeding up development and democratizing coding.<br>
92
+ </h2>
93
+
94
+ </div> <br><br>
95
+
96
+ """)
97
+
98
+ # subheading = gr.Heading("Answer the following questions to generate a personalized diet plan.", level=3) # Add a subheading
99
+ with gr.Row():
100
+ image_box = gr.Image(type="filepath")
101
+
102
+ chatbot = gr.Chatbot(
103
+ scale = 2,
104
+ height=750
105
+ )
106
+ text_box = gr.Textbox(
107
+ placeholder="Enter text and press enter, or upload an image to start",
108
+ container=False,
109
+ )
110
+
111
+ btn = gr.Button("Submit")
112
+ clicked = btn.click(query_message,
113
+ [chatbot,text_box,image_box],
114
+ chatbot
115
+ ).then(llm_response,
116
+ [chatbot,text_box,image_box],
117
+ chatbot
118
+ )
119
+ gr.Markdown("## Prompt Examples")
120
+ gr.Examples(
121
+ [
122
+ ["Describe the painting in a poetic way.",'eg1.png'],
123
+ [" Craft a persuasive advertisement for this electric car that highlights its innovative features and eco-friendly benefits, using language that appeals to a tech-savvy audience..",'eg2.png'],
124
+ ["Count no. of people in this image.",'eg3.jpg'],
125
+ ["Tell me some fact about this dog breed.",'eg4.webp'],
126
+ ],
127
+ [
128
+ text_box,
129
+ image_box
130
+ ],
131
+ examples_per_page=25
132
+ )
133
+
134
+ gr.HTML(
135
+ """
136
+ <div style="text-align: justify; max-width: 1100px; margin: 20px auto;">
137
+ <h3 style="font-weight: 450; font-size: 0.8rem; margin: 0rem">
138
+ <b>Disclaimer</b>:
139
+ Please note that the demo is intended for academic and research purposes <b>ONLY</b>. Any use of the demo for generating inappropriate content is strictly prohibited. The responsibility for any misuse or inappropriate use of the demo lies solely with the users who generated such content, and this demo shall not be held liable for any such use.
140
+ </h3>
141
+ <h3 style="font-weight: 450; font-size: 0.8rem; margin: 0rem">
142
+ <b>All the images and video belongs to their respective owners/organisations. I dont claim any copywrite on any image and video.Big shoutout to hugging face community.</b>
143
+ </h3>
144
+ </div>
145
+ <div style="justify-content: center; display:flex; align-items: center;">
146
+ <iframe width="400px" height="300px" src="https://www.youtube.com/embed/UIZAiXYceBI?si=JaY1OzdXShC5OR_M?autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
147
+ </div>
148
+ """
149
+ )
150
+ app.queue()
151
+ app.launch(auth=('user','admin'),auth_message="Enter your username and password.If you don't have it please dm me on linkedin @ https://www.linkedin.com/in/jaskiratsingh04 or Email me @singh.kirat.0409@gmail.com Thanks!",debug=True,share=True)
eg1.png ADDED

Git LFS Details

  • SHA256: 41eb379643561f1eae635d6a94005303f49bbce8490d05aef8a19da642f92bd8
  • Pointer size: 132 Bytes
  • Size of remote file: 1.54 MB
eg2.png ADDED

Git LFS Details

  • SHA256: 2dd6a06297441a22e8fb2d9ede0662882efaedafcc9dfddf1c32024f16286e08
  • Pointer size: 132 Bytes
  • Size of remote file: 1.43 MB
eg3.jpg ADDED
eg4.webp ADDED
gemini.jpg ADDED