> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-es/generacion-de-video/stable-video-diffusion.md).

# Stable Video Diffusion

Genera videos a partir de imágenes con Stable Video Diffusion en Clore.ai

{% hint style="info" %}
**¡Hay alternativas más nuevas disponibles!** Considera [**FramePack**](/guides/guides_v2-es/generacion-de-video/framepack.md) (¡solo 6 GB de VRAM!), [**Wan2.1**](/guides/guides_v2-es/generacion-de-video/wan-video.md) (mayor calidad), o [**LTX-2**](/guides/guides_v2-es/generacion-de-video/ltx-video-2.md) (video con audio nativo).
{% endhint %}

Genera videos a partir de imágenes usando el modelo SVD de Stability AI.

{% hint style="success" %}
Todos los ejemplos se pueden ejecutar en servidores GPU alquilados a través de [Marketplace de CLORE.AI](https://clore.ai/marketplace).
{% endhint %}

## ¿Qué es Stable Video Diffusion?

SVD (Stable Video Diffusion) genera clips cortos de video a partir de una sola imagen:

* Salidas de 14 o 25 fotogramas
* Resolución 576x1024
* Generación de movimiento fluido
* Pesos de código abierto

## Recursos

* **HuggingFace:** [stabilityai/stable-video-diffusion-img2vid-xt](https://huggingface.co/stabilityai/stable-video-diffusion-img2vid-xt)
* **GitHub:** [Stability-AI/generative-models](https://github.com/Stability-AI/generative-models)
* **Artículo:** [Artículo de SVD](https://arxiv.org/abs/2311.15127)

## Requisitos de hardware

| Modelo                 | VRAM | GPU recomendada |
| ---------------------- | ---- | --------------- |
| SVD (14 fotogramas)    | 16GB | RTX 4090        |
| SVD-XT (25 fotogramas) | 24GB | RTX 4090 / A100 |

## Despliegue rápido

**Imagen de Docker:**

```
pytorch/pytorch:2.11.0-cuda12.8-cudnn9-devel
```

**Puertos:**

```
22/tcp
7860/http
```

**Comando:**

```bash
pip install diffusers transformers accelerate && \\
pip install gradio && \\
python -c "
import gradio as gr
from diffusers import StableVideoDiffusionPipeline
from diffusers.utils import export_to_video
import torch

pipe = StableVideoDiffusionPipeline.from_pretrained(
    'stabilityai/stable-video-diffusion-img2vid-xt',
    torch_dtype=torch.float16,
    variant='fp16'
).to('cuda')

def generate(image, seed, fps):
    generator = torch.manual_seed(seed)
    frames = pipe(image, num_frames=25, generator=generator).frames[0]
    export_to_video(frames, 'output.mp4', fps=fps)
    return 'output.mp4'

gr.Interface(
    fn=generate,
    inputs=[gr.Image(type='pil'), gr.Number(value=42, label='Semilla'), gr.Slider(6, 30, value=7, label='FPS')],
    outputs=gr.Video(),
    title='Difusión de video estable'
).launch(server_name='0.0.0.0', server_port=7860)
"
```

## Accediendo a tu servicio

Después del despliegue, encuentra tu `http_pub` URL en **Mis pedidos**:

1. Ve a **Mis pedidos** página
2. Haz clic en tu pedido
3. Encuentra la `http_pub` URL (p. ej., `abc123.clorecloud.net`)

Usa `https://YOUR_HTTP_PUB_URL` en lugar de `localhost` en los ejemplos a continuación.

## Instalación

```bash
pip install diffusers transformers accelerate torch

# Para exportar video
pip install imageio[ffmpeg]
```

## Uso básico

```python
import torch
from diffusers import StableVideoDiffusionPipeline
from diffusers.utils import load_image, export_to_video

# Cargar pipeline
pipe = StableVideoDiffusionPipeline.from_pretrained(
    "stabilityai/stable-video-diffusion-img2vid-xt",
    torch_dtype=torch.float16,
    variant="fp16"
)
pipe.to("cuda")

# Cargar y redimensionar imagen
image = load_image("input.jpg")
image = image.resize((1024, 576))

# Generar video
generator = torch.manual_seed(42)
frames = pipe(image, num_frames=25, generator=generator).frames[0]

# Guardar video
export_to_video(frames, "output.mp4", fps=7)
```

## SVD vs SVD-XT

| Función    | SVD     | SVD-XT    |
| ---------- | ------- | --------- |
| Fotogramas | 14      | 25        |
| Duración   | \~2 sec | \~3.5 sec |
| VRAM       | 16GB    | 24GB      |
| Calidad    | Bueno   | Mejor     |

## Optimización de memoria

```python

# Habilitar atención eficiente en memoria
pipe.enable_model_cpu_offload()

# O usar fragmentación de atención
pipe.enable_attention_slicing()

# Para VRAM muy baja
pipe.enable_sequential_cpu_offload()
```

## Procesamiento por lotes

````python
import os
from pathlib import Path

input_dir = Path("./images")
output_dir = Path("./videos")
output_dir.mkdir(exist_ok=True)

for img_path in input_dir.glob("*.jpg")】【：】【“】【t_a729e313":"image = load_image(str(img_path)).resize((1024, 576))","t_2409ba55":"frames = pipe(image, num_frames=25).frames[0]","t_13ed1b87":"export_to_video(frames, str(output_dir / f\"{img_path.stem}.mp4\"), fps=7)","t_f31dc845":"print(f\"Generado: {img_path.stem}.mp4\")","t_2b2ccf65":"SVD funciona muy bien en ComfyUI:","t_1e9b74ea":"Instala ComfyUI","t_111b9233":"Descarga el modelo SVD en","t_632c6543":"models/checkpoints/","t_19ea0e0a":"Usa nodos SVD para el flujo de trabajo img2vid","t_f7a3c998":"num_frames","t_a0df976b":"a 14","t_5b36b98b":"Usa la variante fp16","t_8e12bc17":"Video demasiado corto","t_80799d56":"Usa SVD-XT (25 fotogramas) en lugar de SVD (14 fotogramas)","t_7061a45d":"Interpola con RIFE para un resultado más fluido","t_8d3d5fac":"Mala calidad de movimiento","t_08a92098":"Usa imágenes de entrada de alta calidad","t_2dcceb6c":"Asegúrate de que la imagen sea 1024x576 (o 576x1024)","t_60717151":"Actualiza PyTorch y diffusers","t_4ae8c90a":"Comprueba la compatibilidad de la versión de CUDA","t_d4a64ea8":"AnimateDiff - Anima imágenes SD","t_12401800":"Interpolación RIFE","t_d20adba0":"- Aumenta los FPS","t_c13ac479":"- Texto a video"}】}]}```json
{
  "t_8a303d2b": "¡Hay alternativas más nuevas disponibles!",
  "t_95b1bee3": "Considera",
  "t_a761b73a": "FramePack",
  "t_7054a598": "(¡solo 6 GB de VRAM!),",
  "t_2ce6f58b": "(mayor calidad), o",
  "t_1f74e9a2": "LTX-2",
  "t_b6491b13": "(video con audio nativo).",
  "t_a5eff1a5": "Genera videos a partir de imágenes usando el modelo SVD de Stability AI.",
  "t_190098ff": "¿Qué es Stable Video Diffusion?",
  "t_9a77ae6b": "SVD (Stable Video Diffusion) genera clips cortos de video a partir de una sola imagen:",
  "t_72cccdd4": "Salidas de 14 o 25 fotogramas",
  "t_030ff575": "Resolución 576x1024",
  "t_17e89200": "Generación de movimiento fluido",
  "t_cfd98532": "stabilityai/stable-video-diffusion-img2vid-xt",
  "t_723cca54": "Stability-AI/generative-models",
  "t_92ce4bdb": "Artículo de SVD",
  "t_5e955705": "SVD (14 fotogramas)",
  "t_abeb1cd9": "SVD-XT (25 fotogramas)",
  "t_fdbc2ced": "RTX 4090 / A100",
  "t_fad117a3": "pip install diffusers transformers accelerate && \\",
  "t_b38e3ef5": "pip install gradio && \\",
  "t_8d4c5373": "from diffusers.utils import export_to_video",
  "t_266a6abe": "'stabilityai/stable-video-diffusion-img2vid-xt',",
  "t_1a2701d6": "variant='fp16'",
  "t_299af0b3": "def generate(image, seed, fps):",
  "t_07860f8e": "generator = torch.manual_seed(seed)",
  "t_78d4525f": "frames = pipe(image, num_frames=25, generator=generator).frames[0]",
  "t_a91b3a3b": "export_to_video(frames, 'output.mp4', fps=fps)",
  "t_d112ef29": "return 'output.mp4'",
  "t_07ec7e7a": "inputs=[gr.Image(type='pil'), gr.Number(value=42, label='Semilla'), gr.Slider(6, 30, value=7, label='FPS')],",
  "t_c5e4ac47": "outputs=gr.Video(),",
  "t_53799cf0": "title='Difusión de video estable'",
  "t_bbb540be": "# Para exportar video",
  "t_117f9e99": "pip install imageio[ffmpeg]",
  "t_e4eb9bbd": "from diffusers.utils import load_image, export_to_video",
  "t_a3705dae": "variant=\"fp16\"",
  "t_834c2ee9": "image = load_image(\"input.jpg\")",
  "t_c46492a8": "generator = torch.manual_seed(42)",
  "t_d3f8013e": "# Guardar video",
  "t_d72a2abc": "export_to_video(frames, \"output.mp4\", fps=7)",
  "t_5c5e425f": "SVD vs SVD-XT",
  "t_8b7b88b3": "~2 sec",
  "t_61631b06": "~3.5 sec",
  "t_2017c680": "# Habilitar atención eficiente en memoria",
  "t_35555292": "# O usar fragmentación de atención",
  "t_c88dfc7b": "# Para VRAM muy baja",
  "t_65cd2891": "from pathlib import Path",
  "t_5e7a5dde": "input_dir = Path(\"./images\")",
  "t_73e63dc0": "output_dir = Path(\"./videos\")",
  "t_8c08414a": "output_dir.mkdir(exist_ok=True)",
  "t_afc2de26": "for img_path in input_dir.glob(\"*.jpg\"):",
  "t_a729e313": "image = load_image(str(img_path)).resize((1024, 576))",
  "t_2409ba55": "frames = pipe(image, num_frames=25).frames[0]",
  "t_13ed1b87": "export_to_video(frames, str(output_dir / f\"{img_path.stem}.mp4\"), fps=7)",
  "t_f31dc845": "print(f\"Generado: {img_path.stem}.mp4\")",
  "t_2b2ccf65": "SVD funciona muy bien en ComfyUI:",
  "t_1e9b74ea": "Instala ComfyUI",
  "t_111b9233": "Descarga el modelo SVD en",
  "t_632c6543": "models/checkpoints/",
  "t_19ea0e0a": "Usa nodos SVD para el flujo de trabajo img2vid",
  "t_f7a3c998": "num_frames",
  "t_a0df976b": "a 14",
  "t_5b36b98b": "Usa la variante fp16",
  "t_8e12bc17": "Video demasiado corto",
  "t_80799d56": "Usa SVD-XT (25 fotogramas) en lugar de SVD (14 fotogramas)",
  "t_7061a45d": "Interpola con RIFE para un resultado más fluido",
  "t_8d3d5fac": "Mala calidad de movimiento",
  "t_08a92098": "Usa imágenes de entrada de alta calidad",
  "t_2dcceb6c": "Asegúrate de que la imagen sea 1024x576 (o 576x1024)",
  "t_60717151": "Actualiza PyTorch y diffusers",
  "t_4ae8c90a": "Comprueba la compatibilidad de la versión de CUDA",
  "t_d4a64ea8": "AnimateDiff - Anima imágenes SD",
  "t_12401800": "Interpolación RIFE",
  "t_d20adba0": "- Aumenta los FPS",
  "t_c13ac479": "- Texto a video"
}】}]}]}]}]}】}]}]}]}]}]}]}】}]}]}]}]}}]}]}]}]}]}】}]}]}]}]}]}]}}]}]}]}]}]}]  ],"content_hash":"f4b0d74f2ae96b2b","provenance":"Private Derived"}]}]}]}]}]}
```"}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}}```
## Correct answer
",
    image = load_image(str(img_path)).resize((1024, 576))
    frames = pipe(image, num_frames=25).frames[0]
    export_to_video(frames, str(output_dir / f"{img_path.stem}.mp4"), fps=7)
    print(f"Generado: {img_path.stem}.mp4")
````

## Integración con ComfyUI

SVD funciona muy bien en ComfyUI:

1. Instala ComfyUI
2. Descarga el modelo SVD en `models/checkpoints/`
3. Usa nodos SVD para el flujo de trabajo img2vid

## Solución de problemas

{% hint style="danger" %}
**Sin memoria**
{% endhint %}

* Usa `enable_model_cpu_offload()`
* Reduce `num_frames` a 14
* Usa la variante fp16

### Video demasiado corto

* Usa SVD-XT (25 fotogramas) en lugar de SVD (14 fotogramas)
* Interpola con RIFE para un resultado más fluido

### Mala calidad de movimiento

* Usa imágenes de entrada de alta calidad
* Asegúrate de que la imagen sea 1024x576 (o 576x1024)
* Prueba diferentes semillas

### Errores de CUDA

* Actualiza PyTorch y diffusers
* Comprueba la compatibilidad de la versión de CUDA

## Estimación de costos

Tarifas típicas del marketplace de CLORE.AI (a partir de 2024):

| GPU       | Tarifa por hora | Tarifa diaria | Sesión de 4 horas |
| --------- | --------------- | ------------- | ----------------- |
| RTX 3060  | \~$0.03         | \~$0.70       | \~$0.12           |
| RTX 3090  | \~$0.06         | \~$1.50       | \~$0.25           |
| RTX 4090  | \~$0.10         | \~$2.30       | \~$0.40           |
| A100 40GB | \~$0.17         | \~$4.00       | \~$0.70           |
| A100 80GB | \~$0.25         | \~$6.00       | \~$1.00           |

*Los precios varían según el proveedor. Consulta* [*Marketplace de CLORE.AI*](https://clore.ai/marketplace) *las tarifas actuales.*

## Siguientes pasos

* AnimateDiff - Anima imágenes SD
* [Interpolación RIFE](/guides/guides_v2-es/procesamiento-de-video/rife-interpolation.md) - Aumenta los FPS
* [Hunyuan Video](/guides/guides_v2-es/generacion-de-video/hunyuan-video.md) - Texto a video


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-es/generacion-de-video/stable-video-diffusion.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
