Upload folder using huggingface_hub
Browse files- README.md +7 -6
- app.py +50 -0
- requirements.txt +4 -0
README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
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: ControlNet SD3 (Pose)
|
3 |
+
emoji: 💥
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: blue
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.36.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
+
license: apache-2.0
|
11 |
---
|
12 |
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers.utils import load_image
|
3 |
+
import spaces
|
4 |
+
from panna import ControlNetSD3
|
5 |
+
|
6 |
+
model = ControlNetSD3(condition_type="pose")
|
7 |
+
title = ("# [ControlNet SD3](https://huggingface.co/docs/diffusers/en/api/pipelines/controlnet_sd3) (Pose Conditioning)\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, prompt, negative_prompt, seed, guidance_scale, controlnet_conditioning_scale, num_inference_steps):
|
17 |
+
return model.text2image(
|
18 |
+
image=[init_image],
|
19 |
+
prompt=[prompt],
|
20 |
+
negative_prompt=[negative_prompt],
|
21 |
+
guidance_scale=guidance_scale,
|
22 |
+
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
23 |
+
num_inference_steps=num_inference_steps,
|
24 |
+
seed=seed
|
25 |
+
)[0]
|
26 |
+
|
27 |
+
|
28 |
+
with gr.Blocks() as demo:
|
29 |
+
gr.Markdown(title)
|
30 |
+
with gr.Row():
|
31 |
+
prompt = gr.Text(label="Prompt", show_label=True, max_lines=1, placeholder="Enter your prompt", container=False)
|
32 |
+
run_button = gr.Button("Run", scale=0)
|
33 |
+
with gr.Row():
|
34 |
+
init_image = gr.Image(label="Input Image", type='pil')
|
35 |
+
result = gr.Image(label="Result")
|
36 |
+
with gr.Accordion("Advanced Settings", open=False):
|
37 |
+
negative_prompt = gr.Text(label="Negative Prompt", max_lines=1, placeholder="Enter a negative prompt")
|
38 |
+
seed = gr.Slider(label="Seed", minimum=0, maximum=1_000_000, step=1, value=0)
|
39 |
+
with gr.Row():
|
40 |
+
guidance_scale = gr.Slider(label="Guidance scale", minimum=0.0, maximum=10.0, step=0.1, value=7.5)
|
41 |
+
controlnet_conditioning_scale = gr.Slider(label="Controlnet conditioning scale", minimum=0.0, maximum=1.0, step=0.05, value=0.5)
|
42 |
+
num_inference_steps = gr.Slider(label="Inference steps", minimum=1, maximum=50, step=1, value=50)
|
43 |
+
examples = gr.Examples(examples=example_files, inputs=[init_image])
|
44 |
+
gr.on(
|
45 |
+
triggers=[run_button.click, prompt.submit, negative_prompt.submit],
|
46 |
+
fn=infer,
|
47 |
+
inputs=[init_image, prompt, negative_prompt, seed, guidance_scale, controlnet_conditioning_scale, num_inference_steps],
|
48 |
+
outputs=[result]
|
49 |
+
)
|
50 |
+
demo.launch(server_name="0.0.0.0")
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
git+https://github.com/huggingface/diffusers.git
|
2 |
+
accelerate
|
3 |
+
sentencepiece
|
4 |
+
panna>=0.0.9
|