simonlee-cb commited on
Commit
d50deb1
·
1 Parent(s): 408fffa

feat: update descriptions

Browse files
Files changed (1) hide show
  1. gradio_chat.py +48 -39
gradio_chat.py CHANGED
@@ -17,6 +17,45 @@ model = OpenAIModel(
17
  api_key=os.environ.get("OPENAI_API_KEY"),
18
  )
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  simple_agent = Agent(
21
  model,
22
  system_prompt="You are a helpful assistant that can answer questions and help with tasks.",
@@ -160,19 +199,7 @@ async def stream_from_agent(chat_input, chatbot, past_messages, current_image):
160
  yield gr.Textbox(interactive=True), gr.skip(), past_messages, current_image
161
 
162
  with gr.Blocks() as demo:
163
- gr.HTML(
164
- """
165
- <div style="display: flex; justify-content: center; align-items: center; gap: 2rem; padding: 1rem; width: 100%">
166
- <img src="https://ai.pydantic.dev/img/logo-white.svg" style="max-width: 200px; height: auto">
167
- <div>
168
- <h1 style="margin: 0 0 1rem 0">Image Editing Assistant</h1>
169
- <h3 style="margin: 0 0 0.5rem 0">
170
- This assistant edits images according to your instructions.
171
- </h3>
172
- </div>
173
- </div>
174
- """
175
- )
176
 
177
  current_image = gr.State(None)
178
  past_messages = gr.State([])
@@ -181,32 +208,7 @@ with gr.Blocks() as demo:
181
  label='Image Editing Assistant',
182
  type='messages',
183
  avatar_images=(None, 'https://ai.pydantic.dev/img/logo-white.svg'),
184
- examples=[
185
- {
186
- "text": "Replace the background to the space with stars and planets",
187
- "files": [
188
- "https://cdn.prod.website-files.com/66f230993926deadc0ac3a44/66f370d65f158cbbcfbcc532_Crossed%20Arms%20Levi%20Meir%20Clancy.jpg"
189
- ]
190
- },
191
- {
192
- "text": "Change all the balloons to red in the image",
193
- "files": [
194
- "https://www.apple.com/tv-pr/articles/2024/10/apple-tv-unveils-severance-season-two-teaser-ahead-of-the-highly-anticipated-return-of-the-emmy-and-peabody-award-winning-phenomenon/images/big-image/big-image-01/1023024_Severance_Season_Two_Official_Trailer_Big_Image_01_big_image_post.jpg.large_2x.jpg"
195
- ]
196
- },
197
- {
198
- "text": "Change coffee to a glass of water",
199
- "files": [
200
- "https://previews.123rf.com/images/vadymvdrobot/vadymvdrobot1812/vadymvdrobot181201149/113217373-image-of-smiling-woman-holding-takeaway-coffee-in-paper-cup-and-taking-selfie-while-walking-through.jpg"
201
- ]
202
- },
203
- {
204
- "text": "ENHANCE!",
205
- "files": [
206
- "https://m.media-amazon.com/images/M/MV5BNzM3ODc5NzEtNzJkOC00MDM4LWI0MTYtZTkyNmY3ZTBhYzkxXkEyXkFqcGc@._V1_QL75_UX1000_CR0,52,1000,563_.jpg"
207
- ]
208
- }
209
- ]
210
  )
211
 
212
  with gr.Row():
@@ -233,5 +235,12 @@ with gr.Blocks() as demo:
233
  outputs=[chat_input, chatbot, past_messages, current_image],
234
  )
235
 
 
 
 
 
 
 
 
236
  if __name__ == '__main__':
237
  demo.launch()
 
17
  api_key=os.environ.get("OPENAI_API_KEY"),
18
  )
19
 
20
+ INTRO = """
21
+ # Image Editing Assistant
22
+
23
+ ### Experience seamless image editing using natural language in a chat-based interface.
24
+
25
+ With this demo, you can:
26
+ - Enhance or upscale an image
27
+ - Remove objects from an image
28
+ - Replace elements within an image
29
+ - Change the background
30
+ """
31
+
32
+ EXAMPLES = [
33
+ {
34
+ "text": "Replace the background to the space with stars and planets",
35
+ "files": [
36
+ "https://cdn.prod.website-files.com/66f230993926deadc0ac3a44/66f370d65f158cbbcfbcc532_Crossed%20Arms%20Levi%20Meir%20Clancy.jpg"
37
+ ]
38
+ },
39
+ {
40
+ "text": "Change all the balloons to red in the image",
41
+ "files": [
42
+ "https://www.apple.com/tv-pr/articles/2024/10/apple-tv-unveils-severance-season-two-teaser-ahead-of-the-highly-anticipated-return-of-the-emmy-and-peabody-award-winning-phenomenon/images/big-image/big-image-01/1023024_Severance_Season_Two_Official_Trailer_Big_Image_01_big_image_post.jpg.large_2x.jpg"
43
+ ]
44
+ },
45
+ {
46
+ "text": "Change coffee to a glass of water",
47
+ "files": [
48
+ "https://previews.123rf.com/images/vadymvdrobot/vadymvdrobot1812/vadymvdrobot181201149/113217373-image-of-smiling-woman-holding-takeaway-coffee-in-paper-cup-and-taking-selfie-while-walking-through.jpg"
49
+ ]
50
+ },
51
+ {
52
+ "text": "ENHANCE!",
53
+ "files": [
54
+ "https://m.media-amazon.com/images/M/MV5BNzM3ODc5NzEtNzJkOC00MDM4LWI0MTYtZTkyNmY3ZTBhYzkxXkEyXkFqcGc@._V1_QL75_UX1000_CR0,52,1000,563_.jpg"
55
+ ]
56
+ }
57
+ ]
58
+
59
  simple_agent = Agent(
60
  model,
61
  system_prompt="You are a helpful assistant that can answer questions and help with tasks.",
 
199
  yield gr.Textbox(interactive=True), gr.skip(), past_messages, current_image
200
 
201
  with gr.Blocks() as demo:
202
+ gr.Markdown(INTRO)
 
 
 
 
 
 
 
 
 
 
 
 
203
 
204
  current_image = gr.State(None)
205
  past_messages = gr.State([])
 
208
  label='Image Editing Assistant',
209
  type='messages',
210
  avatar_images=(None, 'https://ai.pydantic.dev/img/logo-white.svg'),
211
+ examples=EXAMPLES
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  )
213
 
214
  with gr.Row():
 
235
  outputs=[chat_input, chatbot, past_messages, current_image],
236
  )
237
 
238
+ examples = gr.Examples(
239
+ examples=EXAMPLES,
240
+ inputs=[chat_input],
241
+ outputs=[chat_input],
242
+ )
243
+
244
+
245
  if __name__ == '__main__':
246
  demo.launch()