jejunepixels commited on
Commit
f29b108
·
verified ·
1 Parent(s): fc15318

Build prompt-free diffusion drawing canvas

Browse files
Files changed (2) hide show
  1. README.md +6 -3
  2. app.py +85 -53
README.md CHANGED
@@ -15,9 +15,12 @@ hf_oauth: true
15
 
16
  A prompt-free evolving diffusion canvas. The welcome page contains Hugging Face
17
  sign-in, model selection, and Start drawing. Starting hides the welcome page and
18
- shows the canvas. The explanation is visible directly below the generation canvas. Controls,
19
- history, and downloads are inside Options, collapsed by default. The interface
20
- uses the same high-contrast dark palette in both browser color modes. New start image immediately starts
 
 
 
21
  from fresh random noise using the same model. Change model / sign in pauses and
22
  returns to the welcome page.
23
 
 
15
 
16
  A prompt-free evolving diffusion canvas. The welcome page contains Hugging Face
17
  sign-in, model selection, and Start drawing. Starting hides the welcome page and
18
+ shows the canvas. The drawing stage fills the viewport. Its midnight blue background, amber
19
+ accents, serif welcome heading, and floating pale mint dock match Let It Flow.
20
+ Resume, Pause, and step controls stay visible in the dock. Other controls,
21
+ history, and downloads are inside Options, collapsed by default. The explanation
22
+ is in an expandable About this drawing panel on the generation page. Both browser
23
+ color modes use the same readable palette. New start image immediately starts
24
  from fresh random noise using the same model. Change model / sign in pauses and
25
  returns to the welcome page.
26
 
app.py CHANGED
@@ -283,79 +283,111 @@ def export(session):
283
 
284
 
285
  CSS = """
286
- body,.gradio-container {background:#101310 !important;color:#e7eadd !important}
287
- .gradio-container {max-width:1100px !important;margin:auto}
288
- #canvas {background:#151b15;border:1px solid #303b2b;border-radius:18px}
289
- #canvas img {object-fit:contain !important}
290
- #title {text-align:center;padding:20px 0 4px}
291
- #welcome {max-width:650px !important;margin:8vh auto 0 !important;gap:18px}
292
- #experience {gap:10px}
293
- #canvas {height:calc(100vh - 150px);min-height:350px;max-height:850px}
294
- #explanation {padding:16px 20px;background:#1b211a;border:1px solid #3c4935;border-radius:12px}
295
- .gradio-container .prose, .gradio-container .prose p,
296
- .gradio-container .prose h1, .gradio-container .prose h2,
297
- .gradio-container .prose h3, .gradio-container .prose strong {color:#edf1e6 !important}
298
  footer {display:none !important}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  """
300
  # Set both palettes so browser light/dark preferences cannot invert only part of the UI.
301
  PALETTE = {
302
- "body_background_fill": "#101310", "body_text_color": "#edf1e6",
303
- "body_text_color_subdued": "#c4cfbb", "background_fill_primary": "#1b211a",
304
- "background_fill_secondary": "#232c20", "block_background_fill": "#1b211a",
305
- "block_border_color": "#3c4935", "block_label_background_fill": "#1b211a",
306
- "block_label_text_color": "#edf1e6", "block_title_text_color": "#edf1e6",
307
- "block_info_text_color": "#c4cfbb", "panel_background_fill": "#1b211a",
308
- "input_background_fill": "#232c20", "input_background_fill_hover": "#2d3828",
309
- "input_background_fill_focus": "#232c20", "input_placeholder_color": "#c4cfbb",
310
- "accordion_text_color": "#edf1e6", "border_color_primary": "#3c4935",
311
- "button_primary_background_fill": "#c2d69b", "button_primary_background_fill_hover": "#d2e4b0",
312
- "button_primary_text_color": "#17200e", "button_primary_text_color_hover": "#17200e",
313
- "button_secondary_background_fill": "#2d3828", "button_secondary_background_fill_hover": "#3c4935",
314
- "button_secondary_text_color": "#edf1e6", "button_secondary_text_color_hover": "#ffffff",
315
- "link_text_color": "#c2d69b", "link_text_color_hover": "#e2f0cd",
316
  }
317
- THEME = gr.themes.Soft().set(**{key + suffix: value for key, value in PALETTE.items()
318
  for suffix in ("", "_dark")})
319
  with gr.Blocks(title="Automatic Drawing") as demo:
320
  state = gr.State(Session())
321
  timer = gr.Timer(.5, active=False)
322
  with gr.Column(visible=True, elem_id="welcome") as welcome:
323
- gr.Markdown("# Automatic Drawing\n### Watch an image find its own way.", elem_id="title")
324
- gr.Markdown("Start with random noise and watch a diffusion model turn it into an image. The image then becomes the starting point for the next cycle, continually changing without a written prompt.")
325
  gr.LoginButton()
326
- gr.HTML('<a href="https://jejunepixels-automatic-drawing.hf.space/" target="_blank" rel="noopener noreferrer" style="color:#c2d69b;text-decoration:underline">Open the standalone app directly</a>')
327
  gr.Markdown("Sign in opens the app in a new tab so your login cookie can be saved. Complete sign-in and use the drawing there. Your personal ZeroGPU quota applies. This Space remains private.")
328
  model = gr.Dropdown(choices=[("SD-Turbo - faster", "stabilityai/sd-turbo"),
329
  ("SDXL-Turbo - larger model", "stabilityai/sdxl-turbo")],
330
  value="stabilityai/sd-turbo", label="Choose your model")
331
- begin = gr.Button("Start drawing", variant="primary", size="lg")
332
  gr.Markdown("**What you will see:** noise appears, forms emerge as noise is removed, then the finished image is reinterpreted. There are no hidden subject or style instructions. The model's learned visual patterns guide what appears.")
333
  with gr.Column(visible=False, elem_id="experience") as experience:
334
  canvas = gr.Image(label="Living canvas", show_label=False, interactive=False,
335
  height=640, elem_id="canvas", type="pil")
336
- status = gr.Markdown("Ready.")
337
- with gr.Row():
338
- previous = gr.Button("Step back")
339
- following = gr.Button("Step forward")
340
- gr.Markdown('### What is happening?\nThe first image begins as random noise. The model removes noise in a few steps, drawing on patterns learned during training. Each later cycle takes the previous image, adds fresh noise, and removes it again to produce a variation. Every text prompt is empty.\n\nThe canvas shows decoded views of the actual internal image states: before noise, after noise is added, and after each denoising step. Stages play after a cycle has been computed. Brief holds between cycles come from processing and the shared GPU queue. Generation continues until you pause or reach your GPU quota.', elem_id="explanation")
341
- with gr.Accordion("Options", open=False):
342
- with gr.Row():
343
- resume = gr.Button("Resume", variant="primary")
344
  pause = gr.Button("Pause")
345
- fresh = gr.Button("New start image")
346
- noise_button = gr.Button("Change noise")
347
- back = gr.Button("Change model / sign in")
348
- with gr.Row():
349
- drift = gr.Slider(.25, 1, value=.75, step=.25, label="Drift",
350
- info="Lower values preserve more of the previous image; higher values allow bigger changes. Applies next cycle.")
351
- pace = gr.Slider(.15, 1.5, value=.5, step=.05, label="Seconds per stage",
352
- info="How long each stage stays on screen. This changes playback speed.")
353
- gr.Markdown('**Change noise** picks a new random starting noise and pauses so you can inspect it; press Resume to generate from it. **New start image** starts from new noise and runs automatically. **Step back / Step forward** pause playback and browse the last 64 recorded noise and denoising stages. Browsing does not change generation; Resume continues from the latest completed image. **Change model / sign in** returns to the start page and pauses generation.')
354
- gallery = gr.Gallery(label="Last 32 completed images", columns=8, height=220)
355
- download = gr.Button("Prepare downloads")
356
- with gr.Row():
357
- png = gr.File(label="Current image")
358
- gif = gr.File(label="Evolution animation")
 
 
 
 
359
  outputs = [canvas, gallery, status]
360
  begin.click(enter_canvas, [state, model],
361
  [welcome, experience, canvas, gallery, status, timer, png, gif],
 
283
 
284
 
285
  CSS = """
286
+ body,.gradio-container {background:#080f18 !important;color:#eef3f5 !important}
287
+ .gradio-container {max-width:none !important;min-height:100dvh !important;--color-accent:#f4bf67;--color-accent-soft:#f4bf6726}
 
 
 
 
 
 
 
 
 
 
288
  footer {display:none !important}
289
+ #welcome {max-width:680px !important;margin:7vh auto !important;padding:24px !important;gap:18px !important}
290
+ #welcome header {padding:12px 0 10px}
291
+ .eyebrow {font:600 11px/1.5 system-ui,sans-serif;letter-spacing:.18em;color:#f4bf67}
292
+ #welcome h1 {font:400 clamp(42px,6vw,66px)/1.06 Georgia,serif;letter-spacing:-.04em;margin:14px 0 20px;color:#eef3f5}
293
+ .title-stop {color:#f4bf67}
294
+ #welcome header p {font:16px/1.75 system-ui,sans-serif;color:#b8cbd1;margin:0}
295
+ #welcome .prose {color:#b8cbd1}
296
+ #welcome a {color:#f4bf67 !important}
297
+ #begin-drawing {min-height:48px;font-weight:600}
298
+ #experience {position:fixed !important;inset:0 !important;width:100vw !important;height:100dvh !important;margin:0 !important;padding:0 !important;gap:0 !important;overflow:hidden !important;background:#080f18;z-index:50}
299
+ #canvas {position:absolute !important;inset:0 !important;width:100% !important;height:100% !important;min-height:0 !important;border:0 !important;border-radius:0 !important;background:#080f18 !important;padding:64px 16px 165px !important;box-sizing:border-box}
300
+ #canvas > div {height:100% !important;min-height:0 !important;background:transparent !important}
301
+ #canvas img {width:100% !important;height:100% !important;object-fit:contain !important;border-radius:0 !important}
302
+ #drawing-caption {position:absolute !important;top:18px;left:clamp(16px,4vw,60px);right:16px;z-index:2;background:transparent;border:0;padding:0;color:#c5e2dd}
303
+ #drawing-caption .prose {color:#c5e2dd !important;font:12px/1.5 system-ui,sans-serif}
304
+ #drawing-caption strong {color:#f4bf67 !important}
305
+ #drawing-caption .prose p {white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0}
306
+ #about-drawing {position:absolute !important;top:48px;left:clamp(16px,4vw,60px);width:min(440px,calc(100vw - 32px)) !important;max-height:55dvh;overflow:auto;z-index:3;background:#091622ed !important;border:1px solid #78949d45 !important;border-radius:14px;backdrop-filter:blur(14px);color:#d5e3e6;--block-title-text-color:#d5e3e6;--accordion-text-color:#d5e3e6}
307
+ #about-drawing .prose {color:#d5e3e6 !important;font-size:13px;line-height:1.65}
308
+ #about-drawing h3 {color:#f4bf67 !important;font-family:Georgia,serif;font-weight:400}
309
+ #control-dock {position:absolute !important;bottom:max(16px,env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);width:min(940px,calc(100vw - 32px)) !important;max-height:65dvh;overflow-y:auto;z-index:5;padding:12px !important;border:1px solid #6d9f9b66 !important;border-radius:18px !important;background:#eaf2eff2 !important;backdrop-filter:blur(18px);box-shadow:0 12px 50px #0006;gap:8px !important;
310
+ --body-text-color:#203c3a;--body-text-color-subdued:#526b68;--block-background-fill:#f4f8f6;--background-fill-primary:#f4f8f6;--background-fill-secondary:#e3ece7;--block-label-background-fill:#f4f8f6;--block-label-text-color:#29433f;--block-title-text-color:#203c3a;--block-info-text-color:#526b68;--input-background-fill:#fff;--input-background-fill-hover:#f4f8f6;--input-background-fill-focus:#fff;--input-text-color:#1c3536;--input-placeholder-color:#526b68;--accordion-text-color:#203c3a;--border-color-primary:#b3c7bd;--block-border-color:#bdcdc5;--button-secondary-background-fill:#f4f8f6;--button-secondary-background-fill-hover:#dce9e1;--button-secondary-text-color:#203c3a;--button-secondary-text-color-hover:#17242b;--link-text-color:#725020;color:#203c3a}
311
+ #control-dock .prose,#control-dock .prose strong {color:#203c3a !important}
312
+ #control-dock button {min-width:0 !important;min-height:42px}
313
+ #transport {flex-wrap:nowrap !important;gap:8px !important;position:sticky;top:0;z-index:6;background:#eaf2ef}
314
+ #transport button {flex:1}
315
+ #resume-drawing {background:#f4bf67 !important;color:#17242b !important;border-color:#f4bf67 !important}
316
+ #resume-drawing:hover,#begin-drawing:hover {background:#e7aa45 !important}
317
+ #options {background:transparent !important;border:0 !important}
318
+ #options > .label-wrap {color:#203c3a !important}
319
+ #control-dock button:focus-visible,#welcome button:focus-visible {outline:3px solid #b77a20 !important;outline-offset:2px}
320
+ @media(max-width:640px){
321
+ #welcome {margin:3vh auto !important;padding:18px !important}
322
+ #canvas {padding:70px 8px 150px !important}
323
+ #drawing-caption {left:12px;top:12px;right:12px}
324
+ #drawing-caption .prose {font-size:10px}
325
+ #about-drawing {left:12px;top:44px;width:calc(100vw - 24px) !important;max-height:45dvh}
326
+ #control-dock {bottom:12px;width:calc(100vw - 24px) !important;padding:8px !important;max-height:60dvh}
327
+ #transport {gap:5px !important}
328
+ #transport button {font-size:12px;padding:8px 5px}
329
+ }
330
  """
331
  # Set both palettes so browser light/dark preferences cannot invert only part of the UI.
332
  PALETTE = {
333
+ "body_background_fill": "#080f18", "body_text_color": "#eef3f5",
334
+ "body_text_color_subdued": "#a8bdc4", "background_fill_primary": "#091622",
335
+ "background_fill_secondary": "#112530", "block_background_fill": "#091622",
336
+ "block_border_color": "#577f89", "block_label_background_fill": "#091622",
337
+ "block_label_text_color": "#eef3f5", "block_title_text_color": "#eef3f5",
338
+ "block_info_text_color": "#a8bdc4", "panel_background_fill": "#091622",
339
+ "input_background_fill": "#112530", "input_background_fill_hover": "#193442",
340
+ "input_background_fill_focus": "#112530", "input_placeholder_color": "#a8bdc4",
341
+ "accordion_text_color": "#eef3f5", "border_color_primary": "#577f89",
342
+ "button_primary_background_fill": "#f4bf67", "button_primary_background_fill_hover": "#e7aa45",
343
+ "button_primary_text_color": "#17242b", "button_primary_text_color_hover": "#17242b",
344
+ "button_secondary_background_fill": "#193442", "button_secondary_background_fill_hover": "#577f89",
345
+ "button_secondary_text_color": "#eef3f5", "button_secondary_text_color_hover": "#ffffff",
346
+ "link_text_color": "#f4bf67", "link_text_color_hover": "#f8d49a",
347
  }
348
+ THEME = gr.themes.Soft(primary_hue="amber", neutral_hue="stone").set(**{key + suffix: value for key, value in PALETTE.items()
349
  for suffix in ("", "_dark")})
350
  with gr.Blocks(title="Automatic Drawing") as demo:
351
  state = gr.State(Session())
352
  timer = gr.Timer(.5, active=False)
353
  with gr.Column(visible=True, elem_id="welcome") as welcome:
354
+ gr.HTML('<header><div class="eyebrow">AN EXPERIMENT IN AUTOMATIC DRAWING</div><h1>Automatic Drawing<span class="title-stop">.</span></h1><p>Inspired by automatic drawing, this experiment lets an image unfold without a written prompt. Begin with noise, watch forms emerge, then see the image become the starting point for something new.</p></header>')
 
355
  gr.LoginButton()
356
+ gr.HTML('<a href="https://jejunepixels-automatic-drawing.hf.space/" target="_blank" rel="noopener noreferrer" style="color:#f4bf67;text-decoration:underline">Open the standalone app directly</a>')
357
  gr.Markdown("Sign in opens the app in a new tab so your login cookie can be saved. Complete sign-in and use the drawing there. Your personal ZeroGPU quota applies. This Space remains private.")
358
  model = gr.Dropdown(choices=[("SD-Turbo - faster", "stabilityai/sd-turbo"),
359
  ("SDXL-Turbo - larger model", "stabilityai/sdxl-turbo")],
360
  value="stabilityai/sd-turbo", label="Choose your model")
361
+ begin = gr.Button("Start drawing", variant="primary", size="lg", elem_id="begin-drawing")
362
  gr.Markdown("**What you will see:** noise appears, forms emerge as noise is removed, then the finished image is reinterpreted. There are no hidden subject or style instructions. The model's learned visual patterns guide what appears.")
363
  with gr.Column(visible=False, elem_id="experience") as experience:
364
  canvas = gr.Image(label="Living canvas", show_label=False, interactive=False,
365
  height=640, elem_id="canvas", type="pil")
366
+ status = gr.Markdown("**Automatic Drawing.** No written prompt. Just the next image.", elem_id="drawing-caption")
367
+ with gr.Accordion("About this drawing", open=False, elem_id="about-drawing"):
368
+ gr.Markdown('### What is happening?\nThe first image begins as random noise. The model removes noise in a few steps, drawing on patterns learned during training. Each later cycle takes the previous image, adds fresh noise, and removes it again to produce a variation. Every text prompt is empty.\n\nThe canvas shows decoded views of the actual internal image states: before noise, after noise is added, and after each denoising step. Stages play after a cycle has been computed. Brief holds between cycles come from processing and the shared GPU queue. Generation continues until you pause or reach your GPU quota.', elem_id="explanation")
369
+ with gr.Column(elem_id="control-dock"):
370
+ with gr.Row(elem_id="transport"):
371
+ resume = gr.Button("Resume", variant="primary", elem_id="resume-drawing")
 
 
372
  pause = gr.Button("Pause")
373
+ previous = gr.Button("Step back")
374
+ following = gr.Button("Step forward")
375
+ with gr.Accordion("Options", open=False, elem_id="options"):
376
+ with gr.Row():
377
+ fresh = gr.Button("New start image")
378
+ noise_button = gr.Button("Change noise")
379
+ back = gr.Button("Change model / sign in")
380
+ with gr.Row():
381
+ drift = gr.Slider(.25, 1, value=.75, step=.25, label="Drift",
382
+ info="Lower values preserve more of the previous image; higher values allow bigger changes. Applies next cycle.")
383
+ pace = gr.Slider(.15, 1.5, value=.5, step=.05, label="Seconds per stage",
384
+ info="How long each stage stays on screen. This changes playback speed.")
385
+ gr.Markdown('**Change noise** picks a new random starting noise and pauses so you can inspect it; press Resume to generate from it. **New start image** starts from new noise and runs automatically. **Step back / Step forward** pause playback and browse the last 64 recorded noise and denoising stages. Browsing does not change generation; Resume continues from the latest completed image. **Change model / sign in** returns to the start page and pauses generation.')
386
+ gallery = gr.Gallery(label="Last 32 completed images", columns=8, height=220)
387
+ download = gr.Button("Prepare downloads")
388
+ with gr.Row():
389
+ png = gr.File(label="Current image")
390
+ gif = gr.File(label="Evolution animation")
391
  outputs = [canvas, gallery, status]
392
  begin.click(enter_canvas, [state, model],
393
  [welcome, experience, canvas, gallery, status, timer, png, gif],