Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files- README.md +6 -6
- app.py +66 -0
- requirements.txt +6 -0
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: LEdits PP XL
|
3 |
+
emoji: 🦀
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: red
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.19.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers.utils import load_image
|
3 |
+
import spaces
|
4 |
+
from panna.pipeline import PipelineLEditsPP
|
5 |
+
|
6 |
+
model = PipelineLEditsPP(variant=None, torch_dtype=None)
|
7 |
+
title = ("# [LEdits ++](https://huggingface.co/spaces/editing-images/leditsplusplus) with [Stable Diffusion XL](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0)\n"
|
8 |
+
"The demo is part of [panna](https://github.com/abacws-abacus/panna) project.")
|
9 |
+
example_files = []
|
10 |
+
for n in range(1, 10):
|
11 |
+
load_image(f"https://huggingface.co/spaces/depth-anything/Depth-Anything-V2/resolve/main/assets/examples/demo{n:0>2}.jpg").save(f"demo{n:0>2}.jpg")
|
12 |
+
example_files.append(f"demo{n:0>2}.jpg")
|
13 |
+
|
14 |
+
|
15 |
+
@spaces.GPU
|
16 |
+
def infer(init_image, edit_prompt, reverse_editing_direction, edit_style):
|
17 |
+
reverse_editing_direction = [x for x, y in zip(reverse_editing_direction, edit_prompt) if y]
|
18 |
+
edit_style = [x for x, y in zip(edit_style, edit_prompt) if y]
|
19 |
+
edit_prompt = [x for x in edit_prompt if x]
|
20 |
+
return model(
|
21 |
+
init_image,
|
22 |
+
edit_prompt=edit_prompt,
|
23 |
+
reverse_editing_direction=reverse_editing_direction,
|
24 |
+
edit_style=edit_style,
|
25 |
+
seed=42
|
26 |
+
)
|
27 |
+
|
28 |
+
|
29 |
+
with gr.Blocks() as demo:
|
30 |
+
gr.Markdown(title)
|
31 |
+
with gr.Row():
|
32 |
+
gr.Markdown("<b>Add Concepts:</b>")
|
33 |
+
with gr.Column():
|
34 |
+
add_prompt_1 = gr.Text(label="Add concept")
|
35 |
+
add_style_1 = gr.Dropdown(["default", "face", "style", "object"], value="default", label="Concept Style"),
|
36 |
+
with gr.Column():
|
37 |
+
add_prompt_2 = gr.Text(label="Add concept")
|
38 |
+
add_style_2 = gr.Dropdown(["default", "face", "style", "object"], value="default", label="Concept Style"),
|
39 |
+
with gr.Column():
|
40 |
+
add_prompt_3 = gr.Text(label="Add concept")
|
41 |
+
add_style_3 = gr.Dropdown(["default", "face", "style", "object"], value="default", label="Concept Style"),
|
42 |
+
gr.Markdown("<b>Remove Concepts:</b>")
|
43 |
+
with gr.Column():
|
44 |
+
remove_prompt_1 = gr.Text(label="Remove concept")
|
45 |
+
remove_style_1 = gr.Dropdown(["default", "face", "style", "object"], value="default", label="Concept Style"),
|
46 |
+
with gr.Column():
|
47 |
+
remove_prompt_2 = gr.Text(label="Remove concept")
|
48 |
+
remove_style_2 = gr.Dropdown(["default", "face", "style", "object"], value="default", label="Concept Style"),
|
49 |
+
with gr.Column():
|
50 |
+
remove_prompt_3 = gr.Text(label="Remove concept")
|
51 |
+
remove_style_3 = gr.Dropdown(["default", "face", "style", "object"], value="default", label="Concept Style"),
|
52 |
+
edit_prompt = [add_prompt_1, add_prompt_2, add_prompt_3, remove_prompt_1, remove_prompt_2, remove_prompt_3]
|
53 |
+
edit_style = [add_style_1, add_style_2, add_style_3, remove_style_1, remove_style_2, remove_style_3]
|
54 |
+
reverse_editing_direction = [False, False, False, True, True, True]
|
55 |
+
run_button = gr.Button("Run")
|
56 |
+
with gr.Row():
|
57 |
+
init_image = gr.Image(label="Input Image", type='pil')
|
58 |
+
result = gr.Image(label="Result")
|
59 |
+
examples = gr.Examples(examples=example_files, inputs=[init_image])
|
60 |
+
gr.on(
|
61 |
+
triggers=[run_button.click],
|
62 |
+
fn=infer,
|
63 |
+
inputs=[init_image, edit_prompt, edit_style, reverse_editing_direction],
|
64 |
+
outputs=[result]
|
65 |
+
)
|
66 |
+
demo.launch(server_name="0.0.0.0")
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
diffusers==0.21.0
|
2 |
+
accelerate
|
3 |
+
transformers
|
4 |
+
torch
|
5 |
+
torchvision
|
6 |
+
panna
|