abdibrokhim
commited on
Commit
•
3d205c2
1
Parent(s):
922e3d9
init
Browse files- .gitattributes +2 -0
- .gitignore +2 -0
- app.py +288 -0
- generated-images/cat-and-icecream.jpeg +0 -0
- generated-images/cat-and-yarn.jpeg +0 -0
- generated-images/girl-with-black-pink-hair.png +3 -0
- generated-images/girl-with-white-grey-hair.png +3 -0
- generated-images/panda-and-icecream.png +3 -0
- instructions.txt +468 -0
- paper.txt +17 -0
- requirements.txt +5 -0
- systemPrompt.txt +42 -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 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
37 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
.venv
|
2 |
+
.env
|
app.py
ADDED
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from openai import OpenAI
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
import os
|
5 |
+
import requests
|
6 |
+
import base64
|
7 |
+
from PIL import Image
|
8 |
+
from io import BytesIO
|
9 |
+
|
10 |
+
load_dotenv()
|
11 |
+
|
12 |
+
# Initialize OpenAI client
|
13 |
+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
14 |
+
|
15 |
+
# System prompt (to be updated)
|
16 |
+
SYSTEM_PROMPT = """
|
17 |
+
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.
|
18 |
+
|
19 |
+
Instructions:
|
20 |
+
|
21 |
+
Visual Clarity: The enhanced prompt must provide clear visual details that can be directly interpreted by the image generation model. Break down and elaborate on specific elements of the scene, object, or character based on the user input.
|
22 |
+
|
23 |
+
Example: If the user says "A girl with pink hair," elaborate by adding features like "short wavy pink hair with soft, pastel hues."
|
24 |
+
Style & Theme:
|
25 |
+
|
26 |
+
Emphasize that the final output should reflect a cute, playful, and approachable style.
|
27 |
+
Add terms like "adorable," "cartoonish," "sticker-friendly," or "chibi-like" to guide the output to a lighter, cuter aesthetic.
|
28 |
+
Include styling prompts like “minimalistic lines,” “soft shading,” and “vibrant yet soothing colors.”
|
29 |
+
Personalization:
|
30 |
+
|
31 |
+
If a reference or context is given, enhance it to make the sticker feel personalized.
|
32 |
+
Add context-appropriate descriptors like “wearing a cozy blue hoodie,” “soft pink blush on cheeks,” or “a playful expression.”
|
33 |
+
Expression & Pose:
|
34 |
+
|
35 |
+
Where applicable, refine prompts with suggestions about facial expressions or body language. For example, “Smiling softly with big sparkling eyes” or “A cute wink and a slight tilt of the head.”
|
36 |
+
Background & Accessories:
|
37 |
+
|
38 |
+
Optionally suggest simple, complementary backgrounds or accessories, depending on user input. For instance, "A light pastel background with small, floating hearts" or "Holding a tiny, sparkling star."
|
39 |
+
Colors:
|
40 |
+
|
41 |
+
Emphasize the color scheme based on the user's description, making sure it's consistent with a cute, playful style.
|
42 |
+
Use descriptors like “soft pastels,” “bright and cheerful,” or “warm and friendly hues” to set the mood.
|
43 |
+
Avoid Overcomplication:
|
44 |
+
|
45 |
+
Keep the descriptions short enough to be concise and not overly complex, as the output should retain a sticker-friendly quality.
|
46 |
+
Avoid unnecessary details that could clutter the design.
|
47 |
+
Tone and Language:
|
48 |
+
|
49 |
+
The tone should be light, imaginative, and fun, matching the playful nature of stickers.
|
50 |
+
|
51 |
+
Example:
|
52 |
+
User Input:
|
53 |
+
"A girl with pink hair wearing a hoodie."
|
54 |
+
|
55 |
+
Enhanced Prompt:
|
56 |
+
"An adorable girl with short, wavy pink hair in soft pastel hues, wearing a cozy light blue hoodie. She has a sweet smile with big, sparkling eyes, and a playful expression. The sticker style is cartoonish with minimalistic lines and soft shading. The background is a simple light pastel color with small floating hearts, creating a cute and inviting look."
|
57 |
+
"""
|
58 |
+
|
59 |
+
# Function to enhance the user's prompt
|
60 |
+
def enhance_prompt(user_prompt) -> str:
|
61 |
+
completion = client.chat.completions.create(
|
62 |
+
model="gpt-4o",
|
63 |
+
messages=[
|
64 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
65 |
+
{"role": "user", "content": user_prompt}
|
66 |
+
]
|
67 |
+
)
|
68 |
+
ep = completion.choices[0].message.content
|
69 |
+
print('Enhanced Prompt:', ep)
|
70 |
+
return ep
|
71 |
+
|
72 |
+
# Function to generate images using the selected models
|
73 |
+
def generate_images(user_prompt, selected_models):
|
74 |
+
enhanced_prompt = enhance_prompt(user_prompt)
|
75 |
+
images = []
|
76 |
+
headers = {
|
77 |
+
"Authorization": f"Bearer {os.getenv('AIMLAPI_API_KEY')}",
|
78 |
+
}
|
79 |
+
for model in selected_models:
|
80 |
+
try:
|
81 |
+
payload = {
|
82 |
+
"prompt": enhanced_prompt,
|
83 |
+
"model": model,
|
84 |
+
}
|
85 |
+
response = requests.post(
|
86 |
+
"https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
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]:
|
94 |
+
image_url = response_json['data'][0]['url']
|
95 |
+
image_response = requests.get(image_url)
|
96 |
+
image = Image.open(BytesIO(image_response.content))
|
97 |
+
images.append(image)
|
98 |
+
else:
|
99 |
+
print(f"No URL found for model {model}")
|
100 |
+
else:
|
101 |
+
# Handle other models (Aspect 1)
|
102 |
+
if 'images' in response_json and 'url' in response_json['images'][0]:
|
103 |
+
image_url = response_json['images'][0]['url']
|
104 |
+
image_response = requests.get(image_url)
|
105 |
+
image = Image.open(BytesIO(image_response.content))
|
106 |
+
images.append(image)
|
107 |
+
else:
|
108 |
+
print(f"No URL found for model {model}")
|
109 |
+
else:
|
110 |
+
print(f"Error with model {model}: {response.text}")
|
111 |
+
except Exception as e:
|
112 |
+
print(f"Exception occurred with model {model}: {e}")
|
113 |
+
continue
|
114 |
+
return images
|
115 |
+
|
116 |
+
# List of available image generation models
|
117 |
+
model_list = [
|
118 |
+
"stable-diffusion-v35-large",
|
119 |
+
"flux-pro/v1.1",
|
120 |
+
"dall-e-3",
|
121 |
+
"stable-diffusion-v3-medium",
|
122 |
+
"runwayml/stable-diffusion-v1-5",
|
123 |
+
"stabilityai/stable-diffusion-xl-base-1.0",
|
124 |
+
"stabilityai/stable-diffusion-2-1",
|
125 |
+
"SG161222/Realistic_Vision_V3.0_VAE",
|
126 |
+
"prompthero/openjourney",
|
127 |
+
"wavymulder/Analog-Diffusion",
|
128 |
+
"flux-pro",
|
129 |
+
"flux-realism",
|
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">★</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
generated-images/cat-and-yarn.jpeg
ADDED
generated-images/girl-with-black-pink-hair.png
ADDED
Git LFS Details
|
generated-images/girl-with-white-grey-hair.png
ADDED
Git LFS Details
|
generated-images/panda-and-icecream.png
ADDED
Git LFS Details
|
instructions.txt
ADDED
@@ -0,0 +1,468 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
5 |
+
[TASK]
|
6 |
+
<|gradio_app_instructions|>
|
7 |
+
Your task is to complete the code snippets by adding the necessary code to make the API requests.
|
8 |
+
The steps are really simple; user inputs any prompt; for example; "A girl with short pink hair wearing a oversize hoodie.".
|
9 |
+
Then, the prompt will be passed to the enhance_prompt function to enhance the prompt.
|
10 |
+
The enhanced prompt will be passed to the image generation model to generate the image.
|
11 |
+
However, here user will select which image generation model to use.
|
12 |
+
The image will be generated and displayed to the user.
|
13 |
+
|
14 |
+
[UI]
|
15 |
+
<|gradio_app_ui|>
|
16 |
+
List the image generation models on the left side of the UI.
|
17 |
+
Make image generation model selection as checkbox.
|
18 |
+
Display as much Image Output as user selected image generation models.
|
19 |
+
For example; we have 13 image generation models, and user selected 3 models using checkbox.
|
20 |
+
After user enters the prompt. The image will be generated using 3 models and displayed to the user.
|
21 |
+
|
22 |
+
[DOCS]
|
23 |
+
Feel free to use Gradio documentation to complete the task.
|
24 |
+
|
25 |
+
[CODE]
|
26 |
+
<|start_of_code_snippet|>
|
27 |
+
import gradio as gr
|
28 |
+
from openai import OpenAI
|
29 |
+
from dotenv import load_dotenv
|
30 |
+
import os
|
31 |
+
|
32 |
+
load_dotenv()
|
33 |
+
|
34 |
+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
35 |
+
|
36 |
+
# i will update [SYSTEM_PROMPT] myself, ignore for now.
|
37 |
+
SYSTEM_PROMPT = """
|
38 |
+
<i will update myself, ignore for now.>
|
39 |
+
"""
|
40 |
+
|
41 |
+
# general function to enhance prompt
|
42 |
+
# user prompt will be passed as an argument
|
43 |
+
# this is very first step after user input
|
44 |
+
# then enhanced prompt will be passed to the image generation model
|
45 |
+
def enhance_prompt(user_prompt) -> str:
|
46 |
+
completion = client.chat.completions.create(
|
47 |
+
model="gpt-4o",
|
48 |
+
messages=[
|
49 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
50 |
+
{"role": "user", "content": user_prompt}
|
51 |
+
]
|
52 |
+
)
|
53 |
+
|
54 |
+
ep = completion.choices[0].message.content
|
55 |
+
print('Enhanced Prompt: ' ,ep)
|
56 |
+
|
57 |
+
return ep
|
58 |
+
|
59 |
+
# title should be centered
|
60 |
+
# gradio app title
|
61 |
+
title = "Let's Generate Cutesy AI Sticker!"
|
62 |
+
|
63 |
+
# align project_website and paper_url center and in one row
|
64 |
+
project_website = "https://ai-sticker-maker.vercel.app/"
|
65 |
+
paper_url = "https://rebrand.ly/aistickermakerpaper"
|
66 |
+
|
67 |
+
# call to action text should be also centered
|
68 |
+
call_to_action_text = "Please consider starring ⭐️ the [GitHub Repo](https://github.com/abdibrokhim/ai-sticker-maker) if you find this useful!"
|
69 |
+
|
70 |
+
# to build from scratch, you can follow the tutorial on medium and dev.to
|
71 |
+
tutorial_on_medium_link = "https://medium.com/@abdibrokhim/building-an-ai-sticker-maker-platform-with-ai-ml-api-next-js-8b0767a7e159"
|
72 |
+
tutorial_on_dev_link = "https://dev.to/abdibrokhim/building-an-ai-sticker-maker-platform-with-aiml-api-nextjs-react-and-tailwind-css-using-openai-gpt-4o-and-dalle-3-models-46ip"
|
73 |
+
|
74 |
+
# general input placeholder
|
75 |
+
placeholder = "A girl with short pink hair wearing a oversize hoodie..."
|
76 |
+
|
77 |
+
<|list_of_image_generation_models|>
|
78 |
+
# list of image generation models with example API requests
|
79 |
+
|
80 |
+
# 1. stable-diffusion-v35-large
|
81 |
+
# import requests
|
82 |
+
# import base64
|
83 |
+
# def main():
|
84 |
+
# headers = {
|
85 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
86 |
+
# }
|
87 |
+
|
88 |
+
# payload = {
|
89 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
90 |
+
# "model": "stable-diffusion-v35-large",
|
91 |
+
# }
|
92 |
+
|
93 |
+
# response = requests.post(
|
94 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
95 |
+
# )
|
96 |
+
|
97 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
98 |
+
# image_data = base64.b64decode(image_base64)
|
99 |
+
|
100 |
+
# with open("./image.png", "wb") as file:
|
101 |
+
# file.write(image_data)
|
102 |
+
|
103 |
+
|
104 |
+
# main()
|
105 |
+
|
106 |
+
# 2. flux-pro/v1.1
|
107 |
+
# import requests
|
108 |
+
# import base64
|
109 |
+
|
110 |
+
|
111 |
+
# def main():
|
112 |
+
# headers = {
|
113 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
114 |
+
# }
|
115 |
+
|
116 |
+
# payload = {
|
117 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
118 |
+
# "model": "flux-pro/v1.1",
|
119 |
+
# }
|
120 |
+
|
121 |
+
# response = requests.post(
|
122 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
123 |
+
# )
|
124 |
+
|
125 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
126 |
+
# image_data = base64.b64decode(image_base64)
|
127 |
+
|
128 |
+
# with open("./image.png", "wb") as file:
|
129 |
+
# file.write(image_data)
|
130 |
+
|
131 |
+
|
132 |
+
# main()
|
133 |
+
|
134 |
+
# 3. dall-e-3
|
135 |
+
# import requests
|
136 |
+
# import base64
|
137 |
+
|
138 |
+
|
139 |
+
# def main():
|
140 |
+
# headers = {
|
141 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
142 |
+
# }
|
143 |
+
|
144 |
+
# payload = {
|
145 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
146 |
+
# "model": "dall-e-3",
|
147 |
+
# }
|
148 |
+
|
149 |
+
# response = requests.post(
|
150 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
151 |
+
# )
|
152 |
+
|
153 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
154 |
+
# image_data = base64.b64decode(image_base64)
|
155 |
+
|
156 |
+
# with open("./image.png", "wb") as file:
|
157 |
+
# file.write(image_data)
|
158 |
+
|
159 |
+
|
160 |
+
# main()
|
161 |
+
|
162 |
+
# 4. stable-diffusion-v3-medium
|
163 |
+
# import requests
|
164 |
+
# import base64
|
165 |
+
|
166 |
+
|
167 |
+
# def main():
|
168 |
+
# headers = {
|
169 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
170 |
+
# }
|
171 |
+
|
172 |
+
# payload = {
|
173 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
174 |
+
# "model": "stable-diffusion-v3-medium",
|
175 |
+
# }
|
176 |
+
|
177 |
+
# response = requests.post(
|
178 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
179 |
+
# )
|
180 |
+
|
181 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
182 |
+
# image_data = base64.b64decode(image_base64)
|
183 |
+
|
184 |
+
# with open("./image.png", "wb") as file:
|
185 |
+
# file.write(image_data)
|
186 |
+
|
187 |
+
|
188 |
+
# main()
|
189 |
+
|
190 |
+
# 5. runwayml/stable-diffusion-v1-5
|
191 |
+
# import requests
|
192 |
+
# import base64
|
193 |
+
|
194 |
+
|
195 |
+
# def main():
|
196 |
+
# headers = {
|
197 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
198 |
+
# }
|
199 |
+
|
200 |
+
# payload = {
|
201 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
202 |
+
# "model": "runwayml/stable-diffusion-v1-5",
|
203 |
+
# }
|
204 |
+
|
205 |
+
# response = requests.post(
|
206 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
207 |
+
# )
|
208 |
+
|
209 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
210 |
+
# image_data = base64.b64decode(image_base64)
|
211 |
+
|
212 |
+
# with open("./image.png", "wb") as file:
|
213 |
+
# file.write(image_data)
|
214 |
+
|
215 |
+
|
216 |
+
# main()
|
217 |
+
|
218 |
+
# 6. stabilityai/stable-diffusion-xl-base-1.0
|
219 |
+
# import requests
|
220 |
+
# import base64
|
221 |
+
|
222 |
+
|
223 |
+
# def main():
|
224 |
+
# headers = {
|
225 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
226 |
+
# }
|
227 |
+
|
228 |
+
# payload = {
|
229 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
230 |
+
# "model": "stabilityai/stable-diffusion-xl-base-1.0",
|
231 |
+
# }
|
232 |
+
|
233 |
+
# response = requests.post(
|
234 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
235 |
+
# )
|
236 |
+
|
237 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
238 |
+
# image_data = base64.b64decode(image_base64)
|
239 |
+
|
240 |
+
# with open("./image.png", "wb") as file:
|
241 |
+
# file.write(image_data)
|
242 |
+
|
243 |
+
|
244 |
+
# main()
|
245 |
+
|
246 |
+
# 7. stabilityai/stable-diffusion-2-1
|
247 |
+
# import requests
|
248 |
+
# import base64
|
249 |
+
|
250 |
+
|
251 |
+
# def main():
|
252 |
+
# headers = {
|
253 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
254 |
+
# }
|
255 |
+
|
256 |
+
# payload = {
|
257 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
258 |
+
# "model": "stabilityai/stable-diffusion-2-1",
|
259 |
+
# }
|
260 |
+
|
261 |
+
# response = requests.post(
|
262 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
263 |
+
# )
|
264 |
+
|
265 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
266 |
+
# image_data = base64.b64decode(image_base64)
|
267 |
+
|
268 |
+
# with open("./image.png", "wb") as file:
|
269 |
+
# file.write(image_data)
|
270 |
+
|
271 |
+
|
272 |
+
# main()
|
273 |
+
|
274 |
+
# 8. SG161222/Realistic_Vision_V3.0_VAE
|
275 |
+
# import requests
|
276 |
+
# import base64
|
277 |
+
|
278 |
+
|
279 |
+
# def main():
|
280 |
+
# headers = {
|
281 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
282 |
+
# }
|
283 |
+
|
284 |
+
# payload = {
|
285 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
286 |
+
# "model": "SG161222/Realistic_Vision_V3.0_VAE",
|
287 |
+
# }
|
288 |
+
|
289 |
+
# response = requests.post(
|
290 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
291 |
+
# )
|
292 |
+
|
293 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
294 |
+
# image_data = base64.b64decode(image_base64)
|
295 |
+
|
296 |
+
# with open("./image.png", "wb") as file:
|
297 |
+
# file.write(image_data)
|
298 |
+
|
299 |
+
|
300 |
+
# main()
|
301 |
+
|
302 |
+
# 9. prompthero/openjourney
|
303 |
+
# import requests
|
304 |
+
# import base64
|
305 |
+
|
306 |
+
|
307 |
+
# def main():
|
308 |
+
# headers = {
|
309 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
310 |
+
# }
|
311 |
+
|
312 |
+
# payload = {
|
313 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
314 |
+
# "model": "prompthero/openjourney",
|
315 |
+
# }
|
316 |
+
|
317 |
+
# response = requests.post(
|
318 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
319 |
+
# )
|
320 |
+
|
321 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
322 |
+
# image_data = base64.b64decode(image_base64)
|
323 |
+
|
324 |
+
# with open("./image.png", "wb") as file:
|
325 |
+
# file.write(image_data)
|
326 |
+
|
327 |
+
|
328 |
+
# main()
|
329 |
+
|
330 |
+
# 10. wavymulder/Analog-Diffusion
|
331 |
+
# import requests
|
332 |
+
# import base64
|
333 |
+
|
334 |
+
|
335 |
+
# def main():
|
336 |
+
# headers = {
|
337 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
338 |
+
# }
|
339 |
+
|
340 |
+
# payload = {
|
341 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
342 |
+
# "model": "wavymulder/Analog-Diffusion",
|
343 |
+
# }
|
344 |
+
|
345 |
+
# response = requests.post(
|
346 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
347 |
+
# )
|
348 |
+
|
349 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
350 |
+
# image_data = base64.b64decode(image_base64)
|
351 |
+
|
352 |
+
# with open("./image.png", "wb") as file:
|
353 |
+
# file.write(image_data)
|
354 |
+
|
355 |
+
|
356 |
+
# main()
|
357 |
+
|
358 |
+
# 11. flux-pro
|
359 |
+
# import requests
|
360 |
+
# import base64
|
361 |
+
|
362 |
+
|
363 |
+
# def main():
|
364 |
+
# headers = {
|
365 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
366 |
+
# }
|
367 |
+
|
368 |
+
# payload = {
|
369 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
370 |
+
# "model": "flux-pro",
|
371 |
+
# }
|
372 |
+
|
373 |
+
# response = requests.post(
|
374 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
375 |
+
# )
|
376 |
+
|
377 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
378 |
+
# image_data = base64.b64decode(image_base64)
|
379 |
+
|
380 |
+
# with open("./image.png", "wb") as file:
|
381 |
+
# file.write(image_data)
|
382 |
+
|
383 |
+
|
384 |
+
# main()
|
385 |
+
|
386 |
+
# 12. flux-realism
|
387 |
+
# import requests
|
388 |
+
# import base64
|
389 |
+
|
390 |
+
|
391 |
+
# def main():
|
392 |
+
# headers = {
|
393 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
394 |
+
# }
|
395 |
+
|
396 |
+
# payload = {
|
397 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
398 |
+
# "model": "flux-realism",
|
399 |
+
# }
|
400 |
+
|
401 |
+
# response = requests.post(
|
402 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
403 |
+
# )
|
404 |
+
|
405 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
406 |
+
# image_data = base64.b64decode(image_base64)
|
407 |
+
|
408 |
+
# with open("./image.png", "wb") as file:
|
409 |
+
# file.write(image_data)
|
410 |
+
|
411 |
+
|
412 |
+
# main()
|
413 |
+
|
414 |
+
# 13. dall-e-2
|
415 |
+
# import requests
|
416 |
+
# import base64
|
417 |
+
|
418 |
+
|
419 |
+
# def main():
|
420 |
+
# headers = {
|
421 |
+
# "Authorization": "Bearer <YOUR_API_KEY>",
|
422 |
+
# }
|
423 |
+
|
424 |
+
# payload = {
|
425 |
+
# "prompt": "Hyperrealistic art featuring a cat in costume.",
|
426 |
+
# "model": "dall-e-2",
|
427 |
+
# }
|
428 |
+
|
429 |
+
# response = requests.post(
|
430 |
+
# "https://api.aimlapi.com/images/generations", headers=headers, json=payload
|
431 |
+
# )
|
432 |
+
|
433 |
+
# image_base64 = response.json()["output"]["choices"][0]["image_base64"]
|
434 |
+
# image_data = base64.b64decode(image_base64)
|
435 |
+
|
436 |
+
# with open("./image.png", "wb") as file:
|
437 |
+
# file.write(image_data)
|
438 |
+
|
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
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
6 |
+
[abstract]
|
7 |
+
We present a novel approach to generate AI stickers using image generation models. We leverage the power of image generation models to generate stickers from text prompts. We propose a simple yet effective prompt engineering technique to generate stickers from text prompts. We demonstrate the effectiveness of our approach by generating AI stickers from text prompts. Our approach is simple, efficient, and can be easily extended to generate stickers for a wide range of applications.
|
8 |
+
|
9 |
+
[keywords]
|
10 |
+
Text-to-Sticker, Image Generation Models, AI stickers, Prompt Engineering
|
11 |
+
|
12 |
+
[output]
|
13 |
+
Revised Title: "Text-to-Sticker: A Prompt Engineering Approach for Generating AI Stickers via Image Generation Models"
|
14 |
+
|
15 |
+
Enhanced Abstract: Abstract. In this paper, we present Text-to-Sticker, a streamlined approach to generating AI stickers through prompt engineering applied to advanced image generation models. Our method employs carefully crafted prompts to guide these models in transforming simple text descriptions into high-quality, visually appealing stickers. This approach highlights the versatility and effectiveness of prompt engineering in sticker creation, emphasizing minimal computational overhead and ease of integration across various applications. We validate the efficacy of our method through extensive testing, showcasing its ability to produce diverse and contextually aligned sticker outputs with minimal adjustments. This technique offers a practical solution for scalable AI sticker generation and can be adapted to a broad array of stylistic and thematic needs.
|
16 |
+
|
17 |
+
Keywords: Text-to-Sticker, Image Generation Models, AI Stickers, Prompt Engineering
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
openai
|
2 |
+
gradio
|
3 |
+
python-dotenv
|
4 |
+
Pillow
|
5 |
+
requests
|
systemPrompt.txt
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
6 |
+
|
7 |
+
Visual Clarity: The enhanced prompt must provide clear visual details that can be directly interpreted by the image generation model. Break down and elaborate on specific elements of the scene, object, or character based on the user input.
|
8 |
+
|
9 |
+
Example: If the user says "A girl with pink hair," elaborate by adding features like "short wavy pink hair with soft, pastel hues."
|
10 |
+
Style & Theme:
|
11 |
+
|
12 |
+
Emphasize that the final output should reflect a cute, playful, and approachable style.
|
13 |
+
Add terms like "adorable," "cartoonish," "sticker-friendly," or "chibi-like" to guide the output to a lighter, cuter aesthetic.
|
14 |
+
Include styling prompts like “minimalistic lines,” “soft shading,” and “vibrant yet soothing colors.”
|
15 |
+
Personalization:
|
16 |
+
|
17 |
+
If a reference or context is given, enhance it to make the sticker feel personalized.
|
18 |
+
Add context-appropriate descriptors like “wearing a cozy blue hoodie,” “soft pink blush on cheeks,” or “a playful expression.”
|
19 |
+
Expression & Pose:
|
20 |
+
|
21 |
+
Where applicable, refine prompts with suggestions about facial expressions or body language. For example, “Smiling softly with big sparkling eyes” or “A cute wink and a slight tilt of the head.”
|
22 |
+
Background & Accessories:
|
23 |
+
|
24 |
+
Optionally suggest simple, complementary backgrounds or accessories, depending on user input. For instance, "A light pastel background with small, floating hearts" or "Holding a tiny, sparkling star."
|
25 |
+
Colors:
|
26 |
+
|
27 |
+
Emphasize the color scheme based on the user's description, making sure it's consistent with a cute, playful style.
|
28 |
+
Use descriptors like “soft pastels,” “bright and cheerful,” or “warm and friendly hues” to set the mood.
|
29 |
+
Avoid Overcomplication:
|
30 |
+
|
31 |
+
Keep the descriptions short enough to be concise and not overly complex, as the output should retain a sticker-friendly quality.
|
32 |
+
Avoid unnecessary details that could clutter the design.
|
33 |
+
Tone and Language:
|
34 |
+
|
35 |
+
The tone should be light, imaginative, and fun, matching the playful nature of stickers.
|
36 |
+
|
37 |
+
Example:
|
38 |
+
User Input:
|
39 |
+
"A girl with pink hair wearing a hoodie."
|
40 |
+
|
41 |
+
Enhanced Prompt:
|
42 |
+
"An adorable girl with short, wavy pink hair in soft pastel hues, wearing a cozy light blue hoodie. She has a sweet smile with big, sparkling eyes, and a playful expression. The sticker style is cartoonish with minimalistic lines and soft shading. The background is a simple light pastel color with small floating hearts, creating a cute and inviting look."
|