AlekseyCalvin commited on
Commit
b767961
·
verified ·
1 Parent(s): 4ad1dc6

Rename app.py to app.p

Browse files
Files changed (2) hide show
  1. app.p +102 -0
  2. app.py +0 -39
app.p ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, 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 20 args + self implicitly
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), 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 = """
33
+ #col-container {max_width: 1000px; margin: 0 auto;}
34
+ """
35
+
36
+ with gr.Blocks() as demo:
37
+ gr.Markdown("# 🌀 Deforum CPU: Full Featured\nAuthentic implementation with Cadence, Seed Control, and proper Color Coherence.")
38
+
39
+ with gr.Row(elem_id="col-container"):
40
+ with gr.Column(scale=1):
41
+
42
+ with gr.Accordion("⚙️ Engine Settings", open=False):
43
+ model = gr.Dropdown(label="Model", value="AlekseyCalvin/acs_model",
44
+ choices=["AlekseyCalvin/acs_model", "runwayml/stable-diffusion-v1-5", "IDKiro/sdxs-512-dreamshaper"])
45
+ lora = gr.Dropdown(label="LoRA", value="latent-consistency/lcm-lora-sdv1-5",
46
+ choices=["latent-consistency/lcm-lora-sdv1-5", "None"])
47
+ sched = gr.Dropdown(label="Sampler", value="LCM",
48
+ choices=["LCM", "Euler A", "DDIM", "DPM++ 2M"])
49
+ seed_beh = gr.Dropdown(label="Seed Behavior", value="iter", choices=["iter", "fixed", "random"])
50
+ init_img = gr.Image(label="Init Image", type="pil", height=200)
51
+
52
+ prompts = gr.Code(label="Prompts (JSON)", language="json",
53
+ value='{\n "0": "a beautiful forest, sun rays, 8k",\n "30": "forest fire, smoke, dramatic lighting"\n}')
54
+ neg = gr.Textbox(label="Negative Prompt", value="lowres, text, error, cropped, worst quality, low quality")
55
+
56
+ with gr.Row():
57
+ frames = gr.Number(label="Max Frames", value=120)
58
+ fps = gr.Number(label="FPS", value=15)
59
+
60
+ with gr.Row():
61
+ width = gr.Slider(256, 512, value=256, step=64, label="Width")
62
+ height = gr.Slider(256, 512, value=256, step=64, label="Height")
63
+
64
+ with gr.Row():
65
+ steps = gr.Slider(1, 20, value=4, step=1, label="Steps")
66
+ cadence = gr.Slider(1, 8, value=2, step=1, label="Cadence (Speed/Smoothness)")
67
+
68
+ with gr.Accordion("🎬 Motion & Coherence", open=True):
69
+ with gr.Row():
70
+ color = gr.Dropdown(label="Color Match", value="LAB", choices=["None", "LAB", "HSV", "RGB"])
71
+ border = gr.Dropdown(label="Border Mode", value="Reflect", choices=["Reflect", "Replicate", "Wrap", "Black"])
72
+
73
+ z = gr.Textbox(label="Zoom", value="0:(1.01)")
74
+ a = gr.Textbox(label="Angle", value="0:(0)")
75
+ tx = gr.Textbox(label="Translation X", value="0:(0)")
76
+ ty = gr.Textbox(label="Translation Y", value="0:(0)")
77
+ stre = gr.Textbox(label="Strength (Decay)", value="0:(0.65)")
78
+ noi = gr.Textbox(label="Noise (Grain)", value="0:(0.02)")
79
+
80
+ with gr.Row():
81
+ btn = gr.Button("GENERATE", variant="primary", scale=2)
82
+ stop = gr.Button("STOP", variant="stop", scale=1)
83
+
84
+ with gr.Column(scale=1):
85
+ status = gr.Markdown("Ready")
86
+ preview = gr.Image(label="Last Frame")
87
+ video_out = gr.Video(label="Rendered Video")
88
+ zip_out = gr.File(label="Frames ZIP")
89
+
90
+ # Arguments: 20 inputs + self implicitly handled by click
91
+ inputs = [
92
+ prompts, neg, frames, width, height,
93
+ z, a, tx, ty, stre, noi,
94
+ fps, steps, cadence,
95
+ color, border, seed_beh, init_img,
96
+ model, lora, sched
97
+ ]
98
+
99
+ btn.click(process, inputs=inputs, outputs=[preview, video_out, zip_out, status])
100
+ stop.click(stop_gen, outputs=status)
101
+
102
+ demo.queue().launch(css=css, theme=gr.themes.Glass())
app.py DELETED
@@ -1,39 +0,0 @@
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, z, a, tx, ty, stre, noi, steps, color, border, blend, init_img, model, lora, sched):
8
- try:
9
- p_dict = json.loads(prompts_json.replace("'", '"'))
10
- p_dict = {int(k): v for k, v in p_dict.items()}
11
- except: yield None, None, None, "JSON Format Error"; return
12
- yield from runner.render(p_dict, neg, int(frames), 256, 256, z, a, tx, ty, stre, noi, 12, int(steps), 1, color, border, blend, init_img, model, lora, sched)
13
-
14
- with gr.Blocks() as demo:
15
- gr.Markdown("# 🌀 Deforum CPU: Pro Toolkit\n**Prompt Interpolation + Anti-Crash Logic**")
16
- with gr.Row():
17
- with gr.Column():
18
- with gr.Accordion("Pipeline", open=False):
19
- m = gr.Dropdown(label="Model", value="AlekseyCalvin/acs_model", choices=["AlekseyCalvin/acs_model", "runwayml/stable-diffusion-v1-5"])
20
- l = gr.Dropdown(label="LoRA", value="latent-consistency/lcm-lora-sdv1-5", choices=["latent-consistency/lcm-lora-sdv1-5", "None"])
21
- s = gr.Dropdown(label="Sched", value="LCM", choices=["LCM", "Euler A"])
22
- init = gr.Image(label="Init Image", type="pil")
23
- prompts = gr.Code(label="Prompt Keyframes", language="json", value='{"0": "ocean wave", "50": "fire forest"}')
24
- neg = gr.Textbox(label="Negative", value="blur, noise")
25
- with gr.Row():
26
- frames = gr.Number(label="Frames", value=60); steps = gr.Slider(2, 10, 4, label="Steps"); blend = gr.Slider(0.0, 0.4, 0.1, label="Stability Blend")
27
- with gr.Accordion("Animation", open=True):
28
- z, a = gr.Textbox(label="Zoom", value="0:(1.02)"), gr.Textbox(label="Angle", value="0:(0)")
29
- tx, ty = gr.Textbox(label="TX", value="0:(0)"), gr.Textbox(label="TY", value="0:(0)")
30
- st, no = gr.Textbox(label="Strength", value="0:(0.55)"), gr.Textbox(label="Noise", value="0:(0.02)")
31
- col, bor = gr.Dropdown(label="Color", value="LAB", choices=["None","LAB"]), gr.Dropdown(label="Border", value="Reflect", choices=["Reflect","Wrap"])
32
- btn = gr.Button("Generate", variant="primary"); stop = gr.Button("Stop", variant="stop")
33
- with gr.Column():
34
- stat = gr.Markdown("Ready"); pre = gr.Image(label="Preview"); out_v = gr.Video(label="Video"); out_z = gr.File(label="ZIP")
35
-
36
- btn.click(process, [prompts, neg, frames, z, a, tx, ty, st, no, steps, col, bor, blend, init, m, l, s], [pre, out_v, out_z, stat])
37
- stop.click(lambda: runner.stop())
38
-
39
- demo.queue().launch(theme=gr.themes.Glass())