Spaces:
Runtime error
Runtime error
Commit
Β·
8d1595e
1
Parent(s):
e2a97fe
Update app.py
Browse files
app.py
CHANGED
@@ -66,21 +66,22 @@ def transform_ncuda(img,prompt,cfg=8.0,stps=30,sc=0.8):
|
|
66 |
|
67 |
# Set up our warning to print to the console if the adult content classifier is tripped.
|
68 |
# If adult content classifier is not tripped, display generated image.
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
74 |
for artifact in resp.artifacts:
|
75 |
if artifact.finish_reason == generation.FILTER:
|
76 |
warnings.warn(
|
77 |
-
|
78 |
-
|
79 |
if artifact.type == generation.ARTIFACT_IMAGE:
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
raise gr.Error("Input image from sketch")
|
85 |
# print(f'Caught error: {e}')
|
86 |
# logging.warn(f'Caught error: {e}')
|
|
|
66 |
|
67 |
# Set up our warning to print to the console if the adult content classifier is tripped.
|
68 |
# If adult content classifier is not tripped, display generated image.
|
69 |
+
try:
|
70 |
+
for resp in answers2:
|
71 |
+
print('----------------------------------------------------------------------------------')
|
72 |
+
print(f'{resp}')
|
73 |
+
print(f'DEBUG: Type = {resp.__class__}')
|
74 |
+
|
75 |
for artifact in resp.artifacts:
|
76 |
if artifact.finish_reason == generation.FILTER:
|
77 |
warnings.warn(
|
78 |
+
"Your request activated the API's safety filters and could not be processed."
|
79 |
+
"Please modify the prompt and try again.")
|
80 |
if artifact.type == generation.ARTIFACT_IMAGE:
|
81 |
+
global img2
|
82 |
+
img2 = Image.open(io.BytesIO(artifact.binary))
|
83 |
+
return img2
|
84 |
+
except Exception as e:
|
85 |
raise gr.Error("Input image from sketch")
|
86 |
# print(f'Caught error: {e}')
|
87 |
# logging.warn(f'Caught error: {e}')
|