Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import subprocess
|
|
| 3 |
from typing import Union
|
| 4 |
from huggingface_hub import whoami
|
| 5 |
from huggingface_hub import HfApi
|
|
|
|
| 6 |
from huggingface_hub import upload_folder
|
| 7 |
is_spaces = True if os.environ.get("SPACE_ID") else False
|
| 8 |
|
|
@@ -178,6 +179,8 @@ def start_training(
|
|
| 178 |
profile: Union[gr.OAuthProfile, None],
|
| 179 |
oauth_token: Union[gr.OAuthToken, None],
|
| 180 |
):
|
|
|
|
|
|
|
| 181 |
|
| 182 |
if not lora_name:
|
| 183 |
raise gr.Error("You forgot to insert your LoRA name! This name has to be unique.")
|
|
@@ -201,6 +204,15 @@ def start_training(
|
|
| 201 |
print(f"Created model repo {model_repo_id}")
|
| 202 |
except Exception as e:
|
| 203 |
print(f"Model repo might already exist: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
|
| 205 |
# Load the default config
|
| 206 |
with open("train_lora_flux_24gb.yaml" if is_spaces else "ai-toolkit/config/examples/train_lora_flux_24gb.yaml", "r") as f:
|
|
@@ -273,7 +285,7 @@ def start_training(
|
|
| 273 |
# command to run autotrain spacerunner
|
| 274 |
# --- Pre-create subspace and inject token ---
|
| 275 |
hf_token = oauth_token.token
|
| 276 |
-
api = HfApi(token=hf_token)
|
| 277 |
new_space_id = f"{profile.username}/autotrain-{slugged_lora_name}"
|
| 278 |
|
| 279 |
try:
|
|
|
|
| 3 |
from typing import Union
|
| 4 |
from huggingface_hub import whoami
|
| 5 |
from huggingface_hub import HfApi
|
| 6 |
+
from huggingface_hub import HfHubHTTPError
|
| 7 |
from huggingface_hub import upload_folder
|
| 8 |
is_spaces = True if os.environ.get("SPACE_ID") else False
|
| 9 |
|
|
|
|
| 179 |
profile: Union[gr.OAuthProfile, None],
|
| 180 |
oauth_token: Union[gr.OAuthToken, None],
|
| 181 |
):
|
| 182 |
+
|
| 183 |
+
api = HfApi(token=hf_token)
|
| 184 |
|
| 185 |
if not lora_name:
|
| 186 |
raise gr.Error("You forgot to insert your LoRA name! This name has to be unique.")
|
|
|
|
| 204 |
print(f"Created model repo {model_repo_id}")
|
| 205 |
except Exception as e:
|
| 206 |
print(f"Model repo might already exist: {e}")
|
| 207 |
+
# try:
|
| 208 |
+
# api.create_repo(repo_id=model_repo_id, repo_type="model", private=True)
|
| 209 |
+
# print(f"Created model repo {model_repo_id}")
|
| 210 |
+
# except HfHubHTTPError as e:
|
| 211 |
+
# if e.response is not None and e.response.status_code == 409:
|
| 212 |
+
# print(f"Model repo {model_repo_id} already exists, continuing.")
|
| 213 |
+
# else:
|
| 214 |
+
# raise e
|
| 215 |
+
|
| 216 |
|
| 217 |
# Load the default config
|
| 218 |
with open("train_lora_flux_24gb.yaml" if is_spaces else "ai-toolkit/config/examples/train_lora_flux_24gb.yaml", "r") as f:
|
|
|
|
| 285 |
# command to run autotrain spacerunner
|
| 286 |
# --- Pre-create subspace and inject token ---
|
| 287 |
hf_token = oauth_token.token
|
| 288 |
+
# api = HfApi(token=hf_token)
|
| 289 |
new_space_id = f"{profile.username}/autotrain-{slugged_lora_name}"
|
| 290 |
|
| 291 |
try:
|