Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -26,21 +26,7 @@ headers = {"Authorization": f"Bearer {H_key}"}
|
|
26 |
def query_image_generation(payload, max_retries=5):
|
27 |
for attempt in range(max_retries):
|
28 |
response = requests.post(API_URL, headers=headers, json=payload)
|
29 |
-
|
30 |
-
if response.status_code == 503:
|
31 |
-
print(f"Model is still loading, retrying... Attempt {attempt + 1}/{max_retries}")
|
32 |
-
estimated_time = min(response.json().get("estimated_time", 60), 60)
|
33 |
-
time.sleep(estimated_time)
|
34 |
-
continue
|
35 |
-
|
36 |
-
if response.status_code != 200:
|
37 |
-
print(f"Error: Received status code {response.status_code}")
|
38 |
-
print(f"Response: {response.text}")
|
39 |
-
return None
|
40 |
-
|
41 |
return response.content
|
42 |
-
|
43 |
-
print(f"Failed to generate image after {max_retries} attempts.")
|
44 |
return None
|
45 |
|
46 |
# Function for generating an image from text
|
|
|
26 |
def query_image_generation(payload, max_retries=5):
|
27 |
for attempt in range(max_retries):
|
28 |
response = requests.post(API_URL, headers=headers, json=payload)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
return response.content
|
|
|
|
|
30 |
return None
|
31 |
|
32 |
# Function for generating an image from text
|