abdibrokhim commited on
Commit
3ecc63e
·
1 Parent(s): 4c79642

major changes

Browse files
.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
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
37
+ *.png filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -87,7 +87,7 @@ def generate_images(user_prompt, selected_models):
87
  )
88
  if response.status_code == 201:
89
  response_json = response.json()
90
- print(f"Response for model {model}: {response_json}")
91
  # Handle OpenAI models differently (Aspect 2)
92
  if model in ["dall-e-3", "dall-e-2"]:
93
  if 'data' in response_json and 'url' in response_json['data'][0]:
@@ -130,64 +130,159 @@ model_list = [
130
  "dall-e-2",
131
  ]
132
 
133
- # Gradio Interface
134
- with gr.Blocks() as demo:
135
- # Title and links
136
- with gr.Row():
137
- gr.Markdown("""
138
- # Let's Generate Cutesy AI Sticker!
139
- <p align="center">
140
- <a title="Page" href="https://ai-sticker-maker.vercel.app/" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
141
- <img src="https://img.shields.io/badge/Project-Website-pink?logo=googlechrome&logoColor=white">
142
- </a>
143
- <a title="arXiv" href="https://rebrand.ly/aistickermakerpaper" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
144
- <img src="https://img.shields.io/badge/arXiv-Paper-b31b1b?logo=arxiv&logoColor=white">
145
- </a>
146
- <a title="Github" href="https://github.com/abdibrokhim/ai-sticker-maker" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
147
- <img src="https://img.shields.io/github/stars/EnVision-Research/Lotus?label=GitHub%20%E2%98%85&logo=github&color=C8C" alt="badge-github-stars">
148
- </a>
149
- <a title="Social" href="https://x.com/abdibrokhim" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
150
- <img src="https://www.obukhov.ai/img/badges/badge-social.svg" alt="social">
151
- </a>
152
- <a title="Social" href="https://x.com/haodongli00/status/1839524569058582884" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
153
- <img src="https://www.obukhov.ai/img/badges/badge-social.svg" alt="social">
154
- </a>
155
- <br>
156
- <strong>Please consider starring <span style="color: orange">&#9733;</span> the <a href="https://github.com/abdibrokhim/ai-sticker-maker" target="_blank" rel="noopener noreferrer">GitHub Repo</a> if you find this useful!</strong>
157
- """)
158
- with gr.Row():
159
- with gr.Column(scale=1):
160
- # Model selection
161
- selected_models = gr.CheckboxGroup(
162
- choices=model_list,
163
- label="Select Image Generation Models",
164
- value=["stable-diffusion-v35-large"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  )
166
- with gr.Column(scale=2):
167
- # User prompt input
168
- # Example propt: a very cutesy panda sitting and easting a pink very creamy ice cream
169
- user_prompt = gr.Textbox(
170
- placeholder="A girl with short pink hair wearing an oversize hoodie...",
171
- label="Enter your prompt here"
172
  )
173
- # Generate button
174
- generate_button = gr.Button("Generate Images")
175
-
176
- # Outputs
177
- image_outputs = gr.Gallery(label="Generated Images", columns=[3], rows=[1], elem_id="gallery")
178
-
179
- # Function to run on button click
180
- def on_click(user_prompt, selected_models):
181
- images = generate_images(user_prompt, selected_models)
182
- # Filter out None values in case of errors
183
- return [img for img in images if img is not None]
184
-
185
- # Event binding
186
- generate_button.click(
187
- fn=on_click,
188
- inputs=[user_prompt, selected_models],
189
- outputs=image_outputs
190
- )
191
 
192
- # Launch the Gradio app
193
- demo.launch()
 
 
 
 
 
 
87
  )
88
  if response.status_code == 201:
89
  response_json = response.json()
90
+ print("Response JSON:", response_json)
91
  # Handle OpenAI models differently (Aspect 2)
92
  if model in ["dall-e-3", "dall-e-2"]:
93
  if 'data' in response_json and 'url' in response_json['data'][0]:
 
130
  "dall-e-2",
131
  ]
132
 
133
+ # Examples data as a list of dictionaries
134
+ examples = [
135
+ {
136
+ 'user_prompt': "An adorable kitten playing with a ball of yarn",
137
+ 'enhanced_prompt': "An adorable, fluffy kitten with big, sparkling eyes and playful whiskers, tumbling around with a vibrant ball of yarn. The kitten's fur is a soft blend of warm creams and greys, giving it a cuddly, huggable appearance. Its expression is full of joy and mischief, with a tiny pink tongue playfully sticking out. The ball of yarn is a bright and cheerful red, unraveling with dynamic loops and curls. The style is chibi-like and sticker-friendly, with minimalistic lines and gentle shading. The background is a simple, soft pastel color with tiny floating paw prints, enhancing the cute and playful theme.",
138
+ 'generated_image': "./generated-images/cat-and-yarn.jpeg",
139
+ 'ai_model': "dall-e-3"
140
+ },
141
+ {
142
+ 'user_prompt': "A cutesy cat eating ice cream under a rainbow",
143
+ 'enhanced_prompt': "A playful, cartoonish cat with big, sparkling eyes and soft, rounded features, happily licking a colorful ice cream cone. The cat has fluffy fur, pastel colors—like soft cream, peach, or light gray—and tiny pink blush on its cheeks for added charm. It sits contentedly under a bright, arched rainbow with soft, blended hues. Small, floating sparkles and tiny hearts surround the cat and ice cream to add a touch of magic. The ice cream cone has multiple scoops in fun, bright colors like pink, blue, and mint green, making the whole scene feel adorable and sweet, perfect for a cute sticker!",
144
+ 'generated_image': "./generated-images/cat-and-icecream.jpeg",
145
+ 'ai_model': "dall-e-3"
146
+ },
147
+ {
148
+ 'user_prompt': "A girl with short pink+black hair wearing a pink shirt.",
149
+ 'enhanced_prompt': "An adorable chibi-style character with a soft, cozy look. She has a short, wavy bob hairstyle in gradient shades of gray with delicate highlights that sparkle. Her large, expressive brown eyes have a gentle shine, and her cheeks are lightly blushed, adding a touch of warmth. She wears an off-shoulder, cream-colored sweater, giving a relaxed and comforting vibe. The background is a soft pastel gradient in warm beige and cream tones, decorated with small, floating sparkles and star shapes for a magical effect. The overall style is cute, minimalist, and sticker-friendly.",
150
+ 'generated_image': "./generated-images/girl-with-white-grey-hair.png",
151
+ 'ai_model': "dall-e-3"
152
+ }
153
+ ]
154
+
155
+ # Function to create an HTML table for the examples
156
+ def create_examples_table(examples):
157
+ html = '<table style="width:100%; text-align:left; border-collapse: collapse;">'
158
+ # Table headers
159
+ html += '<tr>'
160
+ html += '<th style="border: 1px solid black; padding: 8px; width:20%;">User Prompt</th>'
161
+ html += '<th style="border: 1px solid black; padding: 8px; width:50%;">Enhanced Prompt</th>'
162
+ html += '<th style="border: 1px solid black; padding: 8px; width:20%;">Generated Image</th>'
163
+ html += '<th style="border: 1px solid black; padding: 8px; width:10%;">AI Model</th>'
164
+ html += '</tr>'
165
+ # Table rows
166
+ for example in examples:
167
+ html += '<tr>'
168
+ html += f'<td style="border: 1px solid black; padding: 8px; vertical-align: top;">{example["user_prompt"]}</td>'
169
+ html += f'<td style="border: 1px solid black; padding: 8px; vertical-align: top;">{example["enhanced_prompt"]}</td>'
170
+ # Read and encode the image
171
+ try:
172
+ with open(example["generated_image"], "rb") as image_file:
173
+ image_data = image_file.read()
174
+ encoded_image = base64.b64encode(image_data).decode('utf-8')
175
+ html += f'<td style="border: 1px solid black; padding: 8px; vertical-align: top;"><img src="data:image/jpeg;base64,{encoded_image}" alt="Generated Image" width="800"/></td>'
176
+ except Exception as e:
177
+ print(f"Error loading image {example['generated_image']}: {e}")
178
+ html += '<td style="border: 1px solid black; padding: 8px; vertical-align: top;">Image not available</td>'
179
+ html += f'<td style="border: 1px solid black; padding: 8px; vertical-align: top;">{example["ai_model"]}</td>'
180
+ html += '</tr>'
181
+ html += '</table>'
182
+ return html
183
+
184
+ # Gradio Interface with styling and functionality
185
+ with gr.Blocks(
186
+ css="""
187
+ #download {
188
+ height: 118px;
189
+ }
190
+ .slider .inner {
191
+ width: 5px;
192
+ background: #FFF;
193
+ }
194
+ .viewport {
195
+ aspect-ratio: 4/3;
196
+ }
197
+ .tabs button.selected {
198
+ font-size: 20px !important;
199
+ color: crimson !important;
200
+ }
201
+ h1, h2, h3 {
202
+ text-align: center;
203
+ display: block;
204
+ }
205
+ .md_feedback li {
206
+ margin-bottom: 0px !important;
207
+ }
208
+ """,
209
+ ) as demo:
210
+ gr.Markdown("""
211
+ # Let's Generate Cutesy AI Sticker!
212
+ <p align="center">
213
+ <a title="Page" href="https://ai-sticker-maker.vercel.app/" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
214
+ <img src="https://img.shields.io/badge/Project-Website-pink?logo=googlechrome&logoColor=white">
215
+ </a>
216
+ <a title="arXiv" href="https://rebrand.ly/aistickermakerpaper" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
217
+ <img src="https://img.shields.io/badge/arXiv-Paper-b31b1b?logo=arxiv&logoColor=white">
218
+ </a>
219
+ <a title="Github" href="https://github.com/abdibrokhim/ai-sticker-maker" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
220
+ <img src="https://img.shields.io/github/stars/EnVision-Research/Lotus?label=GitHub%20%E2%98%85&logo=github&color=C8C" alt="badge-github-stars">
221
+ </a>
222
+ <a title="Social" href="https://x.com/abdibrokhim" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
223
+ <img src="https://www.obukhov.ai/img/badges/badge-social.svg" alt="social">
224
+ </a>
225
+ <a title="Social" href="https://x.com/haodongli00/status/1839524569058582884" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
226
+ <img src="https://www.obukhov.ai/img/badges/badge-social.svg" alt="social">
227
+ </a>
228
+ <br>
229
+ <strong>Please consider starring <span style="color: orange">&#9733;</span> the <a href="https://github.com/abdibrokhim/ai-sticker-maker" target="_blank" rel="noopener noreferrer">GitHub Repo</a> if you find this useful!</strong>
230
+ """)
231
+
232
+ with gr.Tabs(elem_classes=["tabs"]):
233
+ with gr.TabItem("Generate Stickers"):
234
+ with gr.Row():
235
+ with gr.Column(scale=1):
236
+ # Model selection
237
+ selected_models = gr.CheckboxGroup(
238
+ choices=model_list,
239
+ label="Select Image Generation Models",
240
+ value=["dall-e-3"]
241
+ )
242
+ # User prompt input
243
+ user_prompt = gr.Textbox(
244
+ placeholder="A girl with short pink hair wearing an oversize hoodie...",
245
+ label="Enter your prompt here"
246
+ )
247
+ seed = gr.Number(
248
+ label="Seed (optional)",
249
+ value=0,
250
+ minimum=0,
251
+ maximum=999999999,
252
+ )
253
+ # Generate and Reset buttons
254
+ with gr.Row():
255
+ generate_button = gr.Button("Generate Images", variant="primary")
256
+ reset_button = gr.Button("Reset")
257
+ with gr.Column(scale=2):
258
+ # Outputs
259
+ image_outputs = gr.Gallery(
260
+ label="Generated Images",
261
+ elem_id="gallery",
262
+ columns=[3],
263
+ rows=[1],
264
+ )
265
+ # Event bindings
266
+ def on_click(user_prompt, selected_models):
267
+ images = generate_images(user_prompt, selected_models)
268
+ return images
269
+
270
+ generate_button.click(
271
+ fn=on_click,
272
+ inputs=[user_prompt, selected_models],
273
+ outputs=image_outputs
274
  )
275
+ reset_button.click(
276
+ fn=lambda: ("", []),
277
+ inputs=[],
278
+ outputs=[user_prompt, selected_models],
279
+ queue=False,
 
280
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
 
282
+ with gr.TabItem("Examples"):
283
+ # Create and display the examples table
284
+ examples_html = create_examples_table(examples)
285
+ gr.HTML(examples_html)
286
+
287
+ # Launch the Gradio app
288
+ demo.launch()
generated-images/cat-and-icecream.jpeg ADDED

Git LFS Details

  • SHA256: 853c86fc2cf686cec29f49d68bac93b37f2a4d6f58419c3fd8712600847e2801
  • Pointer size: 131 Bytes
  • Size of remote file: 269 kB
generated-images/cat-and-yarn.jpeg ADDED

Git LFS Details

  • SHA256: 5b3a745a692b739b2b069f17dede472798e07e0088f550cd8f188a1444943dc3
  • Pointer size: 131 Bytes
  • Size of remote file: 286 kB
generated-images/girl-with-black-pink-hair.png ADDED

Git LFS Details

  • SHA256: d07dd515044753d49a98c5a63f650a36dea290c56422c5d0a064246f15a56d50
  • Pointer size: 132 Bytes
  • Size of remote file: 1.38 MB
generated-images/girl-with-white-grey-hair.png ADDED

Git LFS Details

  • SHA256: 4212366afbd68c05f5a53ac684f89496240ebfc0b425e3ee9fff37ea407d3875
  • Pointer size: 132 Bytes
  • Size of remote file: 1.63 MB
generated-images/panda-and-icecream.png ADDED

Git LFS Details

  • SHA256: dee8f227245f210de013ddc9c7c14dc0801ac2b71cc787a0bc5058b7586c21c2
  • Pointer size: 132 Bytes
  • Size of remote file: 1.17 MB
instructions.txt CHANGED
@@ -1,3 +1,4 @@
 
1
 
2
  Given the following code snippets, and the list of image generation models with example API requests.
3
 
@@ -438,4 +439,30 @@ placeholder = "A girl with short pink hair wearing a oversize hoodie..."
438
 
439
  # main()
440
 
441
- <|end_of_code_snippet|>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *Note: commited intentionally for educational purposes
2
 
3
  Given the following code snippets, and the list of image generation models with example API requests.
4
 
 
439
 
440
  # main()
441
 
442
+ <|end_of_code_snippet|>
443
+
444
+
445
+
446
+ Refactor examples part. Follow this steps:
447
+ 1. make 4 columns: 1) user prompt, 2) enhanced prompt, 3) generated image, 4) ai model
448
+ 2. rewrite column labels also.
449
+ 3. better make dictionary for each entry. so i can easily add more examples.
450
+
451
+ here is example table info:
452
+ [entry 1:]
453
+ user prompt: "An adorable kitten playing with a ball of yarn"
454
+ enhanced prompt: "An adorable, fluffy kitten with big, sparkling eyes and playful whiskers, tumbling around with a vibrant ball of yarn. The kitten's fur is a soft blend of warm creams and greys, giving it a cuddly, huggable appearance. Its expression is full of joy and mischief, with a tiny pink tongue playfully sticking out. The ball of yarn is a bright and cheerful red, unraveling with dynamic loops and curls. The style is chibi-like and sticker-friendly, with minimalistic lines and gentle shading. The background is a simple, soft pastel color with tiny floating paw prints, enhancing the cute and playful theme."
455
+ generated image: "./generated-images/cat-and-yarn.jpeg"
456
+ ai model: "dall-e-3"
457
+
458
+ [entry 2:]
459
+ user prompt: "A cutesy cat eating ice cream under a rainbow"
460
+ enhanced prompt: "A playful, cartoonish cat with big, sparkling eyes and soft, rounded features, happily licking a colorful ice cream cone. The cat has fluffy fur, pastel colors—like soft cream, peach, or light gray—and tiny pink blush on its cheeks for added charm. It sits contentedly under a bright, arched rainbow with soft, blended hues. Small, floating sparkles and tiny hearts surround the cat and ice cream to add a touch of magic. The ice cream cone has multiple scoops in fun, bright colors like pink, blue, and mint green, making the whole scene feel adorable and sweet, perfect for a cute sticker!"
461
+ generated image: "./generated-images/cat-and-icecream.jpeg"
462
+ ai model: "dall-e-3"
463
+
464
+ [entry 3:]
465
+ user prompt: "A girl with short pink+black hair wearing a pink shirt."
466
+ enhanced prompt: "An adorable chibi-style character with a soft, cozy look. She has a short, wavy bob hairstyle in gradient shades of gray with delicate highlights that sparkle. Her large, expressive brown eyes have a gentle shine, and her cheeks are lightly blushed, adding a touch of warmth. She wears an off-shoulder, cream-colored sweater, giving a relaxed and comforting vibe. The background is a soft pastel gradient in warm beige and cream tones, decorated with small, floating sparkles and star shapes for a magical effect. The overall style is cute, minimalist, and sticker-friendly."
467
+ generated image: "./generated-images/girl-with-white-grey-hair.png"
468
+ ai model: "dall-e-3"
paper.txt CHANGED
@@ -1,3 +1,5 @@
 
 
1
  [title]
2
  Text-to-Sticker: Leveraging Image Generation Models to generate AI stickers using simple Prompt Engineering techniques
3
 
 
1
+ *Note: commited intentionally for educational purposes
2
+
3
  [title]
4
  Text-to-Sticker: Leveraging Image Generation Models to generate AI stickers using simple Prompt Engineering techniques
5
 
systemPrompt.txt CHANGED
@@ -1,3 +1,5 @@
 
 
1
  You are tasked with enhancing user prompts to generate clear, detailed, and creative descriptions for a sticker creation AI. The final prompt should be imaginative, visually rich, and aligned with the goal of producing a cute, stylized, and highly personalized sticker based on the user's input.
2
 
3
  Instructions:
 
1
+ *Note: commited intentionally for educational purposes
2
+
3
  You are tasked with enhancing user prompts to generate clear, detailed, and creative descriptions for a sticker creation AI. The final prompt should be imaginative, visually rich, and aligned with the goal of producing a cute, stylized, and highly personalized sticker based on the user's input.
4
 
5
  Instructions: