Spaces:
Sleeping
Sleeping
Download start.py from kanklc/quickdraw-demo: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/spaces/kanklc/quickdraw-demo/resolve/main/start.py
- Command line
-
hf download hf://spaces/kanklc/quickdraw-demo/start.py
-
curl -L -o start.py https://huggingface.co/spaces/kanklc/quickdraw-demo/resolve/main/start.py
1.24 kB
| # Kod ve agirliklari ozel repodan calisma aninda indirir ve uygulamayi baslatir. | |
| import os, sys | |
| from huggingface_hub import snapshot_download | |
| path = snapshot_download(os.environ["PRIVATE_REPO"], token=os.environ["HF_TOKEN"], | |
| local_dir="/tmp/private") | |
| os.chdir(path) | |
| sys.path.insert(0, path) | |
| import gradio as gr | |
| from app import main as api_main | |
| # ZeroGPU, bir @spaces.GPU fonksiyonu ve onu kullanan bir Gradio arayuzu arar. | |
| # Uygulamamiz GPU kullanmaz; bu fonksiyon yalnizca bu kontrol icindir. | |
| try: | |
| import spaces | |
| gpu = spaces.GPU | |
| except Exception as e: | |
| print("spaces import edilemedi:", e, flush=True) | |
| gpu = lambda f: f | |
| def ping(x): | |
| return x | |
| with gr.Blocks(title="Quick Draw") as demo: | |
| box = gr.Textbox(visible=False) | |
| btn = gr.Button("ping", visible=False) | |
| btn.click(ping, box, box) | |
| demo.launch(server_name="0.0.0.0", server_port=7860, prevent_thread_lock=True, ssr_mode=False) | |
| # Kendi arayuz ve API rotalarimizi Gradio sunucusunun onune ekle | |
| api_main._load() | |
| for r in reversed(api_main.app.routes): | |
| if getattr(r, "path", None) in ("/health", "/api/predict", "/api/order_test", "/", "/static"): | |
| demo.app.router.routes.insert(0, r) | |
| demo.block_thread() | |