Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,31 +5,6 @@ from huggingface_hub import hf_hub_download
|
|
| 5 |
from handwriting_api import InputData
|
| 6 |
from typing import List
|
| 7 |
|
| 8 |
-
# Download model from Hugging Face Hub
|
| 9 |
-
def download_model():
|
| 10 |
-
REPO_ID = "3morrrrr/handwriting-synthesis-api" # Your model repo
|
| 11 |
-
FILENAMES = [
|
| 12 |
-
"checkpoints/checkpoint",
|
| 13 |
-
"checkpoints/model-17900.data-00000-of-00001",
|
| 14 |
-
"checkpoints/model-17900.index",
|
| 15 |
-
"checkpoints/model-17900.meta"
|
| 16 |
-
]
|
| 17 |
-
|
| 18 |
-
os.makedirs("checkpoints", exist_ok=True)
|
| 19 |
-
|
| 20 |
-
for filename in FILENAMES:
|
| 21 |
-
hf_hub_download(
|
| 22 |
-
repo_id=REPO_ID,
|
| 23 |
-
filename=filename,
|
| 24 |
-
local_dir=".", # or local_dir="checkpoints", up to you
|
| 25 |
-
)
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
# Download model on startup
|
| 29 |
-
try:
|
| 30 |
-
download_model()
|
| 31 |
-
except Exception as e:
|
| 32 |
-
raise RuntimeError(f"Model download failed: {str(e)}") from e
|
| 33 |
|
| 34 |
# Hugging Face Spaces requires app to run on port 7860
|
| 35 |
GRADIO_PORT = int(os.getenv("GRADIO_SERVER_PORT", "7860"))
|
|
|
|
| 5 |
from handwriting_api import InputData
|
| 6 |
from typing import List
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Hugging Face Spaces requires app to run on port 7860
|
| 10 |
GRADIO_PORT = int(os.getenv("GRADIO_SERVER_PORT", "7860"))
|