Spaces:
Running
on
Zero
Running
on
Zero
feat: Enable MCP
#36
by
multimodalart
HF Staff
- opened
app.py
CHANGED
|
@@ -40,6 +40,25 @@ def sample(
|
|
| 40 |
output_folder: str = "outputs",
|
| 41 |
progress=gr.Progress(track_tqdm=True)
|
| 42 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
if image.mode == "RGBA":
|
| 44 |
image = image.convert("RGB")
|
| 45 |
|
|
@@ -58,6 +77,16 @@ def sample(
|
|
| 58 |
return video_path, seed
|
| 59 |
|
| 60 |
def resize_image(image, output_size=(1024, 576)):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
# Calculate aspect ratios
|
| 62 |
target_aspect = output_size[0] / output_size[1] # Aspect ratio of the desired size
|
| 63 |
image_aspect = image.width / image.height # Aspect ratio of the original image
|
|
@@ -125,4 +154,4 @@ with gr.Blocks() as demo:
|
|
| 125 |
|
| 126 |
if __name__ == "__main__":
|
| 127 |
#demo.queue(max_size=20, api_open=False)
|
| 128 |
-
demo.launch(share=True, show_api=False)
|
|
|
|
| 40 |
output_folder: str = "outputs",
|
| 41 |
progress=gr.Progress(track_tqdm=True)
|
| 42 |
):
|
| 43 |
+
"""
|
| 44 |
+
Generate a video from a single image using Stable Video Diffusion.
|
| 45 |
+
|
| 46 |
+
Args:
|
| 47 |
+
image: Input PIL Image to generate video from
|
| 48 |
+
seed: Random seed for generation reproducibility
|
| 49 |
+
randomize_seed: Whether to randomize the seed
|
| 50 |
+
motion_bucket_id: Controls the amount of motion in the generated video (1-255)
|
| 51 |
+
fps_id: Frames per second for the output video
|
| 52 |
+
version: Model version to use
|
| 53 |
+
cond_aug: Conditioning augmentation strength
|
| 54 |
+
decoding_t: Number of frames decoded at a time (affects VRAM usage)
|
| 55 |
+
device: Device to run the model on
|
| 56 |
+
output_folder: Directory to save the output video
|
| 57 |
+
progress: Gradio progress tracker
|
| 58 |
+
|
| 59 |
+
Returns:
|
| 60 |
+
tuple: (video_path, seed) - Path to the generated video and the seed used
|
| 61 |
+
"""
|
| 62 |
if image.mode == "RGBA":
|
| 63 |
image = image.convert("RGB")
|
| 64 |
|
|
|
|
| 77 |
return video_path, seed
|
| 78 |
|
| 79 |
def resize_image(image, output_size=(1024, 576)):
|
| 80 |
+
"""
|
| 81 |
+
Resize and crop an image to the specified output size while maintaining aspect ratio.
|
| 82 |
+
|
| 83 |
+
Args:
|
| 84 |
+
image: PIL Image to resize
|
| 85 |
+
output_size: Target size as (width, height) tuple
|
| 86 |
+
|
| 87 |
+
Returns:
|
| 88 |
+
PIL.Image: Resized and cropped image
|
| 89 |
+
"""
|
| 90 |
# Calculate aspect ratios
|
| 91 |
target_aspect = output_size[0] / output_size[1] # Aspect ratio of the desired size
|
| 92 |
image_aspect = image.width / image.height # Aspect ratio of the original image
|
|
|
|
| 154 |
|
| 155 |
if __name__ == "__main__":
|
| 156 |
#demo.queue(max_size=20, api_open=False)
|
| 157 |
+
demo.launch(share=True, show_api=False, mcp_server=True)
|