pakdd_mrd / app.py
inflaton's picture
Fix ZeroGPU runtime compatibility
c539cdf
Raw History Blame Contribute Delete
586 Bytes
"""Hugging Face Spaces entry point for the shared demo."""
import os
# On Spaces this must be imported before the demo initializes PyTorch. Keep the
# launcher usable locally when the platform's preinstalled package is absent.
try:
import spaces
except ModuleNotFoundError as exc:
if exc.name != "spaces" or os.environ.get("SPACE_ID"):
raise
spaces = None
from demo import app as demo
if spaces is not None:
demo.live_score = spaces.GPU(duration=60)(demo.live_score)
demo.build().launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", "7860")))