Spaces:
Build error
Build error
Delete app.py
#41
by Calderd30 - opened
app.py
DELETED
|
@@ -1,100 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python
|
| 2 |
-
|
| 3 |
-
import gradio as gr
|
| 4 |
-
import torch
|
| 5 |
-
|
| 6 |
-
from app_canny import create_demo as create_demo_canny
|
| 7 |
-
from app_depth import create_demo as create_demo_depth
|
| 8 |
-
from app_ip2p import create_demo as create_demo_ip2p
|
| 9 |
-
from app_lineart import create_demo as create_demo_lineart
|
| 10 |
-
from app_mlsd import create_demo as create_demo_mlsd
|
| 11 |
-
from app_normal import create_demo as create_demo_normal
|
| 12 |
-
from app_openpose import create_demo as create_demo_openpose
|
| 13 |
-
from app_scribble import create_demo as create_demo_scribble
|
| 14 |
-
from app_scribble_interactive import create_demo as create_demo_scribble_interactive
|
| 15 |
-
from app_segmentation import create_demo as create_demo_segmentation
|
| 16 |
-
from app_shuffle import create_demo as create_demo_shuffle
|
| 17 |
-
from app_softedge import create_demo as create_demo_softedge
|
| 18 |
-
from model import Model
|
| 19 |
-
from settings import ALLOW_CHANGING_BASE_MODEL, DEFAULT_MODEL_ID, SHOW_DUPLICATE_BUTTON
|
| 20 |
-
|
| 21 |
-
DESCRIPTION = "# ControlNet v1.1"
|
| 22 |
-
|
| 23 |
-
if not torch.cuda.is_available():
|
| 24 |
-
DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
|
| 25 |
-
|
| 26 |
-
model = Model(base_model_id=DEFAULT_MODEL_ID, task_name="Canny")
|
| 27 |
-
|
| 28 |
-
with gr.Blocks(css_paths="style.css") as demo:
|
| 29 |
-
gr.Markdown(DESCRIPTION)
|
| 30 |
-
gr.DuplicateButton(
|
| 31 |
-
value="Duplicate Space for private use",
|
| 32 |
-
elem_id="duplicate-button",
|
| 33 |
-
visible=SHOW_DUPLICATE_BUTTON,
|
| 34 |
-
)
|
| 35 |
-
|
| 36 |
-
with gr.Tabs():
|
| 37 |
-
with gr.Tab("Canny"):
|
| 38 |
-
create_demo_canny(model.process_canny)
|
| 39 |
-
with gr.Tab("MLSD"):
|
| 40 |
-
create_demo_mlsd(model.process_mlsd)
|
| 41 |
-
with gr.Tab("Scribble"):
|
| 42 |
-
create_demo_scribble(model.process_scribble)
|
| 43 |
-
with gr.Tab("Scribble Interactive"):
|
| 44 |
-
create_demo_scribble_interactive(model.process_scribble_interactive)
|
| 45 |
-
with gr.Tab("SoftEdge"):
|
| 46 |
-
create_demo_softedge(model.process_softedge)
|
| 47 |
-
with gr.Tab("OpenPose"):
|
| 48 |
-
create_demo_openpose(model.process_openpose)
|
| 49 |
-
with gr.Tab("Segmentation"):
|
| 50 |
-
create_demo_segmentation(model.process_segmentation)
|
| 51 |
-
with gr.Tab("Depth"):
|
| 52 |
-
create_demo_depth(model.process_depth)
|
| 53 |
-
with gr.Tab("Normal map"):
|
| 54 |
-
create_demo_normal(model.process_normal)
|
| 55 |
-
with gr.Tab("Lineart"):
|
| 56 |
-
create_demo_lineart(model.process_lineart)
|
| 57 |
-
with gr.Tab("Content Shuffle"):
|
| 58 |
-
create_demo_shuffle(model.process_shuffle)
|
| 59 |
-
with gr.Tab("Instruct Pix2Pix"):
|
| 60 |
-
create_demo_ip2p(model.process_ip2p)
|
| 61 |
-
|
| 62 |
-
with gr.Accordion(label="Base model", open=False):
|
| 63 |
-
with gr.Row():
|
| 64 |
-
with gr.Column(scale=5):
|
| 65 |
-
current_base_model = gr.Text(label="Current base model")
|
| 66 |
-
with gr.Column(scale=1):
|
| 67 |
-
check_base_model_button = gr.Button("Check current base model")
|
| 68 |
-
with gr.Row():
|
| 69 |
-
with gr.Column(scale=5):
|
| 70 |
-
new_base_model_id = gr.Text(
|
| 71 |
-
label="New base model",
|
| 72 |
-
max_lines=1,
|
| 73 |
-
placeholder="stable-diffusion-v1-5/stable-diffusion-v1-5",
|
| 74 |
-
info="The base model must be compatible with Stable Diffusion v1.5.",
|
| 75 |
-
interactive=ALLOW_CHANGING_BASE_MODEL,
|
| 76 |
-
)
|
| 77 |
-
with gr.Column(scale=1):
|
| 78 |
-
change_base_model_button = gr.Button("Change base model", interactive=ALLOW_CHANGING_BASE_MODEL)
|
| 79 |
-
if not ALLOW_CHANGING_BASE_MODEL:
|
| 80 |
-
gr.Markdown(
|
| 81 |
-
"""The base model is not allowed to be changed in this Space so as not to slow down the demo, but it can be changed if you duplicate the Space."""
|
| 82 |
-
)
|
| 83 |
-
|
| 84 |
-
check_base_model_button.click(
|
| 85 |
-
fn=lambda: model.base_model_id,
|
| 86 |
-
outputs=current_base_model,
|
| 87 |
-
queue=False,
|
| 88 |
-
api_name="check_base_model",
|
| 89 |
-
)
|
| 90 |
-
gr.on(
|
| 91 |
-
triggers=[new_base_model_id.submit, change_base_model_button.click],
|
| 92 |
-
fn=model.set_base_model,
|
| 93 |
-
inputs=new_base_model_id,
|
| 94 |
-
outputs=current_base_model,
|
| 95 |
-
api_name=False,
|
| 96 |
-
concurrency_id="main",
|
| 97 |
-
)
|
| 98 |
-
|
| 99 |
-
if __name__ == "__main__":
|
| 100 |
-
demo.queue(max_size=20).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|