| """ |
| Deploy the Krea 2 Character Design Space. |
| |
| Run this AFTER the account has HuggingFace PRO (required to host Gradio Spaces). |
| It creates the Space and uploads the app files from this folder. |
| |
| HF_TOKEN=hf_xxx python deploy_space.py |
| """ |
| import os |
| from huggingface_hub import HfApi |
|
|
| TOKEN = os.environ["HF_TOKEN"] |
| SPACE = os.environ.get("SPACE", "that-username-is-not-available/Krea-Char-Design-Space") |
| DS = os.environ.get("DATASET_REPO", "that-username-is-not-available/Krea-Char-Design-Data") |
|
|
| api = HfApi(token=TOKEN) |
| api.create_repo(SPACE, repo_type="space", space_sdk="gradio", exist_ok=True) |
|
|
| for f in ["app.py", "requirements.txt", "README.md", ".gitignore"]: |
| api.upload_file(path_or_fileobj=f, path_in_repo=f, repo_id=SPACE, repo_type="space") |
| print("uploaded", f) |
|
|
| api.add_space_secret(repo_id=SPACE, key="HF_TOKEN", value=TOKEN) |
| api.add_space_variable(repo_id=SPACE, key="BASE_MODEL", value="krea/Krea-2-Turbo") |
| api.add_space_variable(repo_id=SPACE, key="DATASET_REPO", value=DS) |
|
|
| |
| |
|
|
| print("Space: https://huggingface.co/spaces/" + SPACE) |
|
|