hysts HF staff commited on
Commit
753523a
1 Parent(s): 837d8ee

gradio==5.6.0

Browse files
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.10
README.md CHANGED
@@ -4,8 +4,7 @@ emoji: 📉
4
  colorFrom: yellow
5
  colorTo: green
6
  sdk: gradio
7
- sdk_version: 3.45.2
8
- python_version: 3.10.11
9
  app_file: app.py
10
  pinned: false
11
  license: mit
 
4
  colorFrom: yellow
5
  colorTo: green
6
  sdk: gradio
7
+ sdk_version: 5.6.0
 
8
  app_file: app.py
9
  pinned: false
10
  license: mit
app.py CHANGED
@@ -27,7 +27,7 @@ if not torch.cuda.is_available():
27
 
28
  model = Model(base_model_id=DEFAULT_MODEL_ID, task_name="Canny")
29
 
30
- with gr.Blocks(css="style.css") as demo:
31
  gr.Markdown(DESCRIPTION)
32
  gr.DuplicateButton(
33
  value="Duplicate Space for private use",
@@ -36,29 +36,29 @@ with gr.Blocks(css="style.css") as demo:
36
  )
37
 
38
  with gr.Tabs():
39
- with gr.TabItem("Canny"):
40
  create_demo_canny(model.process_canny)
41
- with gr.TabItem("MLSD"):
42
  create_demo_mlsd(model.process_mlsd)
43
- with gr.TabItem("Scribble"):
44
  create_demo_scribble(model.process_scribble)
45
- with gr.TabItem("Scribble Interactive"):
46
  create_demo_scribble_interactive(model.process_scribble_interactive)
47
- with gr.TabItem("SoftEdge"):
48
  create_demo_softedge(model.process_softedge)
49
- with gr.TabItem("OpenPose"):
50
  create_demo_openpose(model.process_openpose)
51
- with gr.TabItem("Segmentation"):
52
  create_demo_segmentation(model.process_segmentation)
53
- with gr.TabItem("Depth"):
54
  create_demo_depth(model.process_depth)
55
- with gr.TabItem("Normal map"):
56
  create_demo_normal(model.process_normal)
57
- with gr.TabItem("Lineart"):
58
  create_demo_lineart(model.process_lineart)
59
- with gr.TabItem("Content Shuffle"):
60
  create_demo_shuffle(model.process_shuffle)
61
- with gr.TabItem("Instruct Pix2Pix"):
62
  create_demo_ip2p(model.process_ip2p)
63
 
64
  with gr.Accordion(label="Base model", open=False):
@@ -72,7 +72,7 @@ with gr.Blocks(css="style.css") as demo:
72
  new_base_model_id = gr.Text(
73
  label="New base model",
74
  max_lines=1,
75
- placeholder="runwayml/stable-diffusion-v1-5",
76
  info="The base model must be compatible with Stable Diffusion v1.5.",
77
  interactive=ALLOW_CHANGING_BASE_MODEL,
78
  )
@@ -95,6 +95,7 @@ with gr.Blocks(css="style.css") as demo:
95
  inputs=new_base_model_id,
96
  outputs=current_base_model,
97
  api_name=False,
 
98
  )
99
 
100
  if __name__ == "__main__":
 
27
 
28
  model = Model(base_model_id=DEFAULT_MODEL_ID, task_name="Canny")
29
 
30
+ with gr.Blocks(css_paths="style.css") as demo:
31
  gr.Markdown(DESCRIPTION)
32
  gr.DuplicateButton(
33
  value="Duplicate Space for private use",
 
36
  )
37
 
38
  with gr.Tabs():
39
+ with gr.Tab("Canny"):
40
  create_demo_canny(model.process_canny)
41
+ with gr.Tab("MLSD"):
42
  create_demo_mlsd(model.process_mlsd)
43
+ with gr.Tab("Scribble"):
44
  create_demo_scribble(model.process_scribble)
45
+ with gr.Tab("Scribble Interactive"):
46
  create_demo_scribble_interactive(model.process_scribble_interactive)
47
+ with gr.Tab("SoftEdge"):
48
  create_demo_softedge(model.process_softedge)
49
+ with gr.Tab("OpenPose"):
50
  create_demo_openpose(model.process_openpose)
51
+ with gr.Tab("Segmentation"):
52
  create_demo_segmentation(model.process_segmentation)
53
+ with gr.Tab("Depth"):
54
  create_demo_depth(model.process_depth)
55
+ with gr.Tab("Normal map"):
56
  create_demo_normal(model.process_normal)
57
+ with gr.Tab("Lineart"):
58
  create_demo_lineart(model.process_lineart)
59
+ with gr.Tab("Content Shuffle"):
60
  create_demo_shuffle(model.process_shuffle)
61
+ with gr.Tab("Instruct Pix2Pix"):
62
  create_demo_ip2p(model.process_ip2p)
63
 
64
  with gr.Accordion(label="Base model", open=False):
 
72
  new_base_model_id = gr.Text(
73
  label="New base model",
74
  max_lines=1,
75
+ placeholder="stable-diffusion-v1-5/stable-diffusion-v1-5",
76
  info="The base model must be compatible with Stable Diffusion v1.5.",
77
  interactive=ALLOW_CHANGING_BASE_MODEL,
78
  )
 
95
  inputs=new_base_model_id,
96
  outputs=current_base_model,
97
  api_name=False,
98
+ concurrency_id="main",
99
  )
100
 
101
  if __name__ == "__main__":
app_canny.py CHANGED
@@ -17,8 +17,7 @@ def create_demo(process):
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
- prompt = gr.Textbox(label="Prompt")
21
- run_button = gr.Button("Run")
22
  with gr.Accordion("Advanced options", open=False):
23
  num_samples = gr.Slider(
24
  label="Number of images", minimum=1, maximum=MAX_NUM_IMAGES, value=DEFAULT_NUM_IMAGES, step=1
@@ -66,23 +65,12 @@ def create_demo(process):
66
  outputs=seed,
67
  queue=False,
68
  api_name=False,
69
- ).then(
70
- fn=process,
71
- inputs=inputs,
72
- outputs=result,
73
- api_name=False,
74
- )
75
- run_button.click(
76
- fn=randomize_seed_fn,
77
- inputs=[seed, randomize_seed],
78
- outputs=seed,
79
- queue=False,
80
- api_name=False,
81
  ).then(
82
  fn=process,
83
  inputs=inputs,
84
  outputs=result,
85
  api_name="canny",
 
86
  )
87
  return demo
88
 
 
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
+ prompt = gr.Textbox(label="Prompt", submit_btn=True)
 
21
  with gr.Accordion("Advanced options", open=False):
22
  num_samples = gr.Slider(
23
  label="Number of images", minimum=1, maximum=MAX_NUM_IMAGES, value=DEFAULT_NUM_IMAGES, step=1
 
65
  outputs=seed,
66
  queue=False,
67
  api_name=False,
 
 
 
 
 
 
 
 
 
 
 
 
68
  ).then(
69
  fn=process,
70
  inputs=inputs,
71
  outputs=result,
72
  api_name="canny",
73
+ concurrency_id="main",
74
  )
75
  return demo
76
 
app_depth.py CHANGED
@@ -17,8 +17,7 @@ def create_demo(process):
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
- prompt = gr.Textbox(label="Prompt")
21
- run_button = gr.Button("Run")
22
  with gr.Accordion("Advanced options", open=False):
23
  preprocessor_name = gr.Radio(
24
  label="Preprocessor", choices=["Midas", "DPT", "None"], type="value", value="DPT"
@@ -66,23 +65,12 @@ def create_demo(process):
66
  outputs=seed,
67
  queue=False,
68
  api_name=False,
69
- ).then(
70
- fn=process,
71
- inputs=inputs,
72
- outputs=result,
73
- api_name=False,
74
- )
75
- run_button.click(
76
- fn=randomize_seed_fn,
77
- inputs=[seed, randomize_seed],
78
- outputs=seed,
79
- queue=False,
80
- api_name=False,
81
  ).then(
82
  fn=process,
83
  inputs=inputs,
84
  outputs=result,
85
  api_name="depth",
 
86
  )
87
  return demo
88
 
 
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
+ prompt = gr.Textbox(label="Prompt", submit_btn=True)
 
21
  with gr.Accordion("Advanced options", open=False):
22
  preprocessor_name = gr.Radio(
23
  label="Preprocessor", choices=["Midas", "DPT", "None"], type="value", value="DPT"
 
65
  outputs=seed,
66
  queue=False,
67
  api_name=False,
 
 
 
 
 
 
 
 
 
 
 
 
68
  ).then(
69
  fn=process,
70
  inputs=inputs,
71
  outputs=result,
72
  api_name="depth",
73
+ concurrency_id="main",
74
  )
75
  return demo
76
 
app_ip2p.py CHANGED
@@ -17,8 +17,7 @@ def create_demo(process):
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
- prompt = gr.Textbox(label="Prompt")
21
- run_button = gr.Button("Run")
22
  with gr.Accordion("Advanced options", open=False):
23
  num_samples = gr.Slider(
24
  label="Number of images", minimum=1, maximum=MAX_NUM_IMAGES, value=DEFAULT_NUM_IMAGES, step=1
@@ -58,23 +57,12 @@ def create_demo(process):
58
  outputs=seed,
59
  queue=False,
60
  api_name=False,
61
- ).then(
62
- fn=process,
63
- inputs=inputs,
64
- outputs=result,
65
- api_name=False,
66
- )
67
- run_button.click(
68
- fn=randomize_seed_fn,
69
- inputs=[seed, randomize_seed],
70
- outputs=seed,
71
- queue=False,
72
- api_name=False,
73
  ).then(
74
  fn=process,
75
  inputs=inputs,
76
  outputs=result,
77
  api_name="ip2p",
 
78
  )
79
  return demo
80
 
 
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
+ prompt = gr.Textbox(label="Prompt", submit_btn=True)
 
21
  with gr.Accordion("Advanced options", open=False):
22
  num_samples = gr.Slider(
23
  label="Number of images", minimum=1, maximum=MAX_NUM_IMAGES, value=DEFAULT_NUM_IMAGES, step=1
 
57
  outputs=seed,
58
  queue=False,
59
  api_name=False,
 
 
 
 
 
 
 
 
 
 
 
 
60
  ).then(
61
  fn=process,
62
  inputs=inputs,
63
  outputs=result,
64
  api_name="ip2p",
65
+ concurrency_id="main",
66
  )
67
  return demo
68
 
app_lineart.py CHANGED
@@ -17,8 +17,7 @@ def create_demo(process):
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
- prompt = gr.Textbox(label="Prompt")
21
- run_button = gr.Button("Run")
22
  with gr.Accordion("Advanced options", open=False):
23
  preprocessor_name = gr.Radio(
24
  label="Preprocessor",
@@ -76,23 +75,12 @@ def create_demo(process):
76
  outputs=seed,
77
  queue=False,
78
  api_name=False,
79
- ).then(
80
- fn=process,
81
- inputs=inputs,
82
- outputs=result,
83
- api_name=False,
84
- )
85
- run_button.click(
86
- fn=randomize_seed_fn,
87
- inputs=[seed, randomize_seed],
88
- outputs=seed,
89
- queue=False,
90
- api_name=False,
91
  ).then(
92
  fn=process,
93
  inputs=inputs,
94
  outputs=result,
95
  api_name="lineart",
 
96
  )
97
  return demo
98
 
 
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
+ prompt = gr.Textbox(label="Prompt", submit_btn=True)
 
21
  with gr.Accordion("Advanced options", open=False):
22
  preprocessor_name = gr.Radio(
23
  label="Preprocessor",
 
75
  outputs=seed,
76
  queue=False,
77
  api_name=False,
 
 
 
 
 
 
 
 
 
 
 
 
78
  ).then(
79
  fn=process,
80
  inputs=inputs,
81
  outputs=result,
82
  api_name="lineart",
83
+ concurrency_id="main",
84
  )
85
  return demo
86
 
app_mlsd.py CHANGED
@@ -17,8 +17,7 @@ def create_demo(process):
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
- prompt = gr.Textbox(label="Prompt")
21
- run_button = gr.Button("Run")
22
  with gr.Accordion("Advanced options", open=False):
23
  num_samples = gr.Slider(
24
  label="Number of images", minimum=1, maximum=MAX_NUM_IMAGES, value=DEFAULT_NUM_IMAGES, step=1
@@ -70,23 +69,12 @@ def create_demo(process):
70
  outputs=seed,
71
  queue=False,
72
  api_name=False,
73
- ).then(
74
- fn=process,
75
- inputs=inputs,
76
- outputs=result,
77
- api_name=False,
78
- )
79
- run_button.click(
80
- fn=randomize_seed_fn,
81
- inputs=[seed, randomize_seed],
82
- outputs=seed,
83
- queue=False,
84
- api_name=False,
85
  ).then(
86
  fn=process,
87
  inputs=inputs,
88
  outputs=result,
89
  api_name="mlsd",
 
90
  )
91
  return demo
92
 
 
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
+ prompt = gr.Textbox(label="Prompt", submit_btn=True)
 
21
  with gr.Accordion("Advanced options", open=False):
22
  num_samples = gr.Slider(
23
  label="Number of images", minimum=1, maximum=MAX_NUM_IMAGES, value=DEFAULT_NUM_IMAGES, step=1
 
69
  outputs=seed,
70
  queue=False,
71
  api_name=False,
 
 
 
 
 
 
 
 
 
 
 
 
72
  ).then(
73
  fn=process,
74
  inputs=inputs,
75
  outputs=result,
76
  api_name="mlsd",
77
+ concurrency_id="main",
78
  )
79
  return demo
80
 
app_normal.py CHANGED
@@ -17,8 +17,7 @@ def create_demo(process):
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
- prompt = gr.Textbox(label="Prompt")
21
- run_button = gr.Button("Run")
22
  with gr.Accordion("Advanced options", open=False):
23
  preprocessor_name = gr.Radio(
24
  label="Preprocessor", choices=["NormalBae", "None"], type="value", value="NormalBae"
@@ -66,23 +65,12 @@ def create_demo(process):
66
  outputs=seed,
67
  queue=False,
68
  api_name=False,
69
- ).then(
70
- fn=process,
71
- inputs=inputs,
72
- outputs=result,
73
- api_name=False,
74
- )
75
- run_button.click(
76
- fn=randomize_seed_fn,
77
- inputs=[seed, randomize_seed],
78
- outputs=seed,
79
- queue=False,
80
- api_name=False,
81
  ).then(
82
  fn=process,
83
  inputs=inputs,
84
  outputs=result,
85
  api_name="normal",
 
86
  )
87
  return demo
88
 
 
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
+ prompt = gr.Textbox(label="Prompt", submit_btn=True)
 
21
  with gr.Accordion("Advanced options", open=False):
22
  preprocessor_name = gr.Radio(
23
  label="Preprocessor", choices=["NormalBae", "None"], type="value", value="NormalBae"
 
65
  outputs=seed,
66
  queue=False,
67
  api_name=False,
 
 
 
 
 
 
 
 
 
 
 
 
68
  ).then(
69
  fn=process,
70
  inputs=inputs,
71
  outputs=result,
72
  api_name="normal",
73
+ concurrency_id="main",
74
  )
75
  return demo
76
 
app_openpose.py CHANGED
@@ -17,8 +17,7 @@ def create_demo(process):
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
- prompt = gr.Textbox(label="Prompt")
21
- run_button = gr.Button(label="Run")
22
  with gr.Accordion("Advanced options", open=False):
23
  preprocessor_name = gr.Radio(
24
  label="Preprocessor", choices=["Openpose", "None"], type="value", value="Openpose"
@@ -66,23 +65,12 @@ def create_demo(process):
66
  outputs=seed,
67
  queue=False,
68
  api_name=False,
69
- ).then(
70
- fn=process,
71
- inputs=inputs,
72
- outputs=result,
73
- api_name=False,
74
- )
75
- run_button.click(
76
- fn=randomize_seed_fn,
77
- inputs=[seed, randomize_seed],
78
- outputs=seed,
79
- queue=False,
80
- api_name=False,
81
  ).then(
82
  fn=process,
83
  inputs=inputs,
84
  outputs=result,
85
  api_name="openpose",
 
86
  )
87
  return demo
88
 
 
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
+ prompt = gr.Textbox(label="Prompt", submit_btn=True)
 
21
  with gr.Accordion("Advanced options", open=False):
22
  preprocessor_name = gr.Radio(
23
  label="Preprocessor", choices=["Openpose", "None"], type="value", value="Openpose"
 
65
  outputs=seed,
66
  queue=False,
67
  api_name=False,
 
 
 
 
 
 
 
 
 
 
 
 
68
  ).then(
69
  fn=process,
70
  inputs=inputs,
71
  outputs=result,
72
  api_name="openpose",
73
+ concurrency_id="main",
74
  )
75
  return demo
76
 
app_scribble.py CHANGED
@@ -17,8 +17,7 @@ def create_demo(process):
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
- prompt = gr.Textbox(label="Prompt")
21
- run_button = gr.Button("Run")
22
  with gr.Accordion("Advanced options", open=False):
23
  preprocessor_name = gr.Radio(
24
  label="Preprocessor", choices=["HED", "PidiNet", "None"], type="value", value="HED"
@@ -66,23 +65,12 @@ def create_demo(process):
66
  outputs=seed,
67
  queue=False,
68
  api_name=False,
69
- ).then(
70
- fn=process,
71
- inputs=inputs,
72
- outputs=result,
73
- api_name=False,
74
- )
75
- run_button.click(
76
- fn=randomize_seed_fn,
77
- inputs=[seed, randomize_seed],
78
- outputs=seed,
79
- queue=False,
80
- api_name=False,
81
  ).then(
82
  fn=process,
83
  inputs=inputs,
84
  outputs=result,
85
  api_name="scribble",
 
86
  )
87
  return demo
88
 
 
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
+ prompt = gr.Textbox(label="Prompt", submit_btn=True)
 
21
  with gr.Accordion("Advanced options", open=False):
22
  preprocessor_name = gr.Radio(
23
  label="Preprocessor", choices=["HED", "PidiNet", "None"], type="value", value="HED"
 
65
  outputs=seed,
66
  queue=False,
67
  api_name=False,
 
 
 
 
 
 
 
 
 
 
 
 
68
  ).then(
69
  fn=process,
70
  inputs=inputs,
71
  outputs=result,
72
  api_name="scribble",
73
+ concurrency_id="main",
74
  )
75
  return demo
76
 
app_scribble_interactive.py CHANGED
@@ -13,8 +13,12 @@ from settings import (
13
  from utils import randomize_seed_fn
14
 
15
 
16
- def create_canvas(w, h):
17
- return np.zeros(shape=(h, w, 3), dtype=np.uint8) + 255
 
 
 
 
18
 
19
 
20
  def create_demo(process):
@@ -36,9 +40,17 @@ def create_demo(process):
36
  step=1,
37
  )
38
  create_button = gr.Button("Open drawing canvas!")
39
- image = gr.Image(tool="sketch", brush_radius=10)
40
- prompt = gr.Textbox(label="Prompt")
41
- run_button = gr.Button("Run")
 
 
 
 
 
 
 
 
42
  with gr.Accordion("Advanced options", open=False):
43
  num_samples = gr.Slider(
44
  label="Number of images", minimum=1, maximum=MAX_NUM_IMAGES, value=DEFAULT_NUM_IMAGES, step=1
@@ -92,17 +104,7 @@ def create_demo(process):
92
  inputs=inputs,
93
  outputs=result,
94
  api_name=False,
95
- )
96
- run_button.click(
97
- fn=randomize_seed_fn,
98
- inputs=[seed, randomize_seed],
99
- outputs=seed,
100
- queue=False,
101
- api_name=False,
102
- ).then(
103
- fn=process,
104
- inputs=inputs,
105
- outputs=result,
106
  )
107
  return demo
108
 
 
13
  from utils import randomize_seed_fn
14
 
15
 
16
+ def create_canvas(w: int, h: int) -> dict[str, np.ndarray | list[np.ndarray]]:
17
+ return {
18
+ "background": np.full((h, w), 255, dtype=np.uint8),
19
+ "composite": np.full((h, w), 255, dtype=np.uint8),
20
+ "layers": [np.full((h, w), 255, dtype=np.uint8)],
21
+ }
22
 
23
 
24
  def create_demo(process):
 
40
  step=1,
41
  )
42
  create_button = gr.Button("Open drawing canvas!")
43
+ image = gr.ImageEditor(
44
+ value=create_canvas(DEFAULT_IMAGE_RESOLUTION, DEFAULT_IMAGE_RESOLUTION),
45
+ image_mode="L",
46
+ width=MAX_IMAGE_RESOLUTION + 50,
47
+ height=MAX_IMAGE_RESOLUTION + 50,
48
+ sources=None,
49
+ transforms=(),
50
+ layers=False,
51
+ brush=gr.Brush(default_size=2, default_color="black", color_mode="fixed"),
52
+ )
53
+ prompt = gr.Textbox(label="Prompt", submit_btn=True)
54
  with gr.Accordion("Advanced options", open=False):
55
  num_samples = gr.Slider(
56
  label="Number of images", minimum=1, maximum=MAX_NUM_IMAGES, value=DEFAULT_NUM_IMAGES, step=1
 
104
  inputs=inputs,
105
  outputs=result,
106
  api_name=False,
107
+ concurrency_id="main",
 
 
 
 
 
 
 
 
 
 
108
  )
109
  return demo
110
 
app_segmentation.py CHANGED
@@ -17,8 +17,7 @@ def create_demo(process):
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
- prompt = gr.Textbox(label="Prompt")
21
- run_button = gr.Button("Run")
22
  with gr.Accordion("Advanced options", open=False):
23
  preprocessor_name = gr.Radio(
24
  label="Preprocessor", choices=["UPerNet", "None"], type="value", value="UPerNet"
@@ -66,23 +65,12 @@ def create_demo(process):
66
  outputs=seed,
67
  queue=False,
68
  api_name=False,
69
- ).then(
70
- fn=process,
71
- inputs=inputs,
72
- outputs=result,
73
- api_name=False,
74
- )
75
- run_button.click(
76
- fn=randomize_seed_fn,
77
- inputs=[seed, randomize_seed],
78
- outputs=seed,
79
- queue=False,
80
- api_name=False,
81
  ).then(
82
  fn=process,
83
  inputs=inputs,
84
  outputs=result,
85
  api_name="segmentation",
 
86
  )
87
  return demo
88
 
 
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
+ prompt = gr.Textbox(label="Prompt", submit_btn=True)
 
21
  with gr.Accordion("Advanced options", open=False):
22
  preprocessor_name = gr.Radio(
23
  label="Preprocessor", choices=["UPerNet", "None"], type="value", value="UPerNet"
 
65
  outputs=seed,
66
  queue=False,
67
  api_name=False,
 
 
 
 
 
 
 
 
 
 
 
 
68
  ).then(
69
  fn=process,
70
  inputs=inputs,
71
  outputs=result,
72
  api_name="segmentation",
73
+ concurrency_id="main",
74
  )
75
  return demo
76
 
app_shuffle.py CHANGED
@@ -17,8 +17,7 @@ def create_demo(process):
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
- prompt = gr.Textbox(label="Prompt")
21
- run_button = gr.Button("Run")
22
  with gr.Accordion("Advanced options", open=False):
23
  preprocessor_name = gr.Radio(
24
  label="Preprocessor", choices=["ContentShuffle", "None"], type="value", value="ContentShuffle"
@@ -62,23 +61,12 @@ def create_demo(process):
62
  outputs=seed,
63
  queue=False,
64
  api_name=False,
65
- ).then(
66
- fn=process,
67
- inputs=inputs,
68
- outputs=result,
69
- api_name=False,
70
- )
71
- run_button.click(
72
- fn=randomize_seed_fn,
73
- inputs=[seed, randomize_seed],
74
- outputs=seed,
75
- queue=False,
76
- api_name=False,
77
  ).then(
78
  fn=process,
79
  inputs=inputs,
80
  outputs=result,
81
  api_name="content-shuffle",
 
82
  )
83
  return demo
84
 
 
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
+ prompt = gr.Textbox(label="Prompt", submit_btn=True)
 
21
  with gr.Accordion("Advanced options", open=False):
22
  preprocessor_name = gr.Radio(
23
  label="Preprocessor", choices=["ContentShuffle", "None"], type="value", value="ContentShuffle"
 
61
  outputs=seed,
62
  queue=False,
63
  api_name=False,
 
 
 
 
 
 
 
 
 
 
 
 
64
  ).then(
65
  fn=process,
66
  inputs=inputs,
67
  outputs=result,
68
  api_name="content-shuffle",
69
+ concurrency_id="main",
70
  )
71
  return demo
72
 
app_softedge.py CHANGED
@@ -17,8 +17,7 @@ def create_demo(process):
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
- prompt = gr.Textbox(label="Prompt")
21
- run_button = gr.Button("Run")
22
  with gr.Accordion("Advanced options", open=False):
23
  preprocessor_name = gr.Radio(
24
  label="Preprocessor",
@@ -75,23 +74,12 @@ def create_demo(process):
75
  outputs=seed,
76
  queue=False,
77
  api_name=False,
78
- ).then(
79
- fn=process,
80
- inputs=inputs,
81
- outputs=result,
82
- api_name=False,
83
- )
84
- run_button.click(
85
- fn=randomize_seed_fn,
86
- inputs=[seed, randomize_seed],
87
- outputs=seed,
88
- queue=False,
89
- api_name=False,
90
  ).then(
91
  fn=process,
92
  inputs=inputs,
93
  outputs=result,
94
  api_name="softedge",
 
95
  )
96
  return demo
97
 
 
17
  with gr.Row():
18
  with gr.Column():
19
  image = gr.Image()
20
+ prompt = gr.Textbox(label="Prompt", submit_btn=True)
 
21
  with gr.Accordion("Advanced options", open=False):
22
  preprocessor_name = gr.Radio(
23
  label="Preprocessor",
 
74
  outputs=seed,
75
  queue=False,
76
  api_name=False,
 
 
 
 
 
 
 
 
 
 
 
 
77
  ).then(
78
  fn=process,
79
  inputs=inputs,
80
  outputs=result,
81
  api_name="softedge",
82
+ concurrency_id="main",
83
  )
84
  return demo
85
 
model.py CHANGED
@@ -40,7 +40,7 @@ def download_all_controlnet_weights() -> None:
40
 
41
 
42
  class Model:
43
- def __init__(self, base_model_id: str = "runwayml/stable-diffusion-v1-5", task_name: str = "Canny"):
44
  self.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
45
  self.base_model_id = ""
46
  self.task_name = ""
@@ -265,7 +265,7 @@ class Model:
265
  @torch.inference_mode()
266
  def process_scribble_interactive(
267
  self,
268
- image_and_mask: dict[str, np.ndarray],
269
  prompt: str,
270
  additional_prompt: str,
271
  negative_prompt: str,
@@ -282,7 +282,7 @@ class Model:
282
  if num_images > MAX_NUM_IMAGES:
283
  raise ValueError
284
 
285
- image = image_and_mask["mask"]
286
  image = HWC3(image)
287
  image = resize_image(image, resolution=image_resolution)
288
  control_image = PIL.Image.fromarray(image)
 
40
 
41
 
42
  class Model:
43
+ def __init__(self, base_model_id: str = "stable-diffusion-v1-5/stable-diffusion-v1-5", task_name: str = "Canny"):
44
  self.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
45
  self.base_model_id = ""
46
  self.task_name = ""
 
265
  @torch.inference_mode()
266
  def process_scribble_interactive(
267
  self,
268
+ image_and_mask: dict[str, np.ndarray | list[np.ndarray]] | None,
269
  prompt: str,
270
  additional_prompt: str,
271
  negative_prompt: str,
 
282
  if num_images > MAX_NUM_IMAGES:
283
  raise ValueError
284
 
285
+ image = 255 - image_and_mask["composite"] # type: ignore
286
  image = HWC3(image)
287
  image = resize_image(image, resolution=image_resolution)
288
  control_image = PIL.Image.fromarray(image)
pyproject.toml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "controlnet-v1-1"
3
+ version = "0.1.0"
4
+ description = ""
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "accelerate>=1.1.1",
9
+ "controlnet-aux>=0.0.9",
10
+ "diffusers>=0.31.0",
11
+ "einops>=0.8.0",
12
+ "gradio>=5.6.0",
13
+ "hf-transfer>=0.1.8",
14
+ "mediapipe>=0.10.18",
15
+ "opencv-python-headless>=4.10.0.84",
16
+ "safetensors>=0.4.5",
17
+ "spaces>=0.30.4",
18
+ "torch==2.4.0",
19
+ "torchvision>=0.19.0",
20
+ "transformers>=4.46.3",
21
+ "xformers>=0.0.27.post2",
22
+ ]
requirements.txt CHANGED
@@ -1,13 +1,370 @@
1
- accelerate==0.21.0
2
- controlnet_aux==0.0.6
3
- diffusers==0.18.2
4
- einops==0.6.1
5
- gradio==3.45.2
6
- huggingface-hub==0.16.4
7
- mediapipe==0.10.1
8
- opencv-python-headless==4.8.0.74
9
- safetensors==0.3.1
10
- torch==2.0.1
11
- torchvision==0.15.2
12
- transformers==4.30.2
13
- xformers==0.0.20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv pip compile pyproject.toml -o requirements.txt
3
+ absl-py==2.1.0
4
+ # via mediapipe
5
+ accelerate==1.1.1
6
+ # via controlnet-v1-1 (pyproject.toml)
7
+ aiofiles==23.2.1
8
+ # via gradio
9
+ annotated-types==0.7.0
10
+ # via pydantic
11
+ anyio==4.6.2.post1
12
+ # via
13
+ # gradio
14
+ # httpx
15
+ # starlette
16
+ attrs==24.2.0
17
+ # via mediapipe
18
+ certifi==2024.8.30
19
+ # via
20
+ # httpcore
21
+ # httpx
22
+ # requests
23
+ cffi==1.17.1
24
+ # via sounddevice
25
+ charset-normalizer==3.4.0
26
+ # via requests
27
+ click==8.1.7
28
+ # via
29
+ # typer
30
+ # uvicorn
31
+ contourpy==1.3.1
32
+ # via matplotlib
33
+ controlnet-aux==0.0.9
34
+ # via controlnet-v1-1 (pyproject.toml)
35
+ cycler==0.12.1
36
+ # via matplotlib
37
+ diffusers==0.31.0
38
+ # via controlnet-v1-1 (pyproject.toml)
39
+ einops==0.8.0
40
+ # via
41
+ # controlnet-v1-1 (pyproject.toml)
42
+ # controlnet-aux
43
+ exceptiongroup==1.2.2
44
+ # via anyio
45
+ fastapi==0.115.5
46
+ # via gradio
47
+ ffmpy==0.4.0
48
+ # via gradio
49
+ filelock==3.16.1
50
+ # via
51
+ # controlnet-aux
52
+ # diffusers
53
+ # huggingface-hub
54
+ # torch
55
+ # transformers
56
+ # triton
57
+ flatbuffers==24.3.25
58
+ # via mediapipe
59
+ fonttools==4.55.0
60
+ # via matplotlib
61
+ fsspec==2024.10.0
62
+ # via
63
+ # gradio-client
64
+ # huggingface-hub
65
+ # torch
66
+ gradio==5.6.0
67
+ # via
68
+ # controlnet-v1-1 (pyproject.toml)
69
+ # spaces
70
+ gradio-client==1.4.3
71
+ # via gradio
72
+ h11==0.14.0
73
+ # via
74
+ # httpcore
75
+ # uvicorn
76
+ hf-transfer==0.1.8
77
+ # via controlnet-v1-1 (pyproject.toml)
78
+ httpcore==1.0.7
79
+ # via httpx
80
+ httpx==0.27.2
81
+ # via
82
+ # gradio
83
+ # gradio-client
84
+ # safehttpx
85
+ # spaces
86
+ huggingface-hub==0.26.2
87
+ # via
88
+ # accelerate
89
+ # controlnet-aux
90
+ # diffusers
91
+ # gradio
92
+ # gradio-client
93
+ # tokenizers
94
+ # transformers
95
+ idna==3.10
96
+ # via
97
+ # anyio
98
+ # httpx
99
+ # requests
100
+ imageio==2.36.0
101
+ # via scikit-image
102
+ importlib-metadata==8.5.0
103
+ # via
104
+ # controlnet-aux
105
+ # diffusers
106
+ jax==0.4.35
107
+ # via mediapipe
108
+ jaxlib==0.4.35
109
+ # via
110
+ # jax
111
+ # mediapipe
112
+ jinja2==3.1.4
113
+ # via
114
+ # gradio
115
+ # torch
116
+ kiwisolver==1.4.7
117
+ # via matplotlib
118
+ lazy-loader==0.4
119
+ # via scikit-image
120
+ markdown-it-py==3.0.0
121
+ # via rich
122
+ markupsafe==2.1.5
123
+ # via
124
+ # gradio
125
+ # jinja2
126
+ matplotlib==3.9.2
127
+ # via mediapipe
128
+ mdurl==0.1.2
129
+ # via markdown-it-py
130
+ mediapipe==0.10.18
131
+ # via controlnet-v1-1 (pyproject.toml)
132
+ ml-dtypes==0.5.0
133
+ # via
134
+ # jax
135
+ # jaxlib
136
+ mpmath==1.3.0
137
+ # via sympy
138
+ networkx==3.4.2
139
+ # via
140
+ # scikit-image
141
+ # torch
142
+ numpy==1.26.4
143
+ # via
144
+ # accelerate
145
+ # contourpy
146
+ # controlnet-aux
147
+ # diffusers
148
+ # gradio
149
+ # imageio
150
+ # jax
151
+ # jaxlib
152
+ # matplotlib
153
+ # mediapipe
154
+ # ml-dtypes
155
+ # opencv-contrib-python
156
+ # opencv-python-headless
157
+ # pandas
158
+ # scikit-image
159
+ # scipy
160
+ # tifffile
161
+ # torchvision
162
+ # transformers
163
+ # xformers
164
+ nvidia-cublas-cu12==12.1.3.1
165
+ # via
166
+ # nvidia-cudnn-cu12
167
+ # nvidia-cusolver-cu12
168
+ # torch
169
+ nvidia-cuda-cupti-cu12==12.1.105
170
+ # via torch
171
+ nvidia-cuda-nvrtc-cu12==12.1.105
172
+ # via torch
173
+ nvidia-cuda-runtime-cu12==12.1.105
174
+ # via torch
175
+ nvidia-cudnn-cu12==9.1.0.70
176
+ # via torch
177
+ nvidia-cufft-cu12==11.0.2.54
178
+ # via torch
179
+ nvidia-curand-cu12==10.3.2.106
180
+ # via torch
181
+ nvidia-cusolver-cu12==11.4.5.107
182
+ # via torch
183
+ nvidia-cusparse-cu12==12.1.0.106
184
+ # via
185
+ # nvidia-cusolver-cu12
186
+ # torch
187
+ nvidia-nccl-cu12==2.20.5
188
+ # via torch
189
+ nvidia-nvjitlink-cu12==12.6.77
190
+ # via
191
+ # nvidia-cusolver-cu12
192
+ # nvidia-cusparse-cu12
193
+ nvidia-nvtx-cu12==12.1.105
194
+ # via torch
195
+ opencv-contrib-python==4.10.0.84
196
+ # via mediapipe
197
+ opencv-python-headless==4.10.0.84
198
+ # via
199
+ # controlnet-v1-1 (pyproject.toml)
200
+ # controlnet-aux
201
+ opt-einsum==3.4.0
202
+ # via jax
203
+ orjson==3.10.11
204
+ # via gradio
205
+ packaging==24.2
206
+ # via
207
+ # accelerate
208
+ # gradio
209
+ # gradio-client
210
+ # huggingface-hub
211
+ # lazy-loader
212
+ # matplotlib
213
+ # scikit-image
214
+ # spaces
215
+ # transformers
216
+ pandas==2.2.3
217
+ # via gradio
218
+ pillow==11.0.0
219
+ # via
220
+ # controlnet-aux
221
+ # diffusers
222
+ # gradio
223
+ # imageio
224
+ # matplotlib
225
+ # scikit-image
226
+ # torchvision
227
+ protobuf==4.25.5
228
+ # via mediapipe
229
+ psutil==5.9.8
230
+ # via
231
+ # accelerate
232
+ # spaces
233
+ pycparser==2.22
234
+ # via cffi
235
+ pydantic==2.9.2
236
+ # via
237
+ # fastapi
238
+ # gradio
239
+ # spaces
240
+ pydantic-core==2.23.4
241
+ # via pydantic
242
+ pydub==0.25.1
243
+ # via gradio
244
+ pygments==2.18.0
245
+ # via rich
246
+ pyparsing==3.2.0
247
+ # via matplotlib
248
+ python-dateutil==2.9.0.post0
249
+ # via
250
+ # matplotlib
251
+ # pandas
252
+ python-multipart==0.0.12
253
+ # via gradio
254
+ pytz==2024.2
255
+ # via pandas
256
+ pyyaml==6.0.2
257
+ # via
258
+ # accelerate
259
+ # gradio
260
+ # huggingface-hub
261
+ # transformers
262
+ regex==2024.11.6
263
+ # via
264
+ # diffusers
265
+ # transformers
266
+ requests==2.32.3
267
+ # via
268
+ # diffusers
269
+ # huggingface-hub
270
+ # spaces
271
+ # transformers
272
+ rich==13.9.4
273
+ # via typer
274
+ ruff==0.7.4
275
+ # via gradio
276
+ safehttpx==0.1.1
277
+ # via gradio
278
+ safetensors==0.4.5
279
+ # via
280
+ # controlnet-v1-1 (pyproject.toml)
281
+ # accelerate
282
+ # diffusers
283
+ # transformers
284
+ scikit-image==0.24.0
285
+ # via controlnet-aux
286
+ scipy==1.14.1
287
+ # via
288
+ # controlnet-aux
289
+ # jax
290
+ # jaxlib
291
+ # scikit-image
292
+ semantic-version==2.10.0
293
+ # via gradio
294
+ sentencepiece==0.2.0
295
+ # via mediapipe
296
+ shellingham==1.5.4
297
+ # via typer
298
+ six==1.16.0
299
+ # via python-dateutil
300
+ sniffio==1.3.1
301
+ # via
302
+ # anyio
303
+ # httpx
304
+ sounddevice==0.5.1
305
+ # via mediapipe
306
+ spaces==0.30.4
307
+ # via controlnet-v1-1 (pyproject.toml)
308
+ starlette==0.41.3
309
+ # via
310
+ # fastapi
311
+ # gradio
312
+ sympy==1.13.3
313
+ # via torch
314
+ tifffile==2024.9.20
315
+ # via scikit-image
316
+ timm==0.6.7
317
+ # via controlnet-aux
318
+ tokenizers==0.20.3
319
+ # via transformers
320
+ tomlkit==0.12.0
321
+ # via gradio
322
+ torch==2.4.0
323
+ # via
324
+ # controlnet-v1-1 (pyproject.toml)
325
+ # accelerate
326
+ # controlnet-aux
327
+ # timm
328
+ # torchvision
329
+ # xformers
330
+ torchvision==0.19.0
331
+ # via
332
+ # controlnet-v1-1 (pyproject.toml)
333
+ # controlnet-aux
334
+ # timm
335
+ tqdm==4.67.0
336
+ # via
337
+ # huggingface-hub
338
+ # transformers
339
+ transformers==4.46.3
340
+ # via controlnet-v1-1 (pyproject.toml)
341
+ triton==3.0.0
342
+ # via torch
343
+ typer==0.13.1
344
+ # via gradio
345
+ typing-extensions==4.12.2
346
+ # via
347
+ # anyio
348
+ # fastapi
349
+ # gradio
350
+ # gradio-client
351
+ # huggingface-hub
352
+ # pydantic
353
+ # pydantic-core
354
+ # rich
355
+ # spaces
356
+ # torch
357
+ # typer
358
+ # uvicorn
359
+ tzdata==2024.2
360
+ # via pandas
361
+ urllib3==2.2.3
362
+ # via requests
363
+ uvicorn==0.32.0
364
+ # via gradio
365
+ websockets==12.0
366
+ # via gradio-client
367
+ xformers==0.0.27.post2
368
+ # via controlnet-v1-1 (pyproject.toml)
369
+ zipp==3.21.0
370
+ # via importlib-metadata
settings.py CHANGED
@@ -2,7 +2,7 @@ import os
2
 
3
  import numpy as np
4
 
5
- DEFAULT_MODEL_ID = os.getenv("DEFAULT_MODEL_ID", "ashllay/stable-diffusion-v1-5-archive")
6
 
7
  MAX_NUM_IMAGES = int(os.getenv("MAX_NUM_IMAGES", "3"))
8
  DEFAULT_NUM_IMAGES = min(MAX_NUM_IMAGES, int(os.getenv("DEFAULT_NUM_IMAGES", "3")))
 
2
 
3
  import numpy as np
4
 
5
+ DEFAULT_MODEL_ID = os.getenv("DEFAULT_MODEL_ID", "stable-diffusion-v1-5/stable-diffusion-v1-5")
6
 
7
  MAX_NUM_IMAGES = int(os.getenv("MAX_NUM_IMAGES", "3"))
8
  DEFAULT_NUM_IMAGES = min(MAX_NUM_IMAGES, int(os.getenv("DEFAULT_NUM_IMAGES", "3")))
uv.lock ADDED
The diff for this file is too large to render. See raw diff