Spaces:
Running on Zero
Running on Zero
Download app.py from himanshu5trpth/checkjson: direct link, hf CLI and curl.
- Browser
- Download file 815 Bytes
-
https://huggingface.co/spaces/himanshu5trpth/checkjson/resolve/main/app.py
- Command line
-
hf download hf://spaces/himanshu5trpth/checkjson/app.py
-
curl -L -o app.py https://huggingface.co/spaces/himanshu5trpth/checkjson/resolve/main/app.py
815 Bytes
| """The CheckJSON HF2 Space. | |
| On ZeroGPU the corrector loads on cuda at start, and only its chat() call takes GPU time. | |
| Run it on your own computer with `python app.py`. Set CHECKJSON_RULES_ONLY=1 to run without a model. | |
| """ | |
| import os | |
| try: | |
| import spaces # must be imported before torch on ZeroGPU | |
| except ImportError: | |
| spaces = None | |
| from checkjson import TransformersBackend | |
| from checkjson.ui.studio import LAUNCH, build_studio | |
| def corrector(): | |
| if os.environ.get("CHECKJSON_RULES_ONLY") == "1": | |
| return None | |
| backend = TransformersBackend(device="cuda" if spaces else None) | |
| if spaces: | |
| backend.wrap(spaces.GPU(duration=30)) | |
| return backend | |
| demo = build_studio(engine=corrector(), public=bool(os.environ.get("SPACE_ID"))) | |
| if __name__ == "__main__": | |
| demo.launch(**LAUNCH) | |