| # ZeroGPU shim: on a HF ZeroGPU Space, `spaces` is available and GPU-stage | |
| # functions must be decorated with @GPU. Locally it falls back to a no-op, | |
| # so the same code runs on the laptop and on the Space. | |
| try: | |
| import spaces | |
| GPU = spaces.GPU | |
| except ImportError: # local dev, no ZeroGPU | |
| def GPU(fn=None, **kwargs): | |
| if fn is None: | |
| return lambda f: f | |
| return fn | |