Spaces:
Runtime error
Runtime error
Update text2image.py
Browse files- text2image.py +2 -7
text2image.py
CHANGED
@@ -3,14 +3,9 @@ import os
|
|
3 |
import json
|
4 |
STABLE_API = os.getenv("STABLE_API")
|
5 |
|
6 |
-
def generate_image(
|
7 |
url = "https://stablediffusionapi.com/api/v3/text2img"
|
8 |
|
9 |
-
if additional:
|
10 |
-
prompt = f"{additional} at {user_input} in {location},{country} with the weather consisting of {weather} and {description}"
|
11 |
-
else:
|
12 |
-
prompt = f"{user_input} in {location},{country} with the weather consisting of {weather} and {description}"
|
13 |
-
|
14 |
payload = json.dumps({
|
15 |
"key": STABLE_API,
|
16 |
"prompt": prompt,
|
@@ -36,4 +31,4 @@ def generate_image(location, weather, country, description, user_input, addition
|
|
36 |
}
|
37 |
|
38 |
response = requests.request("POST", url, headers=headers, data=payload)
|
39 |
-
return response.json()["output"][0]
|
|
|
3 |
import json
|
4 |
STABLE_API = os.getenv("STABLE_API")
|
5 |
|
6 |
+
def generate_image(prompt):
|
7 |
url = "https://stablediffusionapi.com/api/v3/text2img"
|
8 |
|
|
|
|
|
|
|
|
|
|
|
9 |
payload = json.dumps({
|
10 |
"key": STABLE_API,
|
11 |
"prompt": prompt,
|
|
|
31 |
}
|
32 |
|
33 |
response = requests.request("POST", url, headers=headers, data=payload)
|
34 |
+
return response.json()["output"][0]
|