Severian commited on
Commit
55774a1
·
verified ·
1 Parent(s): 5cca4db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -46
app.py CHANGED
@@ -34,8 +34,8 @@ controlnet = ControlNetModel.from_pretrained(
34
  ).to("cuda")
35
 
36
  pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
37
- #"digiplay/GhostMixV1.2VAE",
38
- "benjamin-paine/stable-diffusion-v1-5",
39
  controlnet = controlnet,
40
  torch_dtype = torch.float16,
41
  safety_checker = None,
@@ -196,21 +196,29 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as blocks:
196
  init_image = gr.Image(label="Init Image (Optional). Leave blank to generate image with AI", type="pil")
197
 
198
 
199
- with gr.Accordion("Advanced Artistic Controls", open=True):
 
200
  controlnet_conditioning_scale = gr.Slider(
201
  minimum=0.0,
202
  maximum=5.0,
203
  step=0.01,
204
- value=1.1,
205
  label="QR Code Visibility",
206
  )
207
  gr.Markdown(
208
- """Balance between QR code clarity and artistic integration:
209
- - Lower (0.0-0.5): Subtle, may be hard to scan
210
- - Middle (0.6-1.5): Good blend of art and function
211
- - Higher (1.6-5.0): Very clear QR code, less artistic freedom
212
- - Start at 1.1 and adjust to find your perfect balance."""
 
 
 
 
 
 
213
  )
 
214
  strength = gr.Slider(
215
  minimum=0.0,
216
  maximum=1.0,
@@ -219,38 +227,57 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as blocks:
219
  label="Artistic Freedom",
220
  )
221
  gr.Markdown(
222
- """Controls how much the AI can alter the QR code:
223
- - Lower (0.0-0.3): Minimal changes, closer to standard QR
224
- - Middle (0.4-0.7): Balanced artistic elements
225
- - Higher (0.8-1.0): Maximum creativity, may affect scannability
226
- - Begin with 0.9 for a creative yet functional result."""
 
 
 
 
227
  )
 
228
  guidance_scale = gr.Slider(
229
  minimum=0.0,
230
  maximum=50.0,
231
  step=0.25,
232
  value=7.5,
233
- label="Prompt Adherence",
234
  )
235
  gr.Markdown(
236
- """Determines how closely the AI follows your prompt:
237
- - Lower (0-5): More AI creativity, less prompt influence
238
- - Middle (5-15): Balanced between prompt and AI interpretation
239
- - Higher (15+): Strictly follows prompt, less variation
240
- - Start at 7.5 and adjust based on your desired outcome."""
 
 
 
 
 
 
241
  )
 
242
  sampler = gr.Dropdown(
243
  choices=list(SAMPLER_MAP.keys()),
244
  value="DPM++ Karras SDE",
245
- label="Image Generation Technique",
246
  )
247
  gr.Markdown(
248
- """Different methods for creating your QR art:
249
- - DPM++ Karras SDE: Versatile, high-quality results
250
- - Euler: Sharp, detailed images
251
- - DDIM: Good for abstract or artistic styles
252
- - Experiment to find what works best for your vision!"""
 
 
 
 
 
 
253
  )
 
254
  seed = gr.Slider(
255
  minimum=-1,
256
  maximum=9999999999,
@@ -260,27 +287,17 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as blocks:
260
  randomize=False,
261
  )
262
  gr.Markdown(
263
- """Controls the randomness in art creation:
264
- - -1: New, unique creation each time
265
- - Any other number: Recreates the same image consistently
266
- - Use -1 to explore, or set a specific number to refine a design you like.""",
 
 
 
 
 
267
  )
268
- with gr.Row():
269
- run_btn = gr.Button("🎨 Create Your QR Art", variant="primary")
270
- with gr.Column():
271
- result_image = gr.Image(label="Your Artistic QR Code")
272
- gr.Markdown(
273
- """
274
- ### 🔍 Analyzing Your Creation
275
- - Is the QR code scannable? Test it with your phone's camera.
276
- - Does the art style match your prompt? If not, try adjusting the 'Prompt Adherence'.
277
- - Want more artistic flair? Increase the 'Artistic Freedom'.
278
- - Need a clearer QR code? Raise the 'QR Code Visibility'.
279
-
280
- Remember, creating the perfect QR art is a journey of experimentation and refinement.
281
- Enjoy the process of bringing your unique vision to life!
282
- """
283
- )
284
  run_btn.click(
285
  inference,
286
  inputs=[
 
34
  ).to("cuda")
35
 
36
  pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
37
+ "digiplay/GhostMixV1.2VAE",
38
+ #"benjamin-paine/stable-diffusion-v1-5",
39
  controlnet = controlnet,
40
  torch_dtype = torch.float16,
41
  safety_checker = None,
 
196
  init_image = gr.Image(label="Init Image (Optional). Leave blank to generate image with AI", type="pil")
197
 
198
 
199
+ with gr.Accordion("Advanced Art Controls", open=True):
200
+
201
  controlnet_conditioning_scale = gr.Slider(
202
  minimum=0.0,
203
  maximum=5.0,
204
  step=0.01,
205
+ value=1.3,
206
  label="QR Code Visibility",
207
  )
208
  gr.Markdown(
209
+ """
210
+ **QR Code Visibility** determines how much the QR code itself stands out in the final design. Think of it like balancing between how "artistic" the image looks and how "functional" the QR code is.
211
+
212
+ - **Low settings (0.0-0.5)**: If you choose a lower value, the QR code will blend more into the art, and it might be hard to scan with a phone. This setting is great if you want the image to look amazing, but you might lose some of the scannability. Try this if you care more about art and less about the QR code being easily recognized.
213
+
214
+ - **Medium settings (0.6-1.5)**: This is the sweet spot where the QR code remains clearly visible while still blending in with the art. You can still scan it easily with a phone, but it looks more creative. For most users, setting it around **1.1** is a great start to balance both art and function.
215
+
216
+ - **High settings (1.6-5.0)**: If you need to make sure that the QR code is super easy to scan, even if it means the image looks less like art and more like a regular QR code, then choose a higher value. This is ideal when functionality is the main goal, and the artistic side can take a backseat.
217
+
218
+ Start with **1.3** if you’re unsure, and adjust up or down depending on whether you want the QR code to be more artistic or more functional.
219
+ """
220
  )
221
+
222
  strength = gr.Slider(
223
  minimum=0.0,
224
  maximum=1.0,
 
227
  label="Artistic Freedom",
228
  )
229
  gr.Markdown(
230
+ """
231
+ **Artistic Freedom** controls how much the AI is allowed to change the QR code's look to match your description. It’s like telling the AI how creative it can get with your QR code:
232
+
233
+ - **Low settings (0.0-0.3)**: If you set this low, the AI will make small changes and your QR code will look more like a regular, plain QR code. This is useful if you want something that is still creative but not too wild, keeping it simple and easy to scan.
234
+
235
+ - **Medium settings (0.4-0.7)**: Here, the AI will add more artistic touches but keep the QR code recognizable. You get the best of both worlds—your QR code will have some creative flair, but it will still be easy to scan. For most cases, setting it to **0.6** is a great way to keep the code functional and artistic.
236
+
237
+ - **High settings (0.8-1.0)**: If you set this high, the AI will go all-out creative. The QR code will look amazing, but it might be difficult to scan because the art can start to take over the code. This setting is perfect if you’re aiming for a highly creative piece of art and don’t mind if it’s a bit harder to scan. Start at **0.9** to explore creative but functional designs.
238
+ """
239
  )
240
+
241
  guidance_scale = gr.Slider(
242
  minimum=0.0,
243
  maximum=50.0,
244
  step=0.25,
245
  value=7.5,
246
+ label="Follow the Prompt",
247
  )
248
  gr.Markdown(
249
+ """
250
+ **Follow the Prompt** tells the AI how closely it should follow your description when creating the QR code art. Think of it like giving the AI instructions on how strict or flexible it can be with your design ideas:
251
+
252
+ - **Low settings (0-5)**: If you choose a lower value, the AI has more freedom to get creative on its own and may not stick too closely to your description. This is great if you want to see how the AI interprets your ideas in unexpected ways.
253
+
254
+ - **Medium settings (5-15)**: This is a good balance where the AI will mostly follow your prompt but will also add some of its own creative touches. If you want to see some surprises but still want the design to look like what you described, start at around **7.5**.
255
+
256
+ - **High settings (15+)**: If you choose a higher value, the AI will stick very closely to what you wrote in the description. This is good if you have a very specific idea and don’t want the AI to change much. Just keep in mind that this might limit the AI’s creativity.
257
+
258
+ Start at **7.5** for a balanced approach where the AI follows your ideas but still adds some artistic flair.
259
+ """
260
  )
261
+
262
  sampler = gr.Dropdown(
263
  choices=list(SAMPLER_MAP.keys()),
264
  value="DPM++ Karras SDE",
265
+ label="Art Style",
266
  )
267
  gr.Markdown(
268
+ """
269
+ **Art Style** changes how the AI creates the image, using different methods (or "samplers"). Each method has a different effect on how detailed or artistic the final QR code looks:
270
+
271
+ - **DPM++ Karras SDE**: This is a great all-around option for creating high-quality, detailed images. It’s a good place to start if you want a balance of sharpness and creativity.
272
+
273
+ - **Euler**: This method creates very sharp, detailed images, making the QR code look crisp and clear. Choose this if you want a precise, well-defined design.
274
+
275
+ - **DDIM**: This method is better if you want the QR code to have a more artistic, abstract style. It’s great for when you want the QR code to look like a piece of modern art.
276
+
277
+ Feel free to experiment with different samplers to see what works best for the look you’re going for!
278
+ """
279
  )
280
+
281
  seed = gr.Slider(
282
  minimum=-1,
283
  maximum=9999999999,
 
287
  randomize=False,
288
  )
289
  gr.Markdown(
290
+ """
291
+ **Creative Seed** controls whether the AI creates a completely new design each time or sticks to a specific design. Think of it like a recipe: with the same seed number, you get the same "recipe" for your QR code every time.
292
+
293
+ - **-1**: This setting makes the AI create something completely new every time you run it. Use this if you want to explore different design ideas with each attempt.
294
+
295
+ - **Any other number**: If you set a specific number, the AI will always create the same image based on that number. This is useful if you find a design you like and want to recreate it exactly.
296
+
297
+ Try **-1** if you want to explore and generate different designs. If you find something you really love, write down the seed number and use it again to recreate the same design.
298
+ """
299
  )
300
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  run_btn.click(
302
  inference,
303
  inputs=[