Spaces:
Runtime error
Runtime error
jiayueru
commited on
Commit
β’
cd0ef8f
1
Parent(s):
3cf5640
test
Browse files- app.py +12 -45
- app_old.py +59 -0
app.py
CHANGED
@@ -4,56 +4,23 @@ import shlex
|
|
4 |
from src.demo.model import DesignEdit
|
5 |
import spaces
|
6 |
|
7 |
-
os.makedirs('models', exist_ok=True)
|
8 |
-
subprocess.run(shlex.split('wget https://huggingface.co/Adapter/DragonDiffusion/resolve/main/model/efficient_sam_vits.pt -O models/efficient_sam_vits.pt'))
|
9 |
-
|
10 |
from src.demo.demo import *
|
11 |
import shlex
|
12 |
|
13 |
import cv2
|
14 |
import gradio as gr
|
15 |
-
pretrained_model_path = "stabilityai/stable-diffusion-xl-base-1.0"
|
16 |
-
model = DesignEdit(pretrained_model_path=pretrained_model_path)
|
17 |
-
DESCRIPTION_1 = """<div style="text-align: center; font-size: 80px;">
|
18 |
-
<strong class="title is-1">
|
19 |
-
<span style="color: green;">πΏD</span>
|
20 |
-
<span style="color: orange;">e</span>
|
21 |
-
<span style="color: rgb(63, 185, 63);">s</span>
|
22 |
-
<span style="color: green;">i</span>
|
23 |
-
<span style="color: rgb(200, 85, 23);">g</span>
|
24 |
-
<span style="color: green;">n</span>
|
25 |
-
<span style="color: orange;">E</span>
|
26 |
-
<span style="color: crimson;">d</span>
|
27 |
-
<span style="color: darkorange;">i</span>
|
28 |
-
<span style="color: green;">tπΏ</span>
|
29 |
-
</strong>
|
30 |
-
</div>
|
31 |
-
"""
|
32 |
-
DESCRIPTION_2 = """ <div style="text-align: center;font-size: 24px;"> <h1> Multi-Layered Latent Decomposition and Fusion for Unified & Accurate Image Editing</h1></div>"""
|
33 |
-
DESCRIPTION_3 = """
|
34 |
-
<div style="text-align: center; font-size: 24px;">
|
35 |
-
<p> Gradio demo for <a href="https://design-edit.github.io/">DesignEdit</a></p>
|
36 |
-
</div>
|
37 |
-
"""
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
with gr.Tabs():
|
44 |
-
with gr.TabItem('1οΈβ£ Object Removal'):
|
45 |
-
create_demo_remove(model.run_remove)
|
46 |
-
with gr.TabItem('2οΈβ£ Zooming Out'):
|
47 |
-
create_demo_zooming(model.run_zooming)
|
48 |
-
with gr.TabItem('3οΈβ£ Camera Panning'):
|
49 |
-
create_demo_panning(model.run_panning)
|
50 |
-
with gr.TabItem('4οΈβ£ Object Moving, Resizing and Flipping'):
|
51 |
-
create_demo_moving(model.run_moving)
|
52 |
-
with gr.TabItem('5οΈβ£ π© Multi-Layered Editing π©'):
|
53 |
-
create_demo_layer(model.run_layer)
|
54 |
-
with gr.TabItem('π§ Mask Preparation: Draw or Sketch'):
|
55 |
-
create_demo_mask_box(model.run_mask)
|
56 |
|
57 |
-
|
58 |
-
|
|
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
4 |
from src.demo.model import DesignEdit
|
5 |
import spaces
|
6 |
|
|
|
|
|
|
|
7 |
from src.demo.demo import *
|
8 |
import shlex
|
9 |
|
10 |
import cv2
|
11 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
from diffusers import DiffusionPipeline
|
14 |
+
|
15 |
+
pipe = DiffusionPipeline.from_pretrained(...)
|
16 |
+
pipe.to('cuda')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
@spaces.GPU
|
19 |
+
def generate(prompt):
|
20 |
+
return pipe(prompt).images
|
21 |
|
22 |
+
gr.Interface(
|
23 |
+
fn=generate,
|
24 |
+
inputs=gr.Text(),
|
25 |
+
outputs=gr.Gallery(),
|
26 |
+
).launch()
|
app_old.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import subprocess
|
3 |
+
import shlex
|
4 |
+
from src.demo.model import DesignEdit
|
5 |
+
import spaces
|
6 |
+
|
7 |
+
os.makedirs('models', exist_ok=True)
|
8 |
+
subprocess.run(shlex.split('wget https://huggingface.co/Adapter/DragonDiffusion/resolve/main/model/efficient_sam_vits.pt -O models/efficient_sam_vits.pt'))
|
9 |
+
|
10 |
+
from src.demo.demo import *
|
11 |
+
import shlex
|
12 |
+
|
13 |
+
import cv2
|
14 |
+
import gradio as gr
|
15 |
+
pretrained_model_path = "stabilityai/stable-diffusion-xl-base-1.0"
|
16 |
+
model = DesignEdit(pretrained_model_path=pretrained_model_path)
|
17 |
+
DESCRIPTION_1 = """<div style="text-align: center; font-size: 80px;">
|
18 |
+
<strong class="title is-1">
|
19 |
+
<span style="color: green;">πΏD</span>
|
20 |
+
<span style="color: orange;">e</span>
|
21 |
+
<span style="color: rgb(63, 185, 63);">s</span>
|
22 |
+
<span style="color: green;">i</span>
|
23 |
+
<span style="color: rgb(200, 85, 23);">g</span>
|
24 |
+
<span style="color: green;">n</span>
|
25 |
+
<span style="color: orange;">E</span>
|
26 |
+
<span style="color: crimson;">d</span>
|
27 |
+
<span style="color: darkorange;">i</span>
|
28 |
+
<span style="color: green;">tπΏ</span>
|
29 |
+
</strong>
|
30 |
+
</div>
|
31 |
+
"""
|
32 |
+
DESCRIPTION_2 = """ <div style="text-align: center;font-size: 24px;"> <h1> Multi-Layered Latent Decomposition and Fusion for Unified & Accurate Image Editing</h1></div>"""
|
33 |
+
DESCRIPTION_3 = """
|
34 |
+
<div style="text-align: center; font-size: 24px;">
|
35 |
+
<p> Gradio demo for <a href="https://design-edit.github.io/">DesignEdit</a></p>
|
36 |
+
</div>
|
37 |
+
"""
|
38 |
+
|
39 |
+
with gr.Blocks(css='style.css') as demo:
|
40 |
+
gr.Markdown(DESCRIPTION_1)
|
41 |
+
gr.Markdown(DESCRIPTION_2)
|
42 |
+
gr.Markdown(DESCRIPTION_3)
|
43 |
+
with gr.Tabs():
|
44 |
+
with gr.TabItem('1οΈβ£ Object Removal'):
|
45 |
+
create_demo_remove(model.run_remove)
|
46 |
+
with gr.TabItem('2οΈβ£ Zooming Out'):
|
47 |
+
create_demo_zooming(model.run_zooming)
|
48 |
+
with gr.TabItem('3οΈβ£ Camera Panning'):
|
49 |
+
create_demo_panning(model.run_panning)
|
50 |
+
with gr.TabItem('4οΈβ£ Object Moving, Resizing and Flipping'):
|
51 |
+
create_demo_moving(model.run_moving)
|
52 |
+
with gr.TabItem('5οΈβ£ π© Multi-Layered Editing π©'):
|
53 |
+
create_demo_layer(model.run_layer)
|
54 |
+
with gr.TabItem('π§ Mask Preparation: Draw or Sketch'):
|
55 |
+
create_demo_mask_box(model.run_mask)
|
56 |
+
|
57 |
+
demo.queue(concurrency_count=3, max_size=20)
|
58 |
+
demo.launch(server_name="0.0.0.0")
|
59 |
+
|