Spaces:
Sleeping
Sleeping
File size: 1,408 Bytes
c2d074e b41f138 c2d074e b41f138 c2d074e b41f138 c2d074e f68e7c7 c2d074e b41f138 c2d074e b41f138 c2d074e e19e46d 7bafecd e19e46d c2d074e b41f138 f68e7c7 c2d074e b41f138 c2d074e b41f138 f68e7c7 b41f138 c2d074e b41f138 c2d074e b41f138 c2d074e f68e7c7 c2d074e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import os
import shutil
import subprocess
import sys
from huggingface_hub import snapshot_download
PRIVATE_REPO_ID = "HongshengY/NeuralSketch2Surf"
HF_TOKEN = os.environ.get("HF_TOKEN")
APP_DIR = "/tmp/private_app"
def main():
if not HF_TOKEN:
print("HF_TOKEN not detected")
sys.exit(1)
print(f"Loading latest code from private repository {PRIVATE_REPO_ID}...")
try:
if os.path.exists(APP_DIR):
shutil.rmtree(APP_DIR)
snapshot_download(
repo_id=PRIVATE_REPO_ID,
repo_type="space",
revision="main",
local_dir=APP_DIR,
token=HF_TOKEN,
force_download=True,
)
print("Code and model download complete!")
os.chdir(APP_DIR)
if os.path.exists("backend/requirements.txt"):
print("Installing backend/requirements.txt...")
subprocess.run(
[sys.executable, "-m", "pip", "install", "-r", "backend/requirements.txt"],
check=True
)
print("Starting NeuralSketch2Surf Web...")
cmd = [
"uvicorn",
"backend.server:app",
"--host", "0.0.0.0",
"--port", "7860"
]
os.execvp("uvicorn", cmd)
except Exception as e:
print(f"An error occurred: {e}")
sys.exit(1)
if __name__ == "__main__":
main() |