Yaron Koresh commited on
Commit
ebe916c
·
verified ·
1 Parent(s): f006a5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -79,14 +79,18 @@ def generate_random_string(length):
79
 
80
  @spaces.GPU(duration=50)
81
  def Piper(_do):
82
- return pipe(
83
- _do,
84
- height=512,
85
- width=768,
86
- num_inference_steps=50,
87
- max_sequence_length=512,
88
- guidance_scale=2
89
- )
 
 
 
 
90
 
91
  def infer(prompt_en):
92
  name = generate_random_string(12)+".png"
@@ -94,7 +98,11 @@ def infer(prompt_en):
94
  _do = 'photographed realistic scene'
95
  else:
96
  _do = f'photographed { prompt_en } realistic scene'
97
- Piper(_do).images[0].save(name)
 
 
 
 
98
  return name
99
 
100
  css="""
 
79
 
80
  @spaces.GPU(duration=50)
81
  def Piper(_do):
82
+ try:
83
+ retu = pipe(
84
+ _do,
85
+ height=512,
86
+ width=768,
87
+ num_inference_steps=50,
88
+ max_sequence_length=512,
89
+ guidance_scale=2
90
+ )
91
+ return retu
92
+ except:
93
+ return ""
94
 
95
  def infer(prompt_en):
96
  name = generate_random_string(12)+".png"
 
98
  _do = 'photographed realistic scene'
99
  else:
100
  _do = f'photographed { prompt_en } realistic scene'
101
+ output = Piper(_do)
102
+ if output == "":
103
+ return output
104
+ else:
105
+ output.images[0].save(name)
106
  return name
107
 
108
  css="""