File size: 1,195 Bytes
d809f63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
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)

# Optional: request ZeroGPU hardware (needs PRO). Uncomment to enable:
# api.request_space_hardware(repo_id=SPACE, hardware="zero-a10g")

print("Space: https://huggingface.co/spaces/" + SPACE)