artificialguybr
commited on
Commit
•
ddde7e5
1
Parent(s):
73af74b
Update app.py
Browse files
app.py
CHANGED
@@ -24,12 +24,19 @@ def generate_image(prompt):
|
|
24 |
},
|
25 |
}
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
# Criando a interface do Gradio
|
35 |
iface = gr.Interface(
|
|
|
24 |
},
|
25 |
}
|
26 |
|
27 |
+
try:
|
28 |
+
response = requests.post(api_url, headers=headers, json=payload)
|
29 |
+
response.raise_for_status() # Verifica se a requisição foi bem-sucedida
|
30 |
+
image_data = response.json().get("data", [])[0] # Obtém os dados da imagem
|
31 |
+
return Image.open(BytesIO(image_data))
|
32 |
+
except requests.exceptions.HTTPError as http_err:
|
33 |
+
print(f"HTTP error occurred: {http_err}")
|
34 |
+
except requests.exceptions.RequestException as err:
|
35 |
+
print(f"An error occurred: {err}")
|
36 |
+
except requests.exceptions.JSONDecodeError as json_err:
|
37 |
+
print(f"JSON decode error: {json_err}")
|
38 |
+
except Exception as e:
|
39 |
+
print(f"An unexpected error occurred: {e}")
|
40 |
|
41 |
# Criando a interface do Gradio
|
42 |
iface = gr.Interface(
|