EnigmaOfTheWorld commited on
Commit
23f602c
β€’
1 Parent(s): 3d7fefb

Added exception handling on line 66

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -67,15 +67,18 @@ def transform_ncuda(img,prompt,cfg=8.0,stps=30,sc=0.8):
67
  print('----------------------------------------------------------------------------------')
68
  print(f'{resp}')
69
  print(f'DEBUG: Type = {resp.__class__}')
70
- for artifact in resp.artifacts:
71
- if artifact.finish_reason == generation.FILTER:
72
- warnings.warn(
73
- "Your request activated the API's safety filters and could not be processed."
74
- "Please modify the prompt and try again.")
75
- if artifact.type == generation.ARTIFACT_IMAGE:
76
- global img2
77
- img2 = Image.open(io.BytesIO(artifact.binary))
78
- return img2
 
 
 
79
  # img2.save(str(artifact.seed)+ "-img2img.png") # Save our generated image with its seed number as the filename and the img2img suffix so that we know this is our transformed image.
80
 
81
 
 
67
  print('----------------------------------------------------------------------------------')
68
  print(f'{resp}')
69
  print(f'DEBUG: Type = {resp.__class__}')
70
+ try:
71
+ for artifact in resp.artifacts:
72
+ if artifact.finish_reason == generation.FILTER:
73
+ warnings.warn(
74
+ "Your request activated the API's safety filters and could not be processed."
75
+ "Please modify the prompt and try again.")
76
+ if artifact.type == generation.ARTIFACT_IMAGE:
77
+ global img2
78
+ img2 = Image.open(io.BytesIO(artifact.binary))
79
+ return img2
80
+ except Exception as e:
81
+ print(f'Caught error: {e}')
82
  # img2.save(str(artifact.seed)+ "-img2img.png") # Save our generated image with its seed number as the filename and the img2img suffix so that we know this is our transformed image.
83
 
84