Dev2506's picture
Add files using upload-large-folder tool
15d68eb verified
Raw
History Blame Contribute Delete
2.48 kB
"""
Indic Heritage Studio v2 β€” Application entry point.
Launches the Gradio web UI exposing all six multimodal pipelines:
1. Text β†’ Heritage-styled image (SDXL + DreamShaper-XL + per-style LoRA)
2. Image + style β†’ Stylized image (IP-Adapter XL)
3. Image β†’ 4-second video (Stable Video Diffusion)
4. ControlNet (Canny/Depth/OpenPose composition conditioning)
5. Inpainting (mask + restyle)
6. Batch processing (multi-GPU parallel)
Usage:
python app.py
# then open http://localhost:7860
"""
from __future__ import annotations
import logging
import os
import sys
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
logging.basicConfig(
level=os.getenv("LOG_LEVEL", "INFO"),
format="%(asctime)s | %(levelname)-7s | %(name)s | %(message)s",
datefmt="%H:%M:%S",
)
log = logging.getLogger("indic-heritage-studio")
def _preflight() -> None:
"""Run sanity checks before starting the UI."""
root = Path(__file__).resolve().parent
if str(root) not in sys.path:
sys.path.insert(0, str(root))
if not os.getenv("AMD_MODEL_API_KEY"):
log.warning(
"AMD_MODEL_API_KEY not set β€” agent layer will be disabled. "
"Core generation still works."
)
try:
import torch
if not torch.cuda.is_available():
log.warning(
"torch.cuda.is_available() is False β€” running on CPU. "
"Generation will be very slow."
)
else:
n = torch.cuda.device_count()
log.info("GPU ready: %d device(s) detected β€” %s",
n, torch.cuda.get_device_name(0))
if n > 1:
log.info("Multi-GPU mode: %d GPUs available, total %.0f GB VRAM",
n, sum(torch.cuda.get_device_properties(i).total_memory
for i in range(n)) / 1e9)
except ImportError:
log.error("PyTorch not installed. Run: pip install -r requirements.txt")
sys.exit(1)
def main() -> None:
_preflight()
from ui.gradio_app import build_ui
log.info("Starting Indic Heritage Studio v2 …")
demo = build_ui()
demo.launch(
server_name=os.getenv("GRADIO_SERVER_NAME", "0.0.0.0"),
server_port=int(os.getenv("GRADIO_SERVER_PORT", "7860")),
share=False,
show_error=True,
inbrowser=False,
max_threads=8,
)
if __name__ == "__main__":
main()