Spaces:
Runtime error
Runtime error
styles fix
Browse files- __pycache__/app.cpython-311.pyc +0 -0
- app.py +17 -4
- loras_civit.json +3 -3
__pycache__/app.cpython-311.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
|
|
|
app.py
CHANGED
|
@@ -247,18 +247,30 @@ def get_civitai_safetensors(link):
|
|
| 247 |
model_id, version_id = parse_civitai_model_url(link)
|
| 248 |
session = requests.Session()
|
| 249 |
session.headers.update({"User-Agent": "flux-lora-lab/1.0"})
|
| 250 |
-
civitai_token =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
if civitai_token:
|
| 252 |
session.headers.update({"Authorization": f"Bearer {civitai_token}"})
|
| 253 |
selected_version = None
|
| 254 |
|
| 255 |
if version_id:
|
| 256 |
-
version_resp = session.get(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
version_resp.raise_for_status()
|
| 258 |
selected_version = version_resp.json()
|
| 259 |
title = selected_version.get("model", {}).get("name") or selected_version.get("name") or f"Civitai-{version_id}"
|
| 260 |
else:
|
| 261 |
-
model_resp = session.get(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
model_resp.raise_for_status()
|
| 263 |
model_data = model_resp.json()
|
| 264 |
title = model_data.get("name") or f"Civitai-{model_id}"
|
|
@@ -287,8 +299,9 @@ def get_civitai_safetensors(link):
|
|
| 287 |
except requests.HTTPError as e:
|
| 288 |
status_code = e.response.status_code if e.response is not None else None
|
| 289 |
if status_code == 401:
|
|
|
|
| 290 |
raise Exception(
|
| 291 |
-
"Civitai download unauthorized (401). Set CIVITAI_API_TOKEN in your Space/app secrets "
|
| 292 |
"or use a public direct .safetensors URL."
|
| 293 |
) from e
|
| 294 |
raise
|
|
|
|
| 247 |
model_id, version_id = parse_civitai_model_url(link)
|
| 248 |
session = requests.Session()
|
| 249 |
session.headers.update({"User-Agent": "flux-lora-lab/1.0"})
|
| 250 |
+
civitai_token = (
|
| 251 |
+
os.getenv("CIVITAI_API_TOKEN", "").strip()
|
| 252 |
+
or os.getenv("CIVITAI_TOKEN", "").strip()
|
| 253 |
+
)
|
| 254 |
+
token_params = {"token": civitai_token} if civitai_token else None
|
| 255 |
if civitai_token:
|
| 256 |
session.headers.update({"Authorization": f"Bearer {civitai_token}"})
|
| 257 |
selected_version = None
|
| 258 |
|
| 259 |
if version_id:
|
| 260 |
+
version_resp = session.get(
|
| 261 |
+
f"https://civitai.com/api/v1/model-versions/{version_id}",
|
| 262 |
+
params=token_params,
|
| 263 |
+
timeout=20
|
| 264 |
+
)
|
| 265 |
version_resp.raise_for_status()
|
| 266 |
selected_version = version_resp.json()
|
| 267 |
title = selected_version.get("model", {}).get("name") or selected_version.get("name") or f"Civitai-{version_id}"
|
| 268 |
else:
|
| 269 |
+
model_resp = session.get(
|
| 270 |
+
f"https://civitai.com/api/v1/models/{model_id}",
|
| 271 |
+
params=token_params,
|
| 272 |
+
timeout=20
|
| 273 |
+
)
|
| 274 |
model_resp.raise_for_status()
|
| 275 |
model_data = model_resp.json()
|
| 276 |
title = model_data.get("name") or f"Civitai-{model_id}"
|
|
|
|
| 299 |
except requests.HTTPError as e:
|
| 300 |
status_code = e.response.status_code if e.response is not None else None
|
| 301 |
if status_code == 401:
|
| 302 |
+
token_hint = "token detected but rejected" if civitai_token else "no token detected"
|
| 303 |
raise Exception(
|
| 304 |
+
f"Civitai download unauthorized (401): {token_hint}. Set CIVITAI_API_TOKEN in your Space/app secrets "
|
| 305 |
"or use a public direct .safetensors URL."
|
| 306 |
) from e
|
| 307 |
raise
|
loras_civit.json
CHANGED
|
@@ -42,10 +42,10 @@
|
|
| 42 |
"image": "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e4747aca-c37f-4300-ae68-70222276ffd3/original=true/26009851.jpeg"
|
| 43 |
},
|
| 44 |
{
|
| 45 |
-
"title": "
|
| 46 |
-
"civitai_url": "https://civitai.com/models/
|
| 47 |
"trigger_word": "",
|
| 48 |
"trigger_position": "append",
|
| 49 |
-
"image": "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/
|
| 50 |
}
|
| 51 |
]
|
|
|
|
| 42 |
"image": "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e4747aca-c37f-4300-ae68-70222276ffd3/original=true/26009851.jpeg"
|
| 43 |
},
|
| 44 |
{
|
| 45 |
+
"title": "Full Female Anatomy - Fineart Nudity - Flux Lora (NSFW) -Breasts/Pussy/Ass/and more",
|
| 46 |
+
"civitai_url": "https://civitai.com/models/668646/full-female-anatomy-fineart-nudity-flux-lora-nsfw-breastspussyassand-more?modelVersionId=748526",
|
| 47 |
"trigger_word": "",
|
| 48 |
"trigger_position": "append",
|
| 49 |
+
"image": "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/b39e8041-492b-42bd-aafe-67878cb0d80b/original=true/25350057.jpeg"
|
| 50 |
}
|
| 51 |
]
|