Spaces:
Build error
Build error
PatrickSchrML
commited on
Commit
·
05fd97a
1
Parent(s):
eed8479
error message if output not available
Browse files
app.py
CHANGED
@@ -44,9 +44,12 @@ def infer(prompt, n_samples, steps, scale, seed):
|
|
44 |
response = requests.get(url.format(prompt, int(n_samples), max(50,int(steps)), f'{scale:.1f}', int(seed)))
|
45 |
#response = requests.get(url.format('a%20naked%20girl', 2, 50, 7.5, 2))
|
46 |
data = json.load(BytesIO(response.content))
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
|
51 |
# payload = {'prompt': prompt}
|
52 |
# images_request = requests.post(url, json=payload)
|
|
|
44 |
response = requests.get(url.format(prompt, int(n_samples), max(50,int(steps)), f'{scale:.1f}', int(seed)))
|
45 |
#response = requests.get(url.format('a%20naked%20girl', 2, 50, 7.5, 2))
|
46 |
data = json.load(BytesIO(response.content))
|
47 |
+
if 'output' not in data:
|
48 |
+
raise gr.Error("Although safety guidance is enabled, potential unsafe content found. Please try again with different seed.")
|
49 |
+
else:
|
50 |
+
for image in data['output']['choices']:
|
51 |
+
im = Image.open(BytesIO(base64.b64decode(image['image_base64'])))
|
52 |
+
images.append(im)
|
53 |
|
54 |
# payload = {'prompt': prompt}
|
55 |
# images_request = requests.post(url, json=payload)
|