Download app.py from Emirinth/ctfast: direct link, hf CLI and curl.
- Browser
- Download file 905 Bytes
-
https://huggingface.co/spaces/Emirinth/ctfast/resolve/main/app.py
- Command line
-
hf download hf://spaces/Emirinth/ctfast/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Emirinth/ctfast/resolve/main/app.py
905 Bytes
| """Start the CTFast web app, locally or on the Hugging Face Space. | |
| The trained detector is downloaded from the model repo first if it is missing. | |
| """ | |
| import argparse | |
| DEFAULT_PORT = 7860 | |
| def main() -> None: | |
| """Load the detector once and serve the Control Centre page and the API.""" | |
| parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) | |
| parser.add_argument("--host", default="0.0.0.0") | |
| parser.add_argument("--port", type=int, default=DEFAULT_PORT) | |
| parser.add_argument("--device", default="cpu", help="cpu, or cuda for a local GPU") | |
| args = parser.parse_args() | |
| import uvicorn | |
| from ctfast import deploy | |
| from ctfast.detector import Detector | |
| from ctfast.web.server import create_app | |
| deploy.fetch_model(only_missing=True) | |
| uvicorn.run(create_app(Detector(args.device)), host=args.host, port=args.port) | |
| if __name__ == "__main__": | |
| main() | |