Spaces:
Sleeping
Sleeping
Download app.py from farrell236/OCT_Segmentation_a1: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/farrell236/OCT_Segmentation_a1/resolve/main/app.py
- Command line
-
hf download hf://spaces/farrell236/OCT_Segmentation_a1/app.py
-
curl -L -o app.py https://huggingface.co/spaces/farrell236/OCT_Segmentation_a1/resolve/main/app.py
1.38 kB
| """Launch OCT boundary inference locally or on Hugging Face Spaces.""" | |
| import argparse | |
| import os | |
| def parse_args(argv=None): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument( | |
| "--port", type=int, default=os.environ.get("GRADIO_SERVER_PORT", "7860") | |
| ) | |
| parser.add_argument( | |
| "--host", | |
| default=os.environ.get( | |
| "GRADIO_SERVER_NAME", | |
| "0.0.0.0" if os.environ.get("SPACE_ID") else "127.0.0.1", | |
| ), | |
| ) | |
| parser.add_argument( | |
| "--open", action="store_true", help="Open the viewer in your browser" | |
| ) | |
| args = parser.parse_args(argv) | |
| if not 1 <= args.port <= 65535: | |
| parser.error("Port must be between 1 and 65535") | |
| return args | |
| def main(): | |
| args = parse_args() | |
| os.environ.setdefault("GRADIO_ANALYTICS_ENABLED", "False") | |
| from src.app import build_app | |
| from src.viewer import CHECKPOINT | |
| if not CHECKPOINT.is_file(): | |
| raise SystemExit(f"Checkpoint does not exist: {CHECKPOINT}") | |
| demo = build_app() | |
| demo.queue(default_concurrency_limit=1, max_size=12).launch( | |
| server_name=args.host, | |
| server_port=args.port, | |
| inbrowser=args.open and not bool(os.environ.get("SPACE_ID")), | |
| share=False, | |
| show_error=False, | |
| blocked_paths=[str(CHECKPOINT)], | |
| ) | |
| if __name__ == "__main__": | |
| main() | |