Spaces:
Sleeping
Sleeping
| import os | |
| from pathlib import Path | |
| # Set environment before importing torch | |
| os.environ["PYTORCH_ALLOC_CONF"] = "max_split_size_mb:512" | |
| import gradio as gr | |
| import torch | |
| import core | |
| from ui import layout | |
| # Directories | |
| MODELS_DIR = Path("./models") | |
| FONTS_BASE_DIR = Path("./fonts") | |
| os.makedirs(MODELS_DIR, exist_ok=True) | |
| os.makedirs(FONTS_BASE_DIR, exist_ok=True) | |
| # Force CPU for HF Spaces free tier | |
| target_device = torch.device("cpu") | |
| print(f"Using device: CPU") | |
| print(f"PyTorch version: {torch.__version__}") | |
| print(f"MangaTranslator version: {core.__version__}") | |
| # Debug: List font directories | |
| fonts_in_dir = [d.name for d in FONTS_BASE_DIR.iterdir() if d.is_dir()] | |
| print(f"Font directories found: {fonts_in_dir}") | |
| # Create and launch the Gradio app | |
| app = layout.create_layout( | |
| models_dir=MODELS_DIR, | |
| fonts_base_dir=FONTS_BASE_DIR, | |
| target_device=target_device, | |
| ) | |
| app.queue() | |
| app.launch() | |