Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import google.generativeai as genai
|
3 |
import requests
|
4 |
-
import
|
5 |
|
6 |
# List of popular styles
|
7 |
STYLES = [
|
@@ -51,29 +51,27 @@ def generate_image(stability_api_key, enhanced_prompt, style, negative_prompt):
|
|
51 |
url = "https://api.stability.ai/v2beta/stable-image/generate/sd3"
|
52 |
|
53 |
headers = {
|
54 |
-
"Accept": "
|
55 |
-
"Content-Type": "application/json",
|
56 |
"Authorization": f"Bearer {stability_api_key}"
|
57 |
}
|
58 |
|
59 |
-
|
60 |
-
"model": "sd3.5-large-turbo",
|
61 |
"prompt": f"{enhanced_prompt}, Style: {style}",
|
62 |
"negative_prompt": negative_prompt,
|
63 |
-
"
|
64 |
-
"
|
65 |
-
"
|
66 |
-
"
|
67 |
-
"
|
68 |
-
"
|
|
|
69 |
"output_format": "png"
|
70 |
}
|
71 |
|
72 |
-
response = requests.post(url,
|
73 |
|
74 |
if response.status_code == 200:
|
75 |
-
|
76 |
-
return base64.b64decode(image_data)
|
77 |
else:
|
78 |
raise Exception(f"Image generation failed: {response.text}")
|
79 |
|
|
|
1 |
import gradio as gr
|
2 |
import google.generativeai as genai
|
3 |
import requests
|
4 |
+
import io
|
5 |
|
6 |
# List of popular styles
|
7 |
STYLES = [
|
|
|
51 |
url = "https://api.stability.ai/v2beta/stable-image/generate/sd3"
|
52 |
|
53 |
headers = {
|
54 |
+
"Accept": "image/*",
|
|
|
55 |
"Authorization": f"Bearer {stability_api_key}"
|
56 |
}
|
57 |
|
58 |
+
data = {
|
|
|
59 |
"prompt": f"{enhanced_prompt}, Style: {style}",
|
60 |
"negative_prompt": negative_prompt,
|
61 |
+
"model": "sd3.5-large-turbo",
|
62 |
+
"width": "1024",
|
63 |
+
"height": "1024",
|
64 |
+
"num_images": "1",
|
65 |
+
"steps": "30",
|
66 |
+
"cfg_scale": "7.5",
|
67 |
+
"seed": "0",
|
68 |
"output_format": "png"
|
69 |
}
|
70 |
|
71 |
+
response = requests.post(url, headers=headers, data=data)
|
72 |
|
73 |
if response.status_code == 200:
|
74 |
+
return response.content
|
|
|
75 |
else:
|
76 |
raise Exception(f"Image generation failed: {response.text}")
|
77 |
|