Spaces:
Running
Running
| 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) | | |