Yaron Koresh commited on
Commit
ba73260
·
verified ·
1 Parent(s): 967386d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -78,10 +78,14 @@ def generate_random_string(length):
78
  return ''.join(random.choice(characters) for _ in range(length))
79
 
80
  @spaces.GPU(duration=45)
81
- def Piper(_do):
82
  try:
 
 
 
83
  retu = pipe(
84
  _do,
 
85
  height=512,
86
  width=512,
87
  num_inference_steps=40,
@@ -95,11 +99,13 @@ def Piper(_do):
95
  def infer(p1,p2):
96
  name = generate_random_string(12)+".png"
97
  _do = ['beautiful', 'playful', 'photographed', 'realistic', 'dynamic poze', 'deep field', 'reasonable coloring', 'rough texture', 'best quality', 'focused']
98
- if p2 != "":
99
- _do.append(f'invisible transparent {p2} in')
100
  if p1 != "":
101
  _do.append(f'{p1}')
102
- output = Piper('A '+" ".join(_do))
 
 
 
 
103
  if output == "":
104
  return output
105
  else:
 
78
  return ''.join(random.choice(characters) for _ in range(length))
79
 
80
  @spaces.GPU(duration=45)
81
+ def Piper(_do,_dont):
82
  try:
83
+ params = pipe._preprocess_params
84
+ neg = pipe.preprocess(_dont, **params).input_ids
85
+
86
  retu = pipe(
87
  _do,
88
+ neg_prompt_ids:neg,
89
  height=512,
90
  width=512,
91
  num_inference_steps=40,
 
99
  def infer(p1,p2):
100
  name = generate_random_string(12)+".png"
101
  _do = ['beautiful', 'playful', 'photographed', 'realistic', 'dynamic poze', 'deep field', 'reasonable coloring', 'rough texture', 'best quality', 'focused']
 
 
102
  if p1 != "":
103
  _do.append(f'{p1}')
104
+ if p2 != "":
105
+ _dont = f'{p2} where in {p1}'
106
+ else:
107
+ _dont = ""
108
+ output = Piper('A '+" ".join(_do),_dont)
109
  if output == "":
110
  return output
111
  else: