> 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-fr/generation-video/opensora.md).

# OpenSora

{% hint style="info" %}
**Des alternatives plus récentes disponibles !** [**FramePack**](/guides/guides_v2-fr/generation-video/framepack.md) génère des vidéos avec seulement 6 Go de VRAM, [**Wan2.1**](/guides/guides_v2-fr/generation-video/wan-video.md) offre une qualité supérieure, et [**LTX-2**](/guides/guides_v2-fr/generation-video/ltx-video-2.md) ajoute la génération audio native.
{% endhint %}

Générez des vidéos avec OpenSora, l'alternative Sora open-source, sur les GPU CLORE.AI.

{% hint style="success" %}
Tous les exemples peuvent être exécutés sur des serveurs GPU loués via [CLORE.AI Marketplace](https://clore.ai/marketplace).
{% endhint %}

## Pourquoi OpenSora ?

* **Open source** - Licence Apache 2.0 complète
* **Inspiré par Sora** - Architecture DiT comme Sora d'OpenAI
* **Scalable** - Plusieurs tailles de modèle et résolutions
* **Vidéos longues** - Générer jusqu'à 16 secondes
* **Développement actif** - Mises à jour et améliorations régulières

## Variantes de modèle

| Modèle         | Résolution | Durée | VRAM  | Qualité   |
| -------------- | ---------- | ----- | ----- | --------- |
| OpenSora 1.2   | 720p       | 16s   | 24 Go | Excellent |
| OpenSora 1.1   | 480p       | 8s    | 16Go  | Bon       |
| OpenSora 1.0   | 256p       | 4s    | 8 Go  | Basique   |
| Open-Sora-Plan | 512p       | 10s   | 20Go  | Excellent |

## Déploiement rapide sur CLORE.AI

**Image Docker :**

```
pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
```

**Ports :**

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

**Commande :**

```bash
git clone https://github.com/hpcaitech/Open-Sora && \
cd Open-Sora && \
pip install -e . && \
pip install gradio && \
python scripts/inference.py \
    --prompt "A cat playing with yarn" \
    --num-frames 51 \
    --resolution 480p \
    --save-dir ./outputs
```

## Accéder à votre service

Après le déploiement, trouvez votre `http_pub` URL dans **Mes commandes**:

1. Aller à la **Mes commandes** page
2. Cliquez sur votre commande
3. Trouvez l' `http_pub` URL (par ex., `abc123.clorecloud.net`)

Utilisez `https://VOTRE_HTTP_PUB_URL` au lieu de `localhost` dans les exemples ci-dessous.

## Exigences matérielles

| Version du modèle | GPU minimum   | Recommandé    | Optimal   |
| ----------------- | ------------- | ------------- | --------- |
| OpenSora 1.0      | RTX 3070 8GB  | RTX 3090 24GB | RTX 4090  |
| OpenSora 1.1      | RTX 3090 16GB | RTX 4090 24GB | A100 40GB |
| OpenSora 1.2      | RTX 4090 24GB | A100 40GB     | A100 80GB |

## Installation

### Depuis la source

```bash
git clone https://github.com/hpcaitech/Open-Sora
cd Open-Sora

# Installer les dépendances
pip install -e .

# Télécharger les poids du modèle
python scripts/download_weights.py --version 1.2
```

### Utilisation de pip

```bash
pip install opensora
```

## Utilisation de base

### Ligne de commande

```bash
# Génération simple
python scripts/inference.py \
    --prompt "A beautiful sunset over the ocean, cinematic" \
    --num-frames 51 \
    --resolution 480p \
    --save-dir ./outputs

# Haute qualité
python scripts/inference.py \
    --prompt "A majestic eagle soaring through clouds" \
    --num-frames 102 \
    --resolution 720p \
    --num-sampling-steps 100 \
    --save-dir ./outputs
```

### API Python

```python
import torch
from opensora.models import OpenSoraModel
from opensora.utils import export_to_video

# Charger le modèle
model = OpenSoraModel.from_pretrained("hpcaitech/OpenSora-v1.2")
model.to("cuda")

# Générer une vidéo
prompt = "A rocket launching into space, dramatic lighting, cinematic"

video = model.generate(
    prompt=prompt,
    num_frames=51,
    height=480,
    width=854,
    num_inference_steps=50,
    guidance_scale=7.0
)

# Enregistrer
export_to_video(video, "rocket.mp4", fps=24)
```

## Génération avancée

### Avec prompts négatifs

```python
video = model.generate(
    prompt="Professional photography of a tiger in the wild",
    negative_prompt="blurry, low quality, distorted, artifacts",
    num_frames=51,
    num_inference_steps=75,
    guidance_scale=7.5
)
```

### Vidéos longues

```python
# Générer 16 secondes à 24fps
video = model.generate(
    prompt="Time-lapse of flowers blooming in a garden",
    num_frames=384,  # 16 seconds at 24fps
    height=480,
    width=854,
    num_inference_steps=100
)

export_to_video(video, "timelapse.mp4", fps=24)
```

### Haute résolution

```python
# Génération 720p (exige plus de VRAM)
video = model.generate(
    prompt="Aerial view of a city at night with lights",
    num_frames=51,
    height=720,
    width=1280,
    num_inference_steps=75
)
```

## Exemples de prompts

### Cinématique

```python
prompts = [
    "Cinematic shot of a samurai drawing his sword, dramatic lighting, 4K",
    "Epic wide shot of a castle on a cliff during a storm",
    "Slow motion of water droplets falling into a still pond",
    "Tracking shot through a neon-lit cyberpunk alley at night"
]
```

### Nature

```python
prompts = [
    "Aurora borealis dancing over snowy mountains, time-lapse",
    "Macro shot of a butterfly emerging from cocoon",
    "Ocean waves crashing on volcanic rocks at sunset",
    "Fog rolling through an ancient forest at dawn"
]
```

### Abstrait

```python
prompts = [
    "Colorful paint drops falling into water, slow motion",
    "Fractals evolving and transforming, psychedelic colors",
    "Liquid metal morphing into different shapes"
]
```

## Options de configuration

### Préréglages de résolution

```python
resolutions = {
    "256p": (256, 455),
    "360p": (360, 640),
    "480p": (480, 854),
    "720p": (720, 1280),
    "1080p": (1080, 1920)  # High VRAM required
}
```

### Paramètres de qualité

```python
# Aperçu rapide
config_fast = {
    "num_frames": 25,
    "num_inference_steps": 25,
    "guidance_scale": 5.0
}

# Équilibré
config_balanced = {
    "num_frames": 51,
    "num_inference_steps": 50,
    "guidance_scale": 7.0
}

# Qualité maximale
config_quality = {
    "num_frames": 102,
    "num_inference_steps": 100,
    "guidance_scale": 7.5
}
```

## Interface Gradio

```python
import gradio as gr
import torch
from opensora.models import OpenSoraModel
from opensora.utils import export_to_video
import tempfile

model = OpenSoraModel.from_pretrained("hpcaitech/OpenSora-v1.2")
model.to("cuda")

def generate_video(prompt, negative_prompt, frames, steps, guidance, resolution, seed):
    res_map = {"480p": (480, 854), "720p": (720, 1280)}
    height, width = res_map.get(resolution, (480, 854))

    generator = torch.Generator("cuda").manual_seed(seed) if seed > 0 else None

    video = model.generate(
        prompt=prompt,
        negative_prompt=negative_prompt,
        num_frames=frames,
        height=height,
        width=width,
        num_inference_steps=steps,
        guidance_scale=guidance,
        generator=generator
    )

    with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as f:
        export_to_video(video, f.name, fps=24)
        return f.name

demo = gr.Interface(
    fn=generate_video,
    inputs=[
        gr.Textbox(label="Prompt", lines=2),
        gr.Textbox(label="Negative Prompt", value="flou, basse qualité"),
        gr.Slider(25, 200, value=51, step=1, label="Frames"),
        gr.Slider(20, 150, value=50, step=5, label="Steps"),
        gr.Slider(3, 15, value=7, step=0.5, label="Guidance"),
        gr.Dropdown(["480p", "720p"], value="480p", label="Resolution"),
        gr.Number(value=-1, label="Graine")
    ],
    outputs=gr.Video(label="Vidéo générée"),
    title="OpenSora - Text to Video",
    description="Generate videos using OpenSora. Running on CLORE.AI."
)

demo.launch(server_name="0.0.0.0", server_port=7860)
```

## Optimisation de la mémoire

```python
# Activer les optimisations mémoire
model.enable_model_cpu_offload()
model.enable_vae_tiling()

# Pour une VRAM très faible
model.enable_sequential_cpu_offload()

# Utiliser une précision inférieure
model = OpenSoraModel.from_pretrained(
    "hpcaitech/OpenSora-v1.2",
    torch_dtype=torch.float16
)
```

## Génération par lot

```python
import os

prompts = [
    "A phoenix rising from flames",
    "Rain falling on city streets at night",
    "Flowers blooming time-lapse",
    "Northern lights over mountains"
]

output_dir = "./videos"
os.makedirs(output_dir, exist_ok=True)

for i, prompt in enumerate(prompts):
    print(f"Génération {i+1}/{len(prompts)} : {prompt[:40]}...")

    video = model.generate(
        prompt=prompt,
        num_frames=51,
        num_inference_steps=50
    )

    export_to_video(video, f"{output_dir}/video_{i:03d}.mp4", fps=24)

    # Libérer la mémoire entre les générations
    torch.cuda.empty_cache()
```

## Performances

| Résolution | Images | Pas | GPU       | Temps    |
| ---------- | ------ | --- | --------- | -------- |
| 480p       | 51     | 50  | RTX 4090  | \~3 min  |
| 480p       | 51     | 50  | A100 40GB | \~2 min  |
| 720p       | 51     | 50  | A100 40GB | \~5 min  |
| 720p       | 102    | 100 | A100 80GB | \~15 min |

## Estimation des coûts

Tarifs typiques du marketplace CLORE.AI :

| GPU           | Tarif horaire | \~51 frame 480p videos/hour |
| ------------- | ------------- | --------------------------- |
| RTX 4090 24GB | \~$0.10       | \~15-20                     |
| A100 40GB     | \~$0.17       | \~25-30                     |
| A100 80GB     | \~$0.25       | \~35 (can do 720p)          |

*Les prix varient. Vérifiez* [*CLORE.AI Marketplace*](https://clore.ai/marketplace) *pour les tarifs actuels.*

## Dépannage

### Mémoire insuffisante

```bash
# Utiliser une résolution plus petite
python scripts/inference.py --resolution 360p --num-frames 25

# Activer le déchargement vers le CPU
python scripts/inference.py --cpu-offload

# Réduire la taille du lot
python scripts/inference.py --batch-size 1
```

### Génération lente

* Réduire `num_inference_steps` (30-50 often enough)
* Utiliser une résolution plus basse pour les aperçus
* Assurez-vous que le GPU est utilisé (vérifiez `nvidia-smi`)

### Mauvaise qualité

* Augmenter les étapes à 75-100
* Utiliser des prompts plus descriptifs
* Ajouter des prompts négatifs pour les artefacts
* Essayer différentes valeurs de guidance (5-10)

### Artefacts vidéo

* Réduire l'échelle de guidance
* Augmenter les étapes d'inférence
* Utiliser un lissage temporel
* Post-traiter avec stabilisation vidéo

## OpenSora vs Autres

| Fonction            | OpenSora 1.2 | Hunyuan   | Wan2.1     | SVD    |
| ------------------- | ------------ | --------- | ---------- | ------ |
| Architecture        | DiT          | DiT       | DiT        | U-Net  |
| Durée maximale      | 16s          | 5s        | 5s         | 4s     |
| Résolution maximale | 720p         | 720p      | 720p       | 576p   |
| Qualité             | Excellent    | Excellent | Excellent  | Bon    |
| Vitesse             | Moyen        | Lent      | Rapide     | Rapide |
| Licence             | Apache 2.0   | Ouvrir    | Apache 2.0 | Ouvrir |

**Utiliser OpenSora lorsque :**

* Besoin de générer des vidéos plus longues
* Souhaite la licence complète Apache 2.0
* Intéressé par une architecture de type Sora
* Besoin d'un support communautaire actif

## Alternative Open-Sora-Plan

Une autre option open-source :

```bash
git clone https://github.com/PKU-YuanGroup/Open-Sora-Plan
cd Open-Sora-Plan
pip install -e .

python scripts/inference.py \
    --prompt "Your prompt here" \
    --output video.mp4
```

## Prochaines étapes

* [Hunyuan Video](/guides/guides_v2-fr/generation-video/hunyuan-video.md) - T2V de haute qualité
* [Wan2.1 Video](/guides/guides_v2-fr/generation-video/wan-video.md) - Génération rapide
* [Stable Video Diffusion](/guides/guides_v2-fr/generation-video/stable-video-diffusion.md) - Animation d'image
* [Interpolation RIFE](/guides/guides_v2-fr/traitement-video/rife-interpolation.md) - Interpolation d'images


---

# 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:

```
GET https://docs.clore.ai/guides/guides_v2-fr/generation-video/opensora.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
