terrapretapermaculture commited on
Commit
ed53313
1 Parent(s): 1ce8807

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -42
app.py CHANGED
@@ -5,18 +5,7 @@ from __future__ import annotations
5
  import gradio as gr
6
  import torch
7
 
8
- from app_canny import create_demo as create_demo_canny
9
  from app_depth import create_demo as create_demo_depth
10
- from app_ip2p import create_demo as create_demo_ip2p
11
- from app_lineart import create_demo as create_demo_lineart
12
- from app_mlsd import create_demo as create_demo_mlsd
13
- from app_normal import create_demo as create_demo_normal
14
- from app_openpose import create_demo as create_demo_openpose
15
- from app_scribble import create_demo as create_demo_scribble
16
- from app_scribble_interactive import create_demo as create_demo_scribble_interactive
17
- from app_segmentation import create_demo as create_demo_segmentation
18
- from app_shuffle import create_demo as create_demo_shuffle
19
- from app_softedge import create_demo as create_demo_softedge
20
  from model import Model
21
  from settings import ALLOW_CHANGING_BASE_MODEL, DEFAULT_MODEL_ID, SHOW_DUPLICATE_BUTTON
22
 
@@ -29,47 +18,46 @@ 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",
34
  elem_id="duplicate-button",
35
  visible=SHOW_DUPLICATE_BUTTON,
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):
65
  with gr.Row():
66
  with gr.Column(scale=5):
67
- current_base_model = gr.Text(label="Current base model")
68
  with gr.Column(scale=1):
69
  check_base_model_button = gr.Button("Check current base model")
70
  with gr.Row():
71
  with gr.Column(scale=5):
72
- new_base_model_id = gr.Text(
73
  label="New base model",
74
  max_lines=1,
75
  placeholder="runwayml/stable-diffusion-v1-5",
@@ -89,7 +77,7 @@ with gr.Blocks(css="style.css") as demo:
89
  queue=False,
90
  api_name="check_base_model",
91
  )
92
- gr.on(
93
  triggers=[new_base_model_id.submit, change_base_model_button.click],
94
  fn=model.set_base_model,
95
  inputs=new_base_model_id,
@@ -98,4 +86,4 @@ with gr.Blocks(css="style.css") as demo:
98
  )
99
 
100
  if __name__ == "__main__":
101
- demo.queue(max_size=20).launch()
 
5
  import gradio as gr
6
  import torch
7
 
 
8
  from app_depth import create_demo as create_demo_depth
 
 
 
 
 
 
 
 
 
 
9
  from model import Model
10
  from settings import ALLOW_CHANGING_BASE_MODEL, DEFAULT_MODEL_ID, SHOW_DUPLICATE_BUTTON
11
 
 
18
 
19
  with gr.Blocks(css="style.css") as demo:
20
  gr.Markdown(DESCRIPTION)
21
+ gr.Button(
22
+ "Duplicate Space for private use",
23
  elem_id="duplicate-button",
24
  visible=SHOW_DUPLICATE_BUTTON,
25
  )
26
 
27
+ # Define the inputs and outputs for the interface
28
+ depth_inputs = [
29
+ gr.Image(type="numpy", label="Input Image"),
30
+ gr.Textbox(label="Prompt"),
31
+ gr.Textbox(label="Additional Prompt"),
32
+ gr.Textbox(label="Negative Prompt"),
33
+ gr.Slider(label="Number of Images", minimum=1, maximum=10, step=1, value=1),
34
+ gr.Slider(label="Image Resolution", minimum=256, maximum=1024, step=256, value=512),
35
+ gr.Slider(label="Preprocess Resolution", minimum=128, maximum=512, step=1, value=384),
36
+ gr.Slider(label="Number of Steps", minimum=1, maximum=100, step=1, value=20),
37
+ gr.Slider(label="Guidance Scale", minimum=0.1, maximum=30.0, step=0.1, value=7.5),
38
+ gr.Slider(label="Seed", minimum=0, maximum=1000000, step=1, value=0),
39
+ gr.Radio(label="Preprocessor", choices=["Midas", "DPT", "None"], value="DPT"),
40
+ ]
41
+
42
+ depth_outputs = [
43
+ gr.Gallery(label="Output Images"),
44
+ ]
45
+
46
+ interfaces = [
47
+ gr.Interface(fn=model.process_depth, inputs=depth_inputs, outputs=depth_outputs, live=False),
48
+ ]
49
+
50
+ gr.TabbedInterface(interface_list=interfaces, tab_names=["Depth"])
 
51
 
52
  with gr.Accordion(label="Base model", open=False):
53
  with gr.Row():
54
  with gr.Column(scale=5):
55
+ current_base_model = gr.Textbox(label="Current base model")
56
  with gr.Column(scale=1):
57
  check_base_model_button = gr.Button("Check current base model")
58
  with gr.Row():
59
  with gr.Column(scale=5):
60
+ new_base_model_id = gr.Textbox(
61
  label="New base model",
62
  max_lines=1,
63
  placeholder="runwayml/stable-diffusion-v1-5",
 
77
  queue=False,
78
  api_name="check_base_model",
79
  )
80
+ gr.update(
81
  triggers=[new_base_model_id.submit, change_base_model_button.click],
82
  fn=model.set_base_model,
83
  inputs=new_base_model_id,
 
86
  )
87
 
88
  if __name__ == "__main__":
89
+ demo.queue(max_size=20).launch()