--- 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 `.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_.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) |