Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -103,7 +103,7 @@ DEFAULT_NEGATIVE_PROMPT = (
|
|
| 103 |
)
|
| 104 |
DEFAULT_FRAME_RATE = 24.0
|
| 105 |
MIN_DIM, MAX_DIM, STEP = 256, 1280, 64
|
| 106 |
-
MIN_FRAMES, MAX_FRAMES = 9,
|
| 107 |
|
| 108 |
# Resolution presets with high/low tiers
|
| 109 |
RESOLUTIONS = {
|
|
@@ -201,7 +201,7 @@ class HQPipelineWithCachedLoRA:
|
|
| 201 |
[prompt, negative_prompt],
|
| 202 |
self.model_ledger,
|
| 203 |
enhance_first_prompt=enhance_prompt,
|
| 204 |
-
enhance_prompt_image=images[0]
|
| 205 |
enhance_prompt_seed=seed,
|
| 206 |
)
|
| 207 |
|
|
@@ -677,7 +677,10 @@ def detect_aspect_ratio(image) -> str:
|
|
| 677 |
|
| 678 |
|
| 679 |
def on_image_upload(first_image, last_image, high_res):
|
| 680 |
-
|
|
|
|
|
|
|
|
|
|
| 681 |
aspect = detect_aspect_ratio(ref_image)
|
| 682 |
tier = "high" if high_res else "low"
|
| 683 |
w, h = RESOLUTIONS[tier][aspect]
|
|
@@ -685,7 +688,10 @@ def on_image_upload(first_image, last_image, high_res):
|
|
| 685 |
|
| 686 |
|
| 687 |
def on_highres_toggle(first_image, last_image, high_res):
|
| 688 |
-
|
|
|
|
|
|
|
|
|
|
| 689 |
aspect = detect_aspect_ratio(ref_image)
|
| 690 |
tier = "high" if high_res else "low"
|
| 691 |
w, h = RESOLUTIONS[tier][aspect]
|
|
@@ -783,7 +789,7 @@ def generate_video(
|
|
| 783 |
images = []
|
| 784 |
output_dir = Path("outputs")
|
| 785 |
output_dir.mkdir(exist_ok=True)
|
| 786 |
-
|
| 787 |
if first_image is not None:
|
| 788 |
temp_first_path = output_dir / f"temp_first_{current_seed}.jpg"
|
| 789 |
if hasattr(first_image, "save"):
|
|
@@ -791,8 +797,8 @@ def generate_video(
|
|
| 791 |
else:
|
| 792 |
import shutil
|
| 793 |
shutil.copy(first_image, temp_first_path)
|
| 794 |
-
images.append((str(temp_first_path), 1.0))
|
| 795 |
-
|
| 796 |
if last_image is not None:
|
| 797 |
temp_last_path = output_dir / f"temp_last_{current_seed}.jpg"
|
| 798 |
if hasattr(last_image, "save"):
|
|
@@ -800,7 +806,7 @@ def generate_video(
|
|
| 800 |
else:
|
| 801 |
import shutil
|
| 802 |
shutil.copy(last_image, temp_last_path)
|
| 803 |
-
images.append((str(temp_last_path), 1.0))
|
| 804 |
|
| 805 |
tiling_config = TilingConfig.default()
|
| 806 |
video_chunks_number = get_video_chunks_number(num_frames, tiling_config)
|
|
|
|
| 103 |
)
|
| 104 |
DEFAULT_FRAME_RATE = 24.0
|
| 105 |
MIN_DIM, MAX_DIM, STEP = 256, 1280, 64
|
| 106 |
+
MIN_FRAMES, MAX_FRAMES = 9, 721
|
| 107 |
|
| 108 |
# Resolution presets with high/low tiers
|
| 109 |
RESOLUTIONS = {
|
|
|
|
| 201 |
[prompt, negative_prompt],
|
| 202 |
self.model_ledger,
|
| 203 |
enhance_first_prompt=enhance_prompt,
|
| 204 |
+
enhance_prompt_image=images[0].path if len(images) > 0 else None,
|
| 205 |
enhance_prompt_seed=seed,
|
| 206 |
)
|
| 207 |
|
|
|
|
| 677 |
|
| 678 |
|
| 679 |
def on_image_upload(first_image, last_image, high_res):
|
| 680 |
+
# Always use first_image for resolution calculation
|
| 681 |
+
ref_image = first_image
|
| 682 |
+
if ref_image is None:
|
| 683 |
+
return gr.update(), gr.update()
|
| 684 |
aspect = detect_aspect_ratio(ref_image)
|
| 685 |
tier = "high" if high_res else "low"
|
| 686 |
w, h = RESOLUTIONS[tier][aspect]
|
|
|
|
| 688 |
|
| 689 |
|
| 690 |
def on_highres_toggle(first_image, last_image, high_res):
|
| 691 |
+
# Always use first_image for resolution calculation
|
| 692 |
+
ref_image = first_image
|
| 693 |
+
if ref_image is None:
|
| 694 |
+
return gr.update(), gr.update()
|
| 695 |
aspect = detect_aspect_ratio(ref_image)
|
| 696 |
tier = "high" if high_res else "low"
|
| 697 |
w, h = RESOLUTIONS[tier][aspect]
|
|
|
|
| 789 |
images = []
|
| 790 |
output_dir = Path("outputs")
|
| 791 |
output_dir.mkdir(exist_ok=True)
|
| 792 |
+
|
| 793 |
if first_image is not None:
|
| 794 |
temp_first_path = output_dir / f"temp_first_{current_seed}.jpg"
|
| 795 |
if hasattr(first_image, "save"):
|
|
|
|
| 797 |
else:
|
| 798 |
import shutil
|
| 799 |
shutil.copy(first_image, temp_first_path)
|
| 800 |
+
images.append(ImageConditioningInput(path=str(temp_first_path), frame_idx=0, strength=1.0))
|
| 801 |
+
|
| 802 |
if last_image is not None:
|
| 803 |
temp_last_path = output_dir / f"temp_last_{current_seed}.jpg"
|
| 804 |
if hasattr(last_image, "save"):
|
|
|
|
| 806 |
else:
|
| 807 |
import shutil
|
| 808 |
shutil.copy(last_image, temp_last_path)
|
| 809 |
+
images.append(ImageConditioningInput(path=str(temp_last_path), frame_idx=num_frames - 1, strength=1.0))
|
| 810 |
|
| 811 |
tiling_config = TilingConfig.default()
|
| 812 |
video_chunks_number = get_video_chunks_number(num_frames, tiling_config)
|