fffiloni commited on
Commit
5672e0b
1 Parent(s): aef3e4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -14,9 +14,6 @@ from diffusers.models import SD3ControlNetModel, SD3MultiControlNetModel
14
  from diffusers.utils import load_image
15
 
16
  # load pipeline
17
- global pipe_canny
18
- global pipe_tile
19
- global pipe
20
  controlnet_canny = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Canny")
21
  controlnet_tile = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Tile")
22
 
@@ -42,14 +39,17 @@ def resize_image(input_path, output_path, target_height):
42
  def show_hidden():
43
  return gr.update(visible=True)
44
 
45
- def load_pipeline(control_type):
 
46
  if control_type == "canny":
 
47
  pipe_canny = StableDiffusion3ControlNetPipeline.from_pretrained(
48
  "stabilityai/stable-diffusion-3-medium-diffusers",
49
  controlnet=controlnet_canny
50
  )
51
  elif control_type == "tile":
52
- pipe_tile = StableDiffusion3ControlNetPipeline.from_pretrained(
 
53
  "stabilityai/stable-diffusion-3-medium-diffusers",
54
  controlnet=controlnet_tile
55
  )
@@ -57,7 +57,7 @@ def load_pipeline(control_type):
57
 
58
  @spaces.GPU(duration=90)
59
  def infer(image_in, prompt, control_type, inference_steps, guidance_scale, control_weight, progress=gr.Progress(track_tqdm=True)):
60
-
61
  n_prompt = 'NSFW, nude, naked, porn, ugly'
62
 
63
  if control_type == "canny":
@@ -135,8 +135,9 @@ with gr.Blocks(css=css) as demo:
135
  control_weight = gr.Slider(label="Control Weight", minimum=0.0, maximum=1.0, step=0.01, value=0.7)
136
 
137
  submit_canny_btn = gr.Button("Submit")
138
- models = gr.Textbox(visible=False)
139
  with gr.Column():
 
140
  result = gr.Image(label="Result")
141
  canny_used = gr.Image(label="Preprocessed Canny", visible=False)
142
 
 
14
  from diffusers.utils import load_image
15
 
16
  # load pipeline
 
 
 
17
  controlnet_canny = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Canny")
18
  controlnet_tile = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Tile")
19
 
 
39
  def show_hidden():
40
  return gr.update(visible=True)
41
 
42
+ def load_pipeline(control_type, progress=gr.Progress(track_tqdm=True)):
43
+ global pipe_canny, pipe_tile
44
  if control_type == "canny":
45
+ global pipe_canny
46
  pipe_canny = StableDiffusion3ControlNetPipeline.from_pretrained(
47
  "stabilityai/stable-diffusion-3-medium-diffusers",
48
  controlnet=controlnet_canny
49
  )
50
  elif control_type == "tile":
51
+ global pipe_tile
52
+ pipe_tile = StableDiffusion3ControlNetPipeline.from_pretrained(
53
  "stabilityai/stable-diffusion-3-medium-diffusers",
54
  controlnet=controlnet_tile
55
  )
 
57
 
58
  @spaces.GPU(duration=90)
59
  def infer(image_in, prompt, control_type, inference_steps, guidance_scale, control_weight, progress=gr.Progress(track_tqdm=True)):
60
+ global pipe, pipe_canny, pipe_tile
61
  n_prompt = 'NSFW, nude, naked, porn, ugly'
62
 
63
  if control_type == "canny":
 
135
  control_weight = gr.Slider(label="Control Weight", minimum=0.0, maximum=1.0, step=0.01, value=0.7)
136
 
137
  submit_canny_btn = gr.Button("Submit")
138
+
139
  with gr.Column():
140
+ models = gr.Textbox(label="Plug-in pipes", visible=False)
141
  result = gr.Image(label="Result")
142
  canny_used = gr.Image(label="Preprocessed Canny", visible=False)
143