Delete app_o.py
Browse files
app_o.py
DELETED
|
@@ -1,88 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python
|
| 2 |
-
|
| 3 |
-
from __future__ import annotations
|
| 4 |
-
|
| 5 |
-
import os
|
| 6 |
-
import pathlib
|
| 7 |
-
import shlex
|
| 8 |
-
import subprocess
|
| 9 |
-
|
| 10 |
-
import gradio as gr
|
| 11 |
-
|
| 12 |
-
if os.getenv('SYSTEM') == 'spaces':
|
| 13 |
-
with open('patch') as f:
|
| 14 |
-
subprocess.run(shlex.split('patch -p1'), stdin=f, cwd='ControlNet')
|
| 15 |
-
|
| 16 |
-
base_url = 'https://huggingface.co/lllyasviel/ControlNet/resolve/main/annotator/ckpts/'
|
| 17 |
-
names = [
|
| 18 |
-
'body_pose_model.pth',
|
| 19 |
-
'dpt_hybrid-midas-501f0c75.pt',
|
| 20 |
-
'hand_pose_model.pth',
|
| 21 |
-
'mlsd_large_512_fp32.pth',
|
| 22 |
-
'mlsd_tiny_512_fp32.pth',
|
| 23 |
-
'network-bsds500.pth',
|
| 24 |
-
'upernet_global_small.pth',
|
| 25 |
-
]
|
| 26 |
-
for name in names:
|
| 27 |
-
command = f'wget https://huggingface.co/lllyasviel/ControlNet/resolve/main/annotator/ckpts/{name} -O {name}'
|
| 28 |
-
out_path = pathlib.Path(f'ControlNet/annotator/ckpts/{name}')
|
| 29 |
-
if out_path.exists():
|
| 30 |
-
continue
|
| 31 |
-
subprocess.run(shlex.split(command), cwd='ControlNet/annotator/ckpts/')
|
| 32 |
-
|
| 33 |
-
from gradio_canny2image import create_demo as create_demo_canny
|
| 34 |
-
from gradio_depth2image import create_demo as create_demo_depth
|
| 35 |
-
from gradio_fake_scribble2image import create_demo as create_demo_fake_scribble
|
| 36 |
-
from gradio_hed2image import create_demo as create_demo_hed
|
| 37 |
-
from gradio_hough2image import create_demo as create_demo_hough
|
| 38 |
-
from gradio_normal2image import create_demo as create_demo_normal
|
| 39 |
-
from gradio_pose2image import create_demo as create_demo_pose
|
| 40 |
-
from gradio_scribble2image import create_demo as create_demo_scribble
|
| 41 |
-
from gradio_scribble2image_interactive import \
|
| 42 |
-
create_demo as create_demo_scribble_interactive
|
| 43 |
-
from gradio_seg2image import create_demo as create_demo_seg
|
| 44 |
-
from model import Model
|
| 45 |
-
|
| 46 |
-
MAX_IMAGES = 1
|
| 47 |
-
DESCRIPTION = '''# ControlNet
|
| 48 |
-
|
| 49 |
-
This is an unofficial demo for [https://github.com/lllyasviel/ControlNet](https://github.com/lllyasviel/ControlNet).
|
| 50 |
-
|
| 51 |
-
If you are interested in trying out other base models, check out [this Space](https://huggingface.co/spaces/hysts/ControlNet-with-other-models) as well.
|
| 52 |
-
'''
|
| 53 |
-
if (SPACE_ID := os.getenv('SPACE_ID')) is not None:
|
| 54 |
-
DESCRIPTION += f'''<p>For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings.<br/>
|
| 55 |
-
<a href="https://huggingface.co/spaces/{SPACE_ID}?duplicate=true">
|
| 56 |
-
<img style="margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
|
| 57 |
-
<p/>
|
| 58 |
-
'''
|
| 59 |
-
|
| 60 |
-
model = Model()
|
| 61 |
-
|
| 62 |
-
with gr.Blocks(css='style.css') as demo:
|
| 63 |
-
gr.Markdown(DESCRIPTION)
|
| 64 |
-
with gr.Tabs():
|
| 65 |
-
with gr.TabItem('Canny'):
|
| 66 |
-
create_demo_canny(model.process_canny, max_images=MAX_IMAGES)
|
| 67 |
-
with gr.TabItem('Hough'):
|
| 68 |
-
create_demo_hough(model.process_hough, max_images=MAX_IMAGES)
|
| 69 |
-
with gr.TabItem('HED'):
|
| 70 |
-
create_demo_hed(model.process_hed, max_images=MAX_IMAGES)
|
| 71 |
-
with gr.TabItem('Scribble'):
|
| 72 |
-
create_demo_scribble(model.process_scribble, max_images=MAX_IMAGES)
|
| 73 |
-
with gr.TabItem('Scribble Interactive'):
|
| 74 |
-
create_demo_scribble_interactive(
|
| 75 |
-
model.process_scribble_interactive, max_images=MAX_IMAGES)
|
| 76 |
-
with gr.TabItem('Fake Scribble'):
|
| 77 |
-
create_demo_fake_scribble(model.process_fake_scribble,
|
| 78 |
-
max_images=MAX_IMAGES)
|
| 79 |
-
with gr.TabItem('Pose'):
|
| 80 |
-
create_demo_pose(model.process_pose, max_images=MAX_IMAGES)
|
| 81 |
-
with gr.TabItem('Segmentation'):
|
| 82 |
-
create_demo_seg(model.process_seg, max_images=MAX_IMAGES)
|
| 83 |
-
with gr.TabItem('Depth'):
|
| 84 |
-
create_demo_depth(model.process_depth, max_images=MAX_IMAGES)
|
| 85 |
-
with gr.TabItem('Normal map'):
|
| 86 |
-
create_demo_normal(model.process_normal, max_images=MAX_IMAGES)
|
| 87 |
-
|
| 88 |
-
demo.queue(api_open=False).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|