Spaces:
Running
on
Zero
Running
on
Zero
Update app_fast.py
Browse files- app_fast.py +15 -15
app_fast.py
CHANGED
|
@@ -17,7 +17,7 @@ text_to_video_pipe = WanPipeline.from_pretrained(MODEL_ID, vae=vae, torch_dtype=
|
|
| 17 |
image_to_video_pipe = WanImageToVideoPipeline.from_pretrained(MODEL_ID, vae=vae, torch_dtype=torch.bfloat16)
|
| 18 |
|
| 19 |
for pipe in [text_to_video_pipe, image_to_video_pipe]:
|
| 20 |
-
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=
|
| 21 |
pipe.to("cuda")
|
| 22 |
|
| 23 |
|
|
@@ -42,22 +42,22 @@ for pipe in [text_to_video_pipe, image_to_video_pipe]:
|
|
| 42 |
#LORA_FILENAME = "HSToric_color_Wan22_5b_LoRA.safetensors"
|
| 43 |
|
| 44 |
LORA_REPO_ID = "AlekseyCalvin/Phenakistiscopes_Wan22_5B_T2V_LoRA"
|
| 45 |
-
LORA_FILENAME = "
|
| 46 |
causvid_path = hf_hub_download(repo_id=LORA_REPO_ID, filename=LORA_FILENAME)
|
| 47 |
-
pipe.load_lora_weights(causvid_path, adapter_name="
|
| 48 |
-
pipe.set_adapters(["
|
| 49 |
pipe.fuse_lora()
|
| 50 |
|
| 51 |
# Constants
|
| 52 |
MOD_VALUE = 32
|
| 53 |
DEFAULT_H_SLIDER_VALUE = 896
|
| 54 |
DEFAULT_W_SLIDER_VALUE = 896
|
| 55 |
-
NEW_FORMULA_MAX_AREA =
|
| 56 |
-
SLIDER_MIN_H, SLIDER_MAX_H = 256,
|
| 57 |
-
SLIDER_MIN_W, SLIDER_MAX_W = 256,
|
| 58 |
MAX_SEED = np.iinfo(np.int32).max
|
| 59 |
-
FIXED_FPS =
|
| 60 |
-
MIN_FRAMES_MODEL =
|
| 61 |
MAX_FRAMES_MODEL = 193
|
| 62 |
|
| 63 |
default_prompt_i2v = "make this image come alive, cinematic motion, smooth animation"
|
|
@@ -98,12 +98,12 @@ def get_duration(input_image, prompt, height, width,
|
|
| 98 |
guidance_scale, steps,
|
| 99 |
seed, randomize_seed,
|
| 100 |
progress):
|
| 101 |
-
if steps >
|
| 102 |
-
return
|
| 103 |
-
elif steps >
|
| 104 |
-
return
|
| 105 |
else:
|
| 106 |
-
return
|
| 107 |
|
| 108 |
@spaces.GPU(duration=get_duration)
|
| 109 |
def generate_video(input_image, prompt, height, width, negative_prompt=default_negative_prompt, duration_seconds=2, guidance_scale=0, steps=4, seed=44, randomize_seed=False, progress=gr.Progress(track_tqdm=True)):
|
|
@@ -147,7 +147,7 @@ with gr.Blocks() as demo:
|
|
| 147 |
prompt_input = gr.Textbox(label="Prompt", value=default_prompt_i2v)
|
| 148 |
duration_seconds_input = gr.Slider(minimum=round(MIN_FRAMES_MODEL/FIXED_FPS,1), maximum=round(MAX_FRAMES_MODEL/FIXED_FPS,1), step=0.1, value=2, label="Duration (seconds)", info=f"Clamped to model's {MIN_FRAMES_MODEL}-{MAX_FRAMES_MODEL} frames at {FIXED_FPS}fps.")
|
| 149 |
|
| 150 |
-
with gr.Accordion("Advanced Settings", open=
|
| 151 |
negative_prompt_input = gr.Textbox(label="Negative Prompt", value=default_negative_prompt, lines=3)
|
| 152 |
seed_input = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=42, interactive=True)
|
| 153 |
randomize_seed_checkbox = gr.Checkbox(label="Randomize seed", value=True, interactive=True)
|
|
|
|
| 17 |
image_to_video_pipe = WanImageToVideoPipeline.from_pretrained(MODEL_ID, vae=vae, torch_dtype=torch.bfloat16)
|
| 18 |
|
| 19 |
for pipe in [text_to_video_pipe, image_to_video_pipe]:
|
| 20 |
+
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=5.0)
|
| 21 |
pipe.to("cuda")
|
| 22 |
|
| 23 |
|
|
|
|
| 42 |
#LORA_FILENAME = "HSToric_color_Wan22_5b_LoRA.safetensors"
|
| 43 |
|
| 44 |
LORA_REPO_ID = "AlekseyCalvin/Phenakistiscopes_Wan22_5B_T2V_LoRA"
|
| 45 |
+
LORA_FILENAME = "Phenakistiscopes_MergedVers4_3_2_wan5b_wEMAsigmaRel020.safetensors"
|
| 46 |
causvid_path = hf_hub_download(repo_id=LORA_REPO_ID, filename=LORA_FILENAME)
|
| 47 |
+
pipe.load_lora_weights(causvid_path, adapter_name="wan_lora")
|
| 48 |
+
pipe.set_adapters(["wan_lora"], adapter_weights=[1.05])
|
| 49 |
pipe.fuse_lora()
|
| 50 |
|
| 51 |
# Constants
|
| 52 |
MOD_VALUE = 32
|
| 53 |
DEFAULT_H_SLIDER_VALUE = 896
|
| 54 |
DEFAULT_W_SLIDER_VALUE = 896
|
| 55 |
+
NEW_FORMULA_MAX_AREA = 1536 * 1536
|
| 56 |
+
SLIDER_MIN_H, SLIDER_MAX_H = 256, 1536
|
| 57 |
+
SLIDER_MIN_W, SLIDER_MAX_W = 256, 1536
|
| 58 |
MAX_SEED = np.iinfo(np.int32).max
|
| 59 |
+
FIXED_FPS = 16
|
| 60 |
+
MIN_FRAMES_MODEL = 17
|
| 61 |
MAX_FRAMES_MODEL = 193
|
| 62 |
|
| 63 |
default_prompt_i2v = "make this image come alive, cinematic motion, smooth animation"
|
|
|
|
| 98 |
guidance_scale, steps,
|
| 99 |
seed, randomize_seed,
|
| 100 |
progress):
|
| 101 |
+
if steps > 5 and duration_seconds > 5:
|
| 102 |
+
return 30
|
| 103 |
+
elif steps > 5 or duration_seconds > 5:
|
| 104 |
+
return 25
|
| 105 |
else:
|
| 106 |
+
return 20
|
| 107 |
|
| 108 |
@spaces.GPU(duration=get_duration)
|
| 109 |
def generate_video(input_image, prompt, height, width, negative_prompt=default_negative_prompt, duration_seconds=2, guidance_scale=0, steps=4, seed=44, randomize_seed=False, progress=gr.Progress(track_tqdm=True)):
|
|
|
|
| 147 |
prompt_input = gr.Textbox(label="Prompt", value=default_prompt_i2v)
|
| 148 |
duration_seconds_input = gr.Slider(minimum=round(MIN_FRAMES_MODEL/FIXED_FPS,1), maximum=round(MAX_FRAMES_MODEL/FIXED_FPS,1), step=0.1, value=2, label="Duration (seconds)", info=f"Clamped to model's {MIN_FRAMES_MODEL}-{MAX_FRAMES_MODEL} frames at {FIXED_FPS}fps.")
|
| 149 |
|
| 150 |
+
with gr.Accordion("Advanced Settings", open=True):
|
| 151 |
negative_prompt_input = gr.Textbox(label="Negative Prompt", value=default_negative_prompt, lines=3)
|
| 152 |
seed_input = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=42, interactive=True)
|
| 153 |
randomize_seed_checkbox = gr.Checkbox(label="Randomize seed", value=True, interactive=True)
|