Severian commited on
Commit
c69d322
Β·
verified Β·
1 Parent(s): 8a823d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +88 -33
app.py CHANGED
@@ -118,7 +118,7 @@ def inference(
118
  controlnet_conditioning_scale=float(controlnet_conditioning_scale), # type: ignore
119
  generator=generator,
120
  strength=float(strength),
121
- num_inference_steps=40,
122
  )
123
  return out.images[0] # type: ignore
124
 
@@ -126,30 +126,42 @@ def inference(
126
  with gr.Blocks() as blocks:
127
  gr.Markdown(
128
  """
129
- # Yamamoto QR Code Art Generator
130
 
131
- ## 🎨 Elevate Your Brand with Creative QR Codes
132
 
133
- Welcome to Yamamoto's QR Code Art Generator, a powerful tool designed for our creative team to produce
134
- stunning, on-brand QR codes that seamlessly blend functionality with artistic expression.
135
 
136
- ### How it works:
137
- We use cutting-edge AI technology to transform ordinary QR codes into visual masterpieces that align with your campaign's aesthetic.
138
- The QR code serves as both the initial image and the control image, allowing for natural integration with your provided prompt.
 
 
139
 
140
- ### Tips for optimal results:
141
- - Use a strength value between 0.8 and 0.95
142
- - Choose a conditioning scale between 0.6 and 2.0
143
- - Experiment with prompts that reflect your campaign's theme or brand identity
144
- """
 
 
 
 
 
 
 
 
 
 
145
  )
146
 
147
  with gr.Row():
148
  with gr.Column():
149
  qr_code_content = gr.Textbox(
150
  label="QR Code Content",
151
- info="QR Code Content or URL",
152
- value="https://www.go-yamamoto.com",
153
  )
154
  with gr.Accordion(label="QR Code Image (Optional)", open=False):
155
  qr_code_image = gr.Image(
@@ -158,13 +170,15 @@ The QR code serves as both the initial image and the control image, allowing for
158
  )
159
 
160
  prompt = gr.Textbox(
161
- label="Prompt",
162
- info="Prompt that guides the generation towards",
163
- value="A futuristic cityscape with neon lights",
164
  )
165
  negative_prompt = gr.Textbox(
166
- label="Negative Prompt",
 
167
  value="ugly, disfigured, low quality, blurry, nsfw",
 
168
  )
169
  use_qr_code_as_init_image = gr.Checkbox(
170
  label="Use QR code as init image",
@@ -173,43 +187,84 @@ The QR code serves as both the initial image and the control image, allowing for
173
  info="Whether init image should be QR code. Unclick to pass init image or generate init image with Stable Diffusion 2.1"
174
  )
175
  with gr.Accordion(label="Init Images (Optional)", open=False, visible=False) as init_image_acc:
176
- init_image = gr.Image(label="Init Image (Optional). Leave blank to generate image with SD 2.1", type="pil")
177
 
178
 
179
- with gr.Accordion(
180
- label="Params: The generated QR Code functionality is largely influenced by the parameters detailed below",
181
- open=True,
182
- ):
183
  controlnet_conditioning_scale = gr.Slider(
184
  minimum=0.0,
185
  maximum=5.0,
186
  step=0.01,
187
  value=1.1,
188
- label="Controlnet Conditioning Scale",
 
 
 
 
 
189
  )
190
  strength = gr.Slider(
191
- minimum=0.0, maximum=1.0, step=0.01, value=0.9, label="Strength"
 
 
 
 
 
 
 
 
 
192
  )
193
  guidance_scale = gr.Slider(
194
  minimum=0.0,
195
  maximum=50.0,
196
  step=0.25,
197
  value=7.5,
198
- label="Guidance Scale",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  )
200
- sampler = gr.Dropdown(choices=list(SAMPLER_MAP.keys()), value="DPM++ Karras SDE", label="Sampler")
201
  seed = gr.Slider(
202
  minimum=-1,
203
  maximum=9999999999,
204
  step=1,
205
  value=-1,
206
- label="Seed",
207
- randomize=True,
 
 
 
 
208
  )
209
  with gr.Row():
210
- run_btn = gr.Button("Run")
211
  with gr.Column():
212
- result_image = gr.Image(label="Result Image")
 
 
 
 
 
 
 
 
 
 
 
 
213
  run_btn.click(
214
  inference,
215
  inputs=[
@@ -226,7 +281,7 @@ The QR code serves as both the initial image and the control image, allowing for
226
  sampler,
227
  ],
228
  outputs=[result_image],
229
- concurrency_limit=1
230
  )
231
 
232
  gr.Examples(
 
118
  controlnet_conditioning_scale=float(controlnet_conditioning_scale), # type: ignore
119
  generator=generator,
120
  strength=float(strength),
121
+ num_inference_steps=50,
122
  )
123
  return out.images[0] # type: ignore
124
 
 
126
  with gr.Blocks() as blocks:
127
  gr.Markdown(
128
  """
129
+ # 🎨 Yamamoto QR Code Art Generator
130
 
131
+ ## Transform Your QR Codes into Brand Masterpieces
132
 
133
+ Welcome to Yamamoto's innovative QR Code Art Generator! This cutting-edge tool empowers our creative team to craft
134
+ visually stunning, on-brand QR codes that perfectly blend functionality with artistic expression.
135
 
136
+ ### πŸš€ How It Works:
137
+ 1. **Enter Your QR Code Content**: Start by inputting the URL or text for your QR code.
138
+ 2. **Craft Your Prompt**: Describe the artistic style or theme you envision for your QR code.
139
+ 3. **Fine-tune with Advanced Settings**: Adjust parameters to perfect your creation (see tips below).
140
+ 4. **Generate and Iterate**: Click 'Run' to create your art, then refine as needed.
141
 
142
+ ### 🌟 Tips for Spectacular Results:
143
+ - **Artistic Freedom**: Set between 0.8 and 0.95 for a balance of creativity and scannability.
144
+ - **QR Code Visibility**: Aim for 0.6 to 2.0 to ensure your code is both artistic and functional.
145
+ - **Prompt Crafting**: Use vivid, specific descriptions that align with your brand identity.
146
+ - **Experimentation**: Don't hesitate to try different settings and prompts to find your perfect style!
147
+
148
+ ### 🎭 Prompt Ideas to Spark Your Creativity:
149
+ - "A serene Japanese garden with cherry blossoms and a koi pond"
150
+ - "A futuristic cityscape with neon lights and flying cars"
151
+ - "An abstract painting with swirling colors and geometric shapes"
152
+ - "A vintage-style travel poster featuring iconic landmarks"
153
+
154
+ Remember, the magic lies in the details of your prompt and the fine-tuning of your settings.
155
+ Happy creating!
156
+ """
157
  )
158
 
159
  with gr.Row():
160
  with gr.Column():
161
  qr_code_content = gr.Textbox(
162
  label="QR Code Content",
163
+ placeholder="Enter URL or text for your QR code",
164
+ info="This is what your QR code will link to or display when scanned.",
165
  )
166
  with gr.Accordion(label="QR Code Image (Optional)", open=False):
167
  qr_code_image = gr.Image(
 
170
  )
171
 
172
  prompt = gr.Textbox(
173
+ label="Artistic Prompt",
174
+ placeholder="Describe the style or theme for your QR code art",
175
+ info="Be specific and creative! This guides the AI in creating your unique QR art.",
176
  )
177
  negative_prompt = gr.Textbox(
178
+ label="Elements to Avoid",
179
+ placeholder="Describe what you don't want in the image",
180
  value="ugly, disfigured, low quality, blurry, nsfw",
181
+ info="List elements or styles you want to avoid in your QR code art.",
182
  )
183
  use_qr_code_as_init_image = gr.Checkbox(
184
  label="Use QR code as init image",
 
187
  info="Whether init image should be QR code. Unclick to pass init image or generate init image with Stable Diffusion 2.1"
188
  )
189
  with gr.Accordion(label="Init Images (Optional)", open=False, visible=False) as init_image_acc:
190
+ init_image = gr.Image(label="Init Image (Optional). Leave blank to generate image with AI", type="pil")
191
 
192
 
193
+ with gr.Accordion("Advanced Artistic Controls", open=False):
 
 
 
194
  controlnet_conditioning_scale = gr.Slider(
195
  minimum=0.0,
196
  maximum=5.0,
197
  step=0.01,
198
  value=1.1,
199
+ label="QR Code Visibility",
200
+ info="""Balance between QR code clarity and artistic integration:
201
+ β€’ Lower (0.0-0.5): Subtle, may be hard to scan
202
+ β€’ Middle (0.6-1.5): Good blend of art and function
203
+ β€’ Higher (1.6-5.0): Very clear QR code, less artistic freedom
204
+ Start at 1.1 and adjust to find your perfect balance."""
205
  )
206
  strength = gr.Slider(
207
+ minimum=0.0,
208
+ maximum=1.0,
209
+ step=0.01,
210
+ value=0.9,
211
+ label="Artistic Freedom",
212
+ info="""Controls how much the AI can alter the QR code:
213
+ β€’ Lower (0.0-0.3): Minimal changes, closer to standard QR
214
+ β€’ Middle (0.4-0.7): Balanced artistic elements
215
+ β€’ Higher (0.8-1.0): Maximum creativity, may affect scannability
216
+ Begin with 0.9 for a creative yet functional result."""
217
  )
218
  guidance_scale = gr.Slider(
219
  minimum=0.0,
220
  maximum=50.0,
221
  step=0.25,
222
  value=7.5,
223
+ label="Prompt Adherence",
224
+ info="""Determines how closely the AI follows your prompt:
225
+ β€’ Lower (0-5): More AI creativity, less prompt influence
226
+ β€’ Middle (5-15): Balanced between prompt and AI interpretation
227
+ β€’ Higher (15+): Strictly follows prompt, less variation
228
+ Start at 7.5 and adjust based on your desired outcome."""
229
+ )
230
+ sampler = gr.Dropdown(
231
+ choices=list(SAMPLER_MAP.keys()),
232
+ value="DPM++ Karras SDE",
233
+ label="Image Generation Technique",
234
+ info="""Different methods for creating your QR art:
235
+ β€’ DPM++ Karras SDE: Versatile, high-quality results
236
+ β€’ Euler: Sharp, detailed images
237
+ β€’ DDIM: Good for abstract or artistic styles
238
+ Experiment to find what works best for your vision!"""
239
  )
 
240
  seed = gr.Slider(
241
  minimum=-1,
242
  maximum=9999999999,
243
  step=1,
244
  value=-1,
245
+ label="Creative Seed",
246
+ info="""Controls the randomness in art creation:
247
+ β€’ -1: New, unique creation each time
248
+ β€’ Any other number: Recreates the same image consistently
249
+ Use -1 to explore, or set a specific number to refine a design you like.""",
250
+ randomize=False,
251
  )
252
  with gr.Row():
253
+ run_btn = gr.Button("🎨 Create Your QR Art", variant="primary")
254
  with gr.Column():
255
+ result_image = gr.Image(label="Your Artistic QR Code")
256
+ gr.Markdown(
257
+ """
258
+ ### πŸ” Analyzing Your Creation
259
+ - Is the QR code scannable? Test it with your phone's camera.
260
+ - Does the art style match your prompt? If not, try adjusting the 'Prompt Adherence'.
261
+ - Want more artistic flair? Increase the 'Artistic Freedom'.
262
+ - Need a clearer QR code? Raise the 'QR Code Visibility'.
263
+
264
+ Remember, creating the perfect QR art is a journey of experimentation and refinement.
265
+ Enjoy the process of bringing your unique vision to life!
266
+ """
267
+ )
268
  run_btn.click(
269
  inference,
270
  inputs=[
 
281
  sampler,
282
  ],
283
  outputs=[result_image],
284
+ concurrency_limit=20
285
  )
286
 
287
  gr.Examples(