# πŸš€ Complete Deployment Guide with CJK Font Support ## Quick Deploy (All Fixes Included) ### Files Required for Hugging Face Space You need these 5 essential files: 1. **`packages.txt`** - System packages (fonts) 2. **`requirements.txt`** - Python packages 3. **`app.py`** - Main application 4. **`app_simple.py`** - Fallback version 5. **`README.md`** - Space description ### Deploy Command ```bash cd /Users/sangmin/Developer/Qwen2.5-VL/huggingface-space ./deploy.sh YOUR_USERNAME YOUR_SPACE_NAME YOUR_TOKEN ``` Example: ```bash ./deploy.sh Sangmin qwen-ocr-detection hf_xxxxxxxxxxxx ``` ### Or Update Existing Space ```bash cd /Users/sangmin/Developer/Qwen2.5-VL/huggingface-space ./update_space.sh ``` ## What Gets Installed ### System Packages (`packages.txt`) ``` fonts-noto-cjk # CJK fonts (Chinese, Japanese, Korean) fonts-noto-cjk-extra # Additional CJK fonts fonts-noto-color-emoji # Emoji support fonts-liberation # Liberation fonts fonts-dejavu-core # DejaVu fonts ``` ### Python Packages (`requirements.txt`) ``` gradio==4.19.2 # Stable Gradio version Pillow>=10.0.0 # Image processing openai>=1.0.0 # API client ``` ## How Hugging Face Processes These Files 1. **Build Phase**: - Reads `packages.txt` β†’ runs `apt-get install` for each package - Reads `requirements.txt` β†’ runs `pip install` for each package - Installs fonts to `/usr/share/fonts/` 2. **Runtime**: - App starts with all fonts available - Font paths are Linux-specific (not macOS) - App searches multiple paths for fonts ## Verification After Deployment ### Check Build Logs Look for: ``` Installing apt packages from packages.txt Reading package lists... Setting up fonts-noto-cjk (1:20201206-1) ... ``` ### Check App Logs Look for: ``` βœ… Loaded font: /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc ``` ### Test CJK Text Upload an image with: - Japanese: γ²γ‚‰γŒγͺγ€γ‚«γ‚Ώγ‚«γƒŠγ€ζΌ’ε­— - Chinese: δΈ­ζ–‡ζ΅‹θ―• - Korean: ν•œκΈ€ ν…ŒμŠ€νŠΈ ## Troubleshooting ### If Fonts Don't Load 1. **Check packages.txt exists** in your Space 2. **Rebuild the Space**: Settings β†’ Factory Reboot 3. **Use test_fonts.py** to debug available fonts ### If App Crashes 1. **Use app_simple.py**: Change app_file in Settings 2. **Check Gradio version**: Must be 4.19.2 3. **Verify launch config**: Must include server settings ## Manual Web Deployment If scripts don't work, upload via web: 1. Go to: https://huggingface.co/new-space 2. Create Space (Gradio SDK) 3. Upload these files: - `packages.txt` (IMPORTANT!) - `requirements.txt` - `app.py` - `README.md` 4. Wait for build to complete ## Expected Result βœ… App runs without errors βœ… Japanese text displays correctly in boxes βœ… Chinese text displays correctly in boxes βœ… Korean text displays correctly in boxes βœ… Bounding boxes align with text βœ… Text labels are readable --- **Your OCR app is ready with full CJK support!** πŸŽŒπŸ‡¨πŸ‡³πŸ‡°πŸ‡· Token: Get from https://huggingface.co/settings/tokens (need WRITE access)