Deploy Hero API
Browse files29 unmodified lines30313233343529 unmodified linesRATE_SCANS = int(os.environ.get("RATE_SCANS", 30))RATE_WORDS = int(os.environ.get("RATE_WORDS", 60000))torch.set_num_threads(max(1, os.cpu_count() or 1))detector = Detector(device="cpu")lock = threading.Lock() # one scan at a time: the CPU is the bottleneck29 unmodified lines3031323334353637383940414243444529 unmodified linesRATE_SCANS = int(os.environ.get("RATE_SCANS", 30))RATE_WORDS = int(os.environ.get("RATE_WORDS", 60000))try:# Free Gradio Spaces on this account run on ZeroGPU hardware, which refuses to start unless at least one# @spaces.GPU function exists. Scans run on the CPU (no GPU quota needed), so this one is just a placeholder.import spaces@spaces.GPU(duration=5)def _gpu_placeholder(): return torch.cuda.is_available()except ImportError:passtorch.set_num_threads(max(1, os.cpu_count() or 1))detector = Detector(device="cpu")lock = threading.Lock() # one scan at a time: the CPU is the bottleneck
app.py+10