Spaces:
Sleeping
Sleeping
| """Hugging Face Space entry point for Tabras. | |
| `MODE` selects the model backend (clients.configure_mode): | |
| - LOCAL : run MiniCPM / Nemotron / SDXL on your own hardware (the default | |
| when you clone and run the repo). | |
| - MODAL : call Modal GPU endpoints over HTTP (used here on the Space). | |
| This file defaults to MODE=MODAL. After `modal deploy modal_app.py`, set these | |
| Space variables to the printed URLs: | |
| TABRAS_CARD_ENDPOINT -> CardModel.chat URL | |
| TABRAS_BOSS_ENDPOINT -> BossModel.chat URL | |
| TABRAS_ART_ENDPOINT -> ArtModel.generate URL | |
| The Space needs no GPU (it just makes HTTP calls), so run it on free CPU hardware. | |
| """ | |
| import os | |
| os.environ.setdefault("MODE", "MODAL") | |
| # Modal GPU endpoints (deployed from modal_app.py). Public URLs, safe to hardcode; | |
| # a Space variable still overrides any of these if you redeploy under a new name. | |
| _MODAL = "https://vishnupratikvennelakanti--tabras-models" | |
| os.environ.setdefault("TABRAS_CARD_ENDPOINT", f"{_MODAL}-cardmodel-chat.modal.run") | |
| os.environ.setdefault("TABRAS_BOSS_ENDPOINT", f"{_MODAL}-bossmodel-chat.modal.run") | |
| os.environ.setdefault("TABRAS_ART_ENDPOINT", f"{_MODAL}-artmodel-generate.modal.run") | |
| from clients import configure_mode # noqa: E402 | |
| configure_mode() | |
| from app import CSS, HEAD, build_app # noqa: E402 | |
| # Module-level `demo` so Hugging Face's launcher finds the Blocks; css/head are | |
| # applied via launch() below (keep the Space's Dev Mode off so this runs). | |
| demo = build_app() | |
| demo.queue() | |
| if __name__ == "__main__": | |
| port = int(os.environ.get("PORT", "7860")) | |
| demo.launch(server_name="0.0.0.0", server_port=port, css=CSS, head=HEAD) | |