SplatAnything / demo /zero_gpu.py
ritianyu's picture
Load sky segmentation weights and enable Street/Rig scene defaults
fb59dba verified
Raw History Blame Contribute Delete
787 Bytes
"""Optional ZeroGPU adapter; local runs do not import or require spaces."""
import spaces
_pipeline = None
def initialize(pipeline):
global _pipeline
# Load and place models during CUDA emulation, before reserving a shared GPU.
pipeline.initialize()
_pipeline = pipeline
def startup():
# The pinned spaces SDK normally invokes this through Blocks.launch().
# Our mounted FastAPI application must report startup explicitly instead.
from spaces.zero import startup as report_startup
report_startup()
@spaces.GPU(duration=120)
def predict(images, camera, options, prepared=None):
if _pipeline is None:
raise RuntimeError('ZeroGPU models have not been initialized.')
return _pipeline.predict(images, camera, options, prepared=prepared)