Yaron Koresh commited on
Commit
f2a0e5e
·
verified ·
1 Parent(s): 6135cbc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -8,7 +8,7 @@ import requests
8
  import gradio as gr
9
  import numpy as np
10
  from lxml.html import fromstring
11
- from pathos.threading import ThreadPool as Pool
12
  #from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler
13
  from diffusers.pipelines.flux import FluxPipeline
14
  #from diffusers.utils import export_to_gif
@@ -77,14 +77,14 @@ def generate_random_string(length):
77
  characters = string.ascii_letters + string.digits
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=448,
86
  width=448,
87
- num_inference_steps=8,
88
  max_sequence_length=256,
89
  guidance_scale=0
90
  )
@@ -96,10 +96,10 @@ def infer(p1,p2):
96
  name = generate_random_string(12)+".png"
97
  _do = ['beautiful', 'playful', 'photographed', 'highly detailed', 'realistic elements', 'dynamic poze', 'deep field', 'vivid reasonable coloring', 'rough texture', 'high sharpness', 'highres', 'best quality', 'focused']
98
  if p1 != "":
99
- _do.append(f'add {p1}')
100
  if p2 != "":
101
- _do.append(f'hide {p2}')
102
- output = Piper(" while ".join(_do))
103
  if output == "":
104
  return output
105
  else:
@@ -184,7 +184,7 @@ with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
184
  idxs = list(range(ln))
185
  p1s = [p1_en for _ in idxs]
186
  p2s = [p2_en for _ in idxs]
187
- return list(Pool(ln).imap( _ret, idxs, p1s, p2s ))
188
  run_button.click(fn=_rets,inputs=[prompt,prompt2],outputs=result)
189
 
190
  demo.queue().launch()
 
8
  import gradio as gr
9
  import numpy as np
10
  from lxml.html import fromstring
11
+ from pathos.multiprocessig import ProcessPool as Pool
12
  #from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler
13
  from diffusers.pipelines.flux import FluxPipeline
14
  #from diffusers.utils import export_to_gif
 
77
  characters = string.ascii_letters + string.digits
78
  return ''.join(random.choice(characters) for _ in range(length))
79
 
80
+ @spaces.GPU(duration=25)
81
  def Piper(_do):
82
  try:
83
  retu = pipe(
84
  _do,
85
  height=448,
86
  width=448,
87
+ num_inference_steps=2,
88
  max_sequence_length=256,
89
  guidance_scale=0
90
  )
 
96
  name = generate_random_string(12)+".png"
97
  _do = ['beautiful', 'playful', 'photographed', 'highly detailed', 'realistic elements', 'dynamic poze', 'deep field', 'vivid reasonable coloring', 'rough texture', 'high sharpness', 'highres', 'best quality', 'focused']
98
  if p1 != "":
99
+ _do.append(f'including {p1}')
100
  if p2 != "":
101
+ _do.append(f'excluding {p2}')
102
+ output = Piper('if '+" while ".join(_do))
103
  if output == "":
104
  return output
105
  else:
 
184
  idxs = list(range(ln))
185
  p1s = [p1_en for _ in idxs]
186
  p2s = [p2_en for _ in idxs]
187
+ return list(Pool(ln).amap( _ret, idxs, p1s, p2s ))
188
  run_button.click(fn=_rets,inputs=[prompt,prompt2],outputs=result)
189
 
190
  demo.queue().launch()