Update app.py
Browse files
app.py
CHANGED
@@ -183,12 +183,14 @@ def generate_image_hf(scene_idea, story):
|
|
183 |
"stabilityai/stable-diffusion-2-1",
|
184 |
"CompVis/stable-diffusion-v1-4"
|
185 |
]:
|
186 |
-
|
187 |
-
|
|
|
|
|
188 |
f"https://api-inference.huggingface.co/models/{model}",
|
189 |
headers={"Authorization": f"Bearer {HUGGINGFACE_API_KEY}"},
|
190 |
json={"inputs": prompt},
|
191 |
-
timeout=
|
192 |
)
|
193 |
logging.info(f"model: {model}, status:{res.status_code},response: {res.text[:300]}")
|
194 |
if res.status_code == 200:
|
|
|
183 |
"stabilityai/stable-diffusion-2-1",
|
184 |
"CompVis/stable-diffusion-v1-4"
|
185 |
]:
|
186 |
+
for model in model:
|
187 |
+
try:
|
188 |
+
logging.info(f"trying model: {model}")
|
189 |
+
res = requests.post(
|
190 |
f"https://api-inference.huggingface.co/models/{model}",
|
191 |
headers={"Authorization": f"Bearer {HUGGINGFACE_API_KEY}"},
|
192 |
json={"inputs": prompt},
|
193 |
+
timeout=15
|
194 |
)
|
195 |
logging.info(f"model: {model}, status:{res.status_code},response: {res.text[:300]}")
|
196 |
if res.status_code == 200:
|