Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -27,13 +27,12 @@ def query(prompt, model, custom_lora, is_negative=False, steps=35, cfg_scale=7,
|
|
27 |
prompt = f"{prompt} | ultra detail, ultra elaboration, ultra quality, perfect."
|
28 |
print(f'Generation {key}: {prompt}')
|
29 |
|
|
|
30 |
try:
|
31 |
-
|
|
|
|
|
32 |
|
33 |
-
# Set API URL based on model selection
|
34 |
-
if custom_lora.strip():
|
35 |
-
API_URL = f"https://api-inference.huggingface.co/models/{custom_lora.strip()}"
|
36 |
-
else:
|
37 |
if model == 'Stable Diffusion XL':
|
38 |
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
|
39 |
if model == 'FLUX.1 [Dev]':
|
@@ -257,12 +256,12 @@ def query(prompt, model, custom_lora, is_negative=False, steps=35, cfg_scale=7,
|
|
257 |
|
258 |
except requests.exceptions.RequestException as e:
|
259 |
error_message = f"Request failed: {str(e)}"
|
260 |
-
if response:
|
261 |
-
if response.status_code == 401:
|
262 |
error_message = "Invalid API token. Please check your Hugging Face API token."
|
263 |
-
elif response.status_code == 403:
|
264 |
error_message = "Access denied. Please check your API token permissions."
|
265 |
-
elif response.status_code == 503:
|
266 |
error_message = "Model is currently loading. Please try again in a few moments."
|
267 |
raise gr.Error(error_message)
|
268 |
except Exception as e:
|
|
|
27 |
prompt = f"{prompt} | ultra detail, ultra elaboration, ultra quality, perfect."
|
28 |
print(f'Generation {key}: {prompt}')
|
29 |
|
30 |
+
# Set API URL based on model selection
|
31 |
try:
|
32 |
+
if custom_lora.strip():
|
33 |
+
API_URL = f"https://api-inference.huggingface.co/models/{custom_lora.strip()}"
|
34 |
+
else:
|
35 |
|
|
|
|
|
|
|
|
|
36 |
if model == 'Stable Diffusion XL':
|
37 |
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
|
38 |
if model == 'FLUX.1 [Dev]':
|
|
|
256 |
|
257 |
except requests.exceptions.RequestException as e:
|
258 |
error_message = f"Request failed: {str(e)}"
|
259 |
+
if hasattr(e, 'response') and e.response is not None:
|
260 |
+
if e.response.status_code == 401:
|
261 |
error_message = "Invalid API token. Please check your Hugging Face API token."
|
262 |
+
elif e.response.status_code == 403:
|
263 |
error_message = "Access denied. Please check your API token permissions."
|
264 |
+
elif e.response.status_code == 503:
|
265 |
error_message = "Model is currently loading. Please try again in a few moments."
|
266 |
raise gr.Error(error_message)
|
267 |
except Exception as e:
|