Spaces:
Running
on
Zero
Running
on
Zero
Revert @linoyts commits
Browse files- app.py +6 -23
- requirements.txt +1 -2
app.py
CHANGED
|
@@ -23,7 +23,7 @@ LANDSCAPE_WIDTH = 832
|
|
| 23 |
LANDSCAPE_HEIGHT = 480
|
| 24 |
MAX_SEED = np.iinfo(np.int32).max
|
| 25 |
|
| 26 |
-
FIXED_FPS =
|
| 27 |
MIN_FRAMES_MODEL = 8
|
| 28 |
MAX_FRAMES_MODEL = 81
|
| 29 |
|
|
@@ -45,17 +45,6 @@ pipe = WanImageToVideoPipeline.from_pretrained(MODEL_ID,
|
|
| 45 |
torch_dtype=torch.bfloat16,
|
| 46 |
).to('cuda')
|
| 47 |
|
| 48 |
-
# load, fuse, unload before compilation
|
| 49 |
-
pipe.load_lora_weights(
|
| 50 |
-
"Kijai/WanVideo_comfy",
|
| 51 |
-
weight_name="Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank32_bf16.safetensors",
|
| 52 |
-
adapter_name="lightx2v"
|
| 53 |
-
)
|
| 54 |
-
|
| 55 |
-
pipe.set_adapters(["lightx2v"], adapter_weights=[1.0])
|
| 56 |
-
pipe.fuse_lora(adapter_names=["lightx2v"], lora_scale=1.0)
|
| 57 |
-
pipe.unload_lora_weights()
|
| 58 |
-
|
| 59 |
|
| 60 |
optimize_pipeline_(pipe,
|
| 61 |
image=Image.new('RGB', (LANDSCAPE_WIDTH, LANDSCAPE_HEIGHT)),
|
|
@@ -98,7 +87,6 @@ def get_duration(
|
|
| 98 |
negative_prompt,
|
| 99 |
duration_seconds,
|
| 100 |
guidance_scale,
|
| 101 |
-
guidance_scale_2,
|
| 102 |
steps,
|
| 103 |
seed,
|
| 104 |
randomize_seed,
|
|
@@ -112,9 +100,8 @@ def generate_video(
|
|
| 112 |
prompt,
|
| 113 |
negative_prompt=default_negative_prompt,
|
| 114 |
duration_seconds = MAX_DURATION,
|
| 115 |
-
guidance_scale =
|
| 116 |
-
|
| 117 |
-
steps = 6,
|
| 118 |
seed = 42,
|
| 119 |
randomize_seed = False,
|
| 120 |
progress=gr.Progress(track_tqdm=True),
|
|
@@ -135,8 +122,6 @@ def generate_video(
|
|
| 135 |
Defaults to 2. Clamped between MIN_FRAMES_MODEL/FIXED_FPS and MAX_FRAMES_MODEL/FIXED_FPS.
|
| 136 |
guidance_scale (float, optional): Controls adherence to the prompt. Higher values = more adherence.
|
| 137 |
Defaults to 1.0. Range: 0.0-20.0.
|
| 138 |
-
guidance_scale_2 (float, optional): Controls adherence to the prompt. Higher values = more adherence.
|
| 139 |
-
Defaults to 1.0. Range: 0.0-20.0.
|
| 140 |
steps (int, optional): Number of inference steps. More steps = higher quality but slower.
|
| 141 |
Defaults to 4. Range: 1-30.
|
| 142 |
seed (int, optional): Random seed for reproducible results. Defaults to 42.
|
|
@@ -175,7 +160,6 @@ def generate_video(
|
|
| 175 |
width=resized_image.width,
|
| 176 |
num_frames=num_frames,
|
| 177 |
guidance_scale=float(guidance_scale),
|
| 178 |
-
guidance_scale_2=float(guidance_scale_2),
|
| 179 |
num_inference_steps=int(steps),
|
| 180 |
generator=torch.Generator(device="cuda").manual_seed(current_seed),
|
| 181 |
).frames[0]
|
|
@@ -200,9 +184,8 @@ with gr.Blocks() as demo:
|
|
| 200 |
negative_prompt_input = gr.Textbox(label="Negative Prompt", value=default_negative_prompt, lines=3)
|
| 201 |
seed_input = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=42, interactive=True)
|
| 202 |
randomize_seed_checkbox = gr.Checkbox(label="Randomize seed", value=True, interactive=True)
|
| 203 |
-
steps_slider = gr.Slider(minimum=1, maximum=30, step=1, value=
|
| 204 |
-
guidance_scale_input = gr.Slider(minimum=0.0, maximum=
|
| 205 |
-
guidance_scale_2_input = gr.Slider(minimum=0.0, maximum=10.0, step=0.5, value=3.5, label="Guidance Scale 2 - low noise stage")
|
| 206 |
|
| 207 |
generate_button = gr.Button("Generate Video", variant="primary")
|
| 208 |
with gr.Column():
|
|
@@ -211,7 +194,7 @@ with gr.Blocks() as demo:
|
|
| 211 |
ui_inputs = [
|
| 212 |
input_image_component, prompt_input,
|
| 213 |
negative_prompt_input, duration_seconds_input,
|
| 214 |
-
guidance_scale_input,
|
| 215 |
]
|
| 216 |
generate_button.click(fn=generate_video, inputs=ui_inputs, outputs=[video_output, seed_input])
|
| 217 |
|
|
|
|
| 23 |
LANDSCAPE_HEIGHT = 480
|
| 24 |
MAX_SEED = np.iinfo(np.int32).max
|
| 25 |
|
| 26 |
+
FIXED_FPS = 24
|
| 27 |
MIN_FRAMES_MODEL = 8
|
| 28 |
MAX_FRAMES_MODEL = 81
|
| 29 |
|
|
|
|
| 45 |
torch_dtype=torch.bfloat16,
|
| 46 |
).to('cuda')
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
optimize_pipeline_(pipe,
|
| 50 |
image=Image.new('RGB', (LANDSCAPE_WIDTH, LANDSCAPE_HEIGHT)),
|
|
|
|
| 87 |
negative_prompt,
|
| 88 |
duration_seconds,
|
| 89 |
guidance_scale,
|
|
|
|
| 90 |
steps,
|
| 91 |
seed,
|
| 92 |
randomize_seed,
|
|
|
|
| 100 |
prompt,
|
| 101 |
negative_prompt=default_negative_prompt,
|
| 102 |
duration_seconds = MAX_DURATION,
|
| 103 |
+
guidance_scale = 1,
|
| 104 |
+
steps = 4,
|
|
|
|
| 105 |
seed = 42,
|
| 106 |
randomize_seed = False,
|
| 107 |
progress=gr.Progress(track_tqdm=True),
|
|
|
|
| 122 |
Defaults to 2. Clamped between MIN_FRAMES_MODEL/FIXED_FPS and MAX_FRAMES_MODEL/FIXED_FPS.
|
| 123 |
guidance_scale (float, optional): Controls adherence to the prompt. Higher values = more adherence.
|
| 124 |
Defaults to 1.0. Range: 0.0-20.0.
|
|
|
|
|
|
|
| 125 |
steps (int, optional): Number of inference steps. More steps = higher quality but slower.
|
| 126 |
Defaults to 4. Range: 1-30.
|
| 127 |
seed (int, optional): Random seed for reproducible results. Defaults to 42.
|
|
|
|
| 160 |
width=resized_image.width,
|
| 161 |
num_frames=num_frames,
|
| 162 |
guidance_scale=float(guidance_scale),
|
|
|
|
| 163 |
num_inference_steps=int(steps),
|
| 164 |
generator=torch.Generator(device="cuda").manual_seed(current_seed),
|
| 165 |
).frames[0]
|
|
|
|
| 184 |
negative_prompt_input = gr.Textbox(label="Negative Prompt", value=default_negative_prompt, lines=3)
|
| 185 |
seed_input = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=42, interactive=True)
|
| 186 |
randomize_seed_checkbox = gr.Checkbox(label="Randomize seed", value=True, interactive=True)
|
| 187 |
+
steps_slider = gr.Slider(minimum=1, maximum=30, step=1, value=4, label="Inference Steps")
|
| 188 |
+
guidance_scale_input = gr.Slider(minimum=0.0, maximum=20.0, step=0.5, value=1.0, label="Guidance Scale", visible=False)
|
|
|
|
| 189 |
|
| 190 |
generate_button = gr.Button("Generate Video", variant="primary")
|
| 191 |
with gr.Column():
|
|
|
|
| 194 |
ui_inputs = [
|
| 195 |
input_image_component, prompt_input,
|
| 196 |
negative_prompt_input, duration_seconds_input,
|
| 197 |
+
guidance_scale_input, steps_slider, seed_input, randomize_seed_checkbox
|
| 198 |
]
|
| 199 |
generate_button.click(fn=generate_video, inputs=ui_inputs, outputs=[video_output, seed_input])
|
| 200 |
|
requirements.txt
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
-
git+https://github.com/huggingface/diffusers.git
|
| 2 |
-
|
| 3 |
transformers
|
| 4 |
accelerate
|
| 5 |
safetensors
|
|
|
|
| 1 |
+
git+https://github.com/huggingface/diffusers.git@5512d70f7fd89f69511d9c23f1473a49f7901bee
|
|
|
|
| 2 |
transformers
|
| 3 |
accelerate
|
| 4 |
safetensors
|