Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import json
|
| 3 |
+
from deforum_engine import DeforumRunner
|
| 4 |
+
|
| 5 |
+
runner = DeforumRunner(device="cpu")
|
| 6 |
+
|
| 7 |
+
def process(prompts_json, neg, frames, width, height,
|
| 8 |
+
z, a, tx, ty, stre, noi,
|
| 9 |
+
fps, steps, cfg, cadence,
|
| 10 |
+
color, border, seed_beh, init_img,
|
| 11 |
+
model, lora, sched):
|
| 12 |
+
try:
|
| 13 |
+
p_dict = json.loads(prompts_json.replace("'", '"'))
|
| 14 |
+
prompts = {int(k): v for k, v in p_dict.items()}
|
| 15 |
+
except Exception as e:
|
| 16 |
+
yield None, None, None, f"JSON Error: {str(e)}"
|
| 17 |
+
return
|
| 18 |
+
|
| 19 |
+
# Pass exactly 21 args + self
|
| 20 |
+
yield from runner.render(
|
| 21 |
+
prompts, neg, int(frames), int(width), int(height),
|
| 22 |
+
z, a, tx, ty, stre, noi,
|
| 23 |
+
int(fps), int(steps), float(cfg), int(cadence),
|
| 24 |
+
color, border, seed_beh, init_img,
|
| 25 |
+
model, lora, sched
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
def stop_gen():
|
| 29 |
+
runner.stop()
|
| 30 |
+
return "Stopping..."
|
| 31 |
+
|
| 32 |
+
css = "#col-container {max_width: 1000px; margin: 0 auto;}"
|
| 33 |
+
|
| 34 |
+
with gr.Blocks() as demo:
|
| 35 |
+
gr.Markdown("# 🌀 Deforum CPU: Full Control")
|
| 36 |
+
|
| 37 |
+
with gr.Row(elem_id="col-container"):
|
| 38 |
+
with gr.Column(scale=1):
|
| 39 |
+
with gr.Accordion("⚙️ Engine", open=False):
|
| 40 |
+
model = gr.Dropdown(label="Model", value="IDKiro/sdxs-512-dreamshaper",
|
| 41 |
+
choices=["IDKiro/sdxs-512-dreamshaper", "AlekseyCalvin/acs_model", "runwayml/stable-diffusion-v1-5"])
|
| 42 |
+
lora = gr.Dropdown(label="LoRA", value="None",
|
| 43 |
+
choices=["latent-consistency/lcm-lora-sdv1-5", "None"])
|
| 44 |
+
sched = gr.Dropdown(label="Sampler", value="Euler A",
|
| 45 |
+
choices=["LCM", "Euler A", "DDIM", "DPM++ 2M"])
|
| 46 |
+
seed_beh = gr.Dropdown(label="Seed Behavior", value="fixed", choices=["iter", "fixed", "random"])
|
| 47 |
+
init_img = gr.Image(label="Init Image", type="pil", height=200)
|
| 48 |
+
|
| 49 |
+
prompts = gr.Code(label="Prompts (JSON)", language="json",
|
| 50 |
+
value='{\n "0": "a simple black line drawing of a cat, white background",\n "30": "a simple black line drawing of a dog, white background"\n}')
|
| 51 |
+
neg = gr.Textbox(label="Negative Prompt", value="complex, realistic, photo, blur")
|
| 52 |
+
|
| 53 |
+
with gr.Row():
|
| 54 |
+
frames = gr.Number(label="Frames", value=60)
|
| 55 |
+
fps = gr.Number(label="FPS", value=12)
|
| 56 |
+
|
| 57 |
+
with gr.Row():
|
| 58 |
+
width = gr.Slider(256, 512, value=256, step=64, label="Width")
|
| 59 |
+
height = gr.Slider(256, 512, value=256, step=64, label="Height")
|
| 60 |
+
|
| 61 |
+
with gr.Row():
|
| 62 |
+
steps = gr.Slider(1, 50, value=3, step=1, label="Steps")
|
| 63 |
+
cfg = gr.Slider(0.0, 20.0, value=1.0, step=0.1, label="CFG Scale (0-2 for SDXS/LCM)")
|
| 64 |
+
cadence = gr.Slider(1, 8, value=1, step=1, label="Cadence")
|
| 65 |
+
|
| 66 |
+
with gr.Accordion("🎬 Motion & Coherence", open=True):
|
| 67 |
+
with gr.Row():
|
| 68 |
+
color = gr.Dropdown(label="Color Match", value="LAB", choices=["None", "LAB", "HSV", "RGB"])
|
| 69 |
+
border = gr.Dropdown(label="Border Mode", value="Reflect", choices=["Reflect", "Replicate", "Wrap", "Black"])
|
| 70 |
+
|
| 71 |
+
z = gr.Textbox(label="Zoom", value="0:(1.0)")
|
| 72 |
+
a = gr.Textbox(label="Angle", value="0:(0)")
|
| 73 |
+
tx = gr.Textbox(label="Translation X", value="0:(0)")
|
| 74 |
+
ty = gr.Textbox(label="Translation Y", value="0:(0)")
|
| 75 |
+
stre = gr.Textbox(label="Strength", value="0:(0.35)")
|
| 76 |
+
noi = gr.Textbox(label="Noise", value="0:(0.0)")
|
| 77 |
+
|
| 78 |
+
with gr.Row():
|
| 79 |
+
btn = gr.Button("GENERATE", variant="primary", scale=2)
|
| 80 |
+
stop = gr.Button("STOP", variant="stop", scale=1)
|
| 81 |
+
|
| 82 |
+
with gr.Column(scale=1):
|
| 83 |
+
status = gr.Markdown("Ready")
|
| 84 |
+
preview = gr.Image(label="Last Frame")
|
| 85 |
+
video_out = gr.Video(label="Rendered Video")
|
| 86 |
+
zip_out = gr.File(label="Frames ZIP")
|
| 87 |
+
|
| 88 |
+
inputs = [
|
| 89 |
+
prompts, neg, frames, width, height,
|
| 90 |
+
z, a, tx, ty, stre, noi,
|
| 91 |
+
fps, steps, cfg, cadence,
|
| 92 |
+
color, border, seed_beh, init_img,
|
| 93 |
+
model, lora, sched
|
| 94 |
+
]
|
| 95 |
+
|
| 96 |
+
btn.click(process, inputs=inputs, outputs=[preview, video_out, zip_out, status])
|
| 97 |
+
stop.click(stop_gen, outputs=status)
|
| 98 |
+
|
| 99 |
+
demo.queue().launch(css=css, theme=gr.themes.Glass())
|