Yaron Koresh commited on
Commit
9154d2d
·
verified ·
1 Parent(s): 1d36949

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -66,42 +66,44 @@ def generate_random_string(length):
66
  return ''.join(random.choice(characters) for _ in range(length))
67
 
68
  @spaces.GPU
69
- def Piper(_do,_dont):
70
  return pipe(
71
  _do,
72
  height=480,
73
  width=480,
74
- negative_prompt=_dont,
75
- num_inference_steps=80,
76
- guidance_scale=6
77
  )
78
 
79
  def infer(prompt1,prompt2,prompt3,prompt4):
80
  name = generate_random_string(12)+".png"
81
 
82
  if prompt4 == None:
83
- prompt4 = "text and logos"
84
  else:
85
- prompt4 = "text and logos and " + " and ".join([translate(v,"english") for v in prompt4])
86
 
 
 
87
  if prompt1 == None:
88
  prompt1 = "element"
89
  else:
90
- prompt1 = " and ".join([ (translate(v,"english").upper()) for v in prompt1 ])
91
 
92
  if prompt2 == None:
93
  prompt2 = "elements"
94
  else:
95
- prompt2 = " and ".join([ (translate(v,"english").upper()) for v in prompt2 ])
96
 
97
  if prompt3 == None:
98
  prompt3 = "event"
99
  else:
100
  prompt3 = " ".join([translate(v,"english").upper() for v in prompt3]) + " event"
101
 
102
- _do = f'Accuratly produce in a sensible way: {prompt3}, focusing on {prompt1}, including {prompt2}, excluding {prompt4}'
103
 
104
- image = Piper(_do,prompt4).images[0].save(name)
105
  return name
106
 
107
  css="""
@@ -142,7 +144,7 @@ with gr.Blocks(theme=gr.themes.Soft(),css=css) as demo:
142
  prompt2 = gr.Dropdown(
143
  multiselect=True,
144
  allow_custom_value=True,
145
- max_choices=3,
146
  label="Background Elements",
147
  show_label=True,
148
  container=True
@@ -160,7 +162,7 @@ with gr.Blocks(theme=gr.themes.Soft(),css=css) as demo:
160
  prompt4 = gr.Dropdown(
161
  multiselect=True,
162
  allow_custom_value=True,
163
- max_choices=4,
164
  label="Forbidden Elements/Events",
165
  show_label=True,
166
  container=True
 
66
  return ''.join(random.choice(characters) for _ in range(length))
67
 
68
  @spaces.GPU
69
+ def Piper(_do):
70
  return pipe(
71
  _do,
72
  height=480,
73
  width=480,
74
+ negative_prompt="",
75
+ num_inference_steps=100,
76
+ guidance_scale=9
77
  )
78
 
79
  def infer(prompt1,prompt2,prompt3,prompt4):
80
  name = generate_random_string(12)+".png"
81
 
82
  if prompt4 == None:
83
+ prompt4 = " excluding, text, logos"
84
  else:
85
+ prompt4 = " excluding, text, logos, " + ", ".join([translate(v,"english") for v in prompt4])
86
 
87
+ prompt4 = prompt4.upper()
88
+
89
  if prompt1 == None:
90
  prompt1 = "element"
91
  else:
92
+ prompt1 = ", and ".join([ (translate(v,"english")+" "+prompt4) for v in prompt1 ])
93
 
94
  if prompt2 == None:
95
  prompt2 = "elements"
96
  else:
97
+ prompt2 = ", and ".join([ (translate(v,"english")+" "+prompt4) for v in prompt2 ])
98
 
99
  if prompt3 == None:
100
  prompt3 = "event"
101
  else:
102
  prompt3 = " ".join([translate(v,"english").upper() for v in prompt3]) + " event"
103
 
104
+ _do = f'Produce, in a sensible way, {prompt3}, including, {prompt2}, glorifying, {prompt1}'
105
 
106
+ image = Piper(_do).images[0].save(name)
107
  return name
108
 
109
  css="""
 
144
  prompt2 = gr.Dropdown(
145
  multiselect=True,
146
  allow_custom_value=True,
147
+ max_choices=2,
148
  label="Background Elements",
149
  show_label=True,
150
  container=True
 
162
  prompt4 = gr.Dropdown(
163
  multiselect=True,
164
  allow_custom_value=True,
165
+ max_choices=2,
166
  label="Forbidden Elements/Events",
167
  show_label=True,
168
  container=True