Spaces:
Running
Running
File size: 2,285 Bytes
4040be0 54ca85f 5657511 4040be0 e65b972 5657511 4040be0 54ca85f a9334c7 54ca85f a9334c7 54ca85f a9334c7 54ca85f a9334c7 54ca85f a9334c7 54ca85f a9334c7 54ca85f a9334c7 54ca85f a9334c7 54ca85f a9334c7 54ca85f a9334c7 54ca85f a9334c7 54ca85f a9334c7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | ---
title: PDF → Manim → LLM App
emoji: "🎬"
colorFrom: "red"
colorTo: "blue"
sdk: gradio
sdk_version: "6.8.0"
python_version: "3.11"
app_file: app.py
pinned: false
---
# 🎬 PDF → Manim Animation Pipeline
Upload a PDF → Gemini generates a Manim animation → watch it in-app and download the artifacts.
---
## 🚀 Deploy on Hugging Face Spaces
1. Create a new Space (SDK: Gradio, any CPU hardware).
2. Upload all files in this folder.
3. No secrets required — users supply their own Gemini API key in the UI.
---
## 🖥️ Usage
1. Upload a PDF.
2. Enter your **Gemini API key** (saved in your browser — enter once).
3. Click **Generate Video**.
4. Watch live status and the generated Manim code appear in real time.
5. When complete:
- ▶️ **Video player** — watch the animation directly in the browser.
- ⬇️ **Artifacts ZIP** — download `<job_id>.py` + `OutputVideo.mp4`.
---
## 🏗️ Architecture
```
PDF Upload
│
▼
Extract Text (pypdf)
│
▼
Gemini 3 Flash Preview → code shown live in UI
│
▼
Manim Render (-qm, 1280×720, 30fps)
│
▼
Video Player + artifacts_<job_id>.zip download
```
---
## 📁 File Structure
```
.
├── app.py # Gradio UI — streaming status, video player, zip download
├── pipeline.py # Job orchestrator
├── queue_manager.py # Thread-pool queue (max 100 jobs)
├── utils.py # PDF extraction, Gemini streaming, code sanitisation
├── requirements.txt # Python deps
├── packages.txt # System deps (LaTeX, ffmpeg, cairo…)
└── README.md
```
---
## ⚙️ System Packages (`packages.txt`)
Manim requires LaTeX and ffmpeg. These are installed automatically by HF Spaces:
- `ffmpeg`, `libcairo2-dev`, `libpango1.0-dev`
- `texlive-latex-base`, `texlive-latex-extra`, `texlive-fonts-recommended`
- `dvipng`, `dvisvgm`, `ghostscript`
---
## 🐛 Troubleshooting
| Issue | Fix |
|-------|-----|
| `latex not found` | Ensure `packages.txt` is at the repo root |
| Render timeout | Use higher-tier hardware or shorten animation in prompt |
| Gemini API error | Check API key and quota at aistudio.google.com |
| Empty PDF | PDF must have selectable text (not a scanned image) |
|