Upload app.py
Browse files
app.py
CHANGED
@@ -1,223 +1,362 @@
|
|
1 |
-
import numpy as np
|
2 |
-
from PIL import Image
|
3 |
-
from huggingface_hub import snapshot_download
|
4 |
-
from leffa.transform import LeffaTransform
|
5 |
-
from leffa.model import LeffaModel
|
6 |
-
from leffa.inference import LeffaInference
|
7 |
-
from leffa_utils.garment_agnostic_mask_predictor import AutoMasker
|
8 |
-
from leffa_utils.densepose_predictor import DensePosePredictor
|
9 |
-
from leffa_utils.utils import resize_and_center, list_dir, get_agnostic_mask_hd, get_agnostic_mask_dc
|
10 |
-
from preprocess.humanparsing.run_parsing import Parsing
|
11 |
-
from preprocess.openpose.run_openpose import OpenPose
|
12 |
-
|
13 |
-
import gradio as gr
|
14 |
-
|
15 |
-
# Download checkpoints
|
16 |
-
snapshot_download(repo_id="franciszzj/Leffa", local_dir="./ckpts")
|
17 |
-
|
18 |
-
|
19 |
-
class LeffaPredictor:
|
20 |
-
def __init__(self):
|
21 |
-
self.mask_predictor = AutoMasker(
|
22 |
-
densepose_path="./ckpts/densepose",
|
23 |
-
schp_path="./ckpts/schp",
|
24 |
-
)
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
pretrained_model_name_or_path="./ckpts/stable-diffusion-xl-1.0-inpainting-0.1",
|
56 |
-
pretrained_model="./ckpts/pose_transfer.pth",
|
57 |
-
dtype="float16",
|
58 |
-
)
|
59 |
-
self.
|
60 |
-
|
61 |
-
def
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
data = {
|
126 |
-
"src_image": [
|
127 |
-
"ref_image": [
|
128 |
-
"mask": [mask],
|
129 |
-
"densepose": [densepose],
|
130 |
-
}
|
131 |
-
data =
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
from PIL import Image
|
3 |
+
from huggingface_hub import snapshot_download
|
4 |
+
from leffa.transform import LeffaTransform
|
5 |
+
from leffa.model import LeffaModel
|
6 |
+
from leffa.inference import LeffaInference
|
7 |
+
from leffa_utils.garment_agnostic_mask_predictor import AutoMasker
|
8 |
+
from leffa_utils.densepose_predictor import DensePosePredictor
|
9 |
+
from leffa_utils.utils import resize_and_center, list_dir, get_agnostic_mask_hd, get_agnostic_mask_dc
|
10 |
+
from preprocess.humanparsing.run_parsing import Parsing
|
11 |
+
from preprocess.openpose.run_openpose import OpenPose
|
12 |
+
|
13 |
+
import gradio as gr
|
14 |
+
|
15 |
+
# Download checkpoints
|
16 |
+
snapshot_download(repo_id="franciszzj/Leffa", local_dir="./ckpts")
|
17 |
+
|
18 |
+
|
19 |
+
class LeffaPredictor(object):
|
20 |
+
def __init__(self):
|
21 |
+
self.mask_predictor = AutoMasker(
|
22 |
+
densepose_path="./ckpts/densepose",
|
23 |
+
schp_path="./ckpts/schp",
|
24 |
+
)
|
25 |
+
|
26 |
+
self.densepose_predictor = DensePosePredictor(
|
27 |
+
config_path="./ckpts/densepose/densepose_rcnn_R_50_FPN_s1x.yaml",
|
28 |
+
weights_path="./ckpts/densepose/model_final_162be9.pkl",
|
29 |
+
)
|
30 |
+
|
31 |
+
self.parsing = Parsing(
|
32 |
+
atr_path="./ckpts/humanparsing/parsing_atr.onnx",
|
33 |
+
lip_path="./ckpts/humanparsing/parsing_lip.onnx",
|
34 |
+
)
|
35 |
+
|
36 |
+
self.openpose = OpenPose(
|
37 |
+
body_model_path="./ckpts/openpose/body_pose_model.pth",
|
38 |
+
)
|
39 |
+
|
40 |
+
vt_model_hd = LeffaModel(
|
41 |
+
pretrained_model_name_or_path="./ckpts/stable-diffusion-inpainting",
|
42 |
+
pretrained_model="./ckpts/virtual_tryon.pth",
|
43 |
+
dtype="float16",
|
44 |
+
)
|
45 |
+
self.vt_inference_hd = LeffaInference(model=vt_model_hd)
|
46 |
+
|
47 |
+
vt_model_dc = LeffaModel(
|
48 |
+
pretrained_model_name_or_path="./ckpts/stable-diffusion-inpainting",
|
49 |
+
pretrained_model="./ckpts/virtual_tryon_dc.pth",
|
50 |
+
dtype="float16",
|
51 |
+
)
|
52 |
+
self.vt_inference_dc = LeffaInference(model=vt_model_dc)
|
53 |
+
|
54 |
+
pt_model = LeffaModel(
|
55 |
+
pretrained_model_name_or_path="./ckpts/stable-diffusion-xl-1.0-inpainting-0.1",
|
56 |
+
pretrained_model="./ckpts/pose_transfer.pth",
|
57 |
+
dtype="float16",
|
58 |
+
)
|
59 |
+
self.pt_inference = LeffaInference(model=pt_model)
|
60 |
+
|
61 |
+
def leffa_predict(
|
62 |
+
self,
|
63 |
+
src_image_path,
|
64 |
+
ref_image_path,
|
65 |
+
control_type,
|
66 |
+
ref_acceleration=False,
|
67 |
+
step=50,
|
68 |
+
scale=2.5,
|
69 |
+
seed=42,
|
70 |
+
vt_model_type="viton_hd",
|
71 |
+
vt_garment_type="upper_body",
|
72 |
+
vt_repaint=False
|
73 |
+
):
|
74 |
+
assert control_type in [
|
75 |
+
"virtual_tryon", "pose_transfer"], "Invalid control type: {}".format(control_type)
|
76 |
+
src_image = Image.open(src_image_path)
|
77 |
+
ref_image = Image.open(ref_image_path)
|
78 |
+
src_image = resize_and_center(src_image, 768, 1024)
|
79 |
+
ref_image = resize_and_center(ref_image, 768, 1024)
|
80 |
+
|
81 |
+
src_image_array = np.array(src_image)
|
82 |
+
|
83 |
+
# Mask
|
84 |
+
if control_type == "virtual_tryon":
|
85 |
+
src_image = src_image.convert("RGB")
|
86 |
+
model_parse, _ = self.parsing(src_image.resize((384, 512)))
|
87 |
+
keypoints = self.openpose(src_image.resize((384, 512)))
|
88 |
+
if vt_model_type == "viton_hd":
|
89 |
+
mask = get_agnostic_mask_hd(
|
90 |
+
model_parse, keypoints, vt_garment_type)
|
91 |
+
elif vt_model_type == "dress_code":
|
92 |
+
mask = get_agnostic_mask_dc(
|
93 |
+
model_parse, keypoints, vt_garment_type)
|
94 |
+
mask = mask.resize((768, 1024))
|
95 |
+
# garment_type_hd = "upper" if vt_garment_type in [
|
96 |
+
# "upper_body", "dresses"] else "lower"
|
97 |
+
# mask = self.mask_predictor(src_image, garment_type_hd)["mask"]
|
98 |
+
elif control_type == "pose_transfer":
|
99 |
+
mask = Image.fromarray(np.ones_like(src_image_array) * 255)
|
100 |
+
|
101 |
+
# DensePose
|
102 |
+
if control_type == "virtual_tryon":
|
103 |
+
if vt_model_type == "viton_hd":
|
104 |
+
src_image_seg_array = self.densepose_predictor.predict_seg(
|
105 |
+
src_image_array)[:, :, ::-1]
|
106 |
+
src_image_seg = Image.fromarray(src_image_seg_array)
|
107 |
+
densepose = src_image_seg
|
108 |
+
elif vt_model_type == "dress_code":
|
109 |
+
src_image_iuv_array = self.densepose_predictor.predict_iuv(
|
110 |
+
src_image_array)
|
111 |
+
src_image_seg_array = src_image_iuv_array[:, :, 0:1]
|
112 |
+
src_image_seg_array = np.concatenate(
|
113 |
+
[src_image_seg_array] * 3, axis=-1)
|
114 |
+
src_image_seg = Image.fromarray(src_image_seg_array)
|
115 |
+
densepose = src_image_seg
|
116 |
+
elif control_type == "pose_transfer":
|
117 |
+
src_image_iuv_array = self.densepose_predictor.predict_iuv(
|
118 |
+
src_image_array)[:, :, ::-1]
|
119 |
+
src_image_iuv = Image.fromarray(src_image_iuv_array)
|
120 |
+
densepose = src_image_iuv
|
121 |
+
|
122 |
+
# Leffa
|
123 |
+
transform = LeffaTransform()
|
124 |
+
|
125 |
+
data = {
|
126 |
+
"src_image": [src_image],
|
127 |
+
"ref_image": [ref_image],
|
128 |
+
"mask": [mask],
|
129 |
+
"densepose": [densepose],
|
130 |
+
}
|
131 |
+
data = transform(data)
|
132 |
+
if control_type == "virtual_tryon":
|
133 |
+
if vt_model_type == "viton_hd":
|
134 |
+
inference = self.vt_inference_hd
|
135 |
+
elif vt_model_type == "dress_code":
|
136 |
+
inference = self.vt_inference_dc
|
137 |
+
elif control_type == "pose_transfer":
|
138 |
+
inference = self.pt_inference
|
139 |
+
output = inference(
|
140 |
+
data,
|
141 |
+
ref_acceleration=ref_acceleration,
|
142 |
+
num_inference_steps=step,
|
143 |
+
guidance_scale=scale,
|
144 |
+
seed=seed,
|
145 |
+
repaint=vt_repaint,)
|
146 |
+
gen_image = output["generated_image"][0]
|
147 |
+
# gen_image.save("gen_image.png")
|
148 |
+
return np.array(gen_image), np.array(mask), np.array(densepose)
|
149 |
+
|
150 |
+
def leffa_predict_vt(self, src_image_path, ref_image_path, ref_acceleration, step, scale, seed, vt_model_type, vt_garment_type, vt_repaint):
|
151 |
+
return self.leffa_predict(src_image_path, ref_image_path, "virtual_tryon", ref_acceleration, step, scale, seed, vt_model_type, vt_garment_type, vt_repaint)
|
152 |
+
|
153 |
+
def leffa_predict_pt(self, src_image_path, ref_image_path, ref_acceleration, step, scale, seed):
|
154 |
+
return self.leffa_predict(src_image_path, ref_image_path, "pose_transfer", ref_acceleration, step, scale, seed)
|
155 |
+
|
156 |
+
|
157 |
+
if __name__ == "__main__":
|
158 |
+
|
159 |
+
leffa_predictor = LeffaPredictor()
|
160 |
+
example_dir = "./ckpts/examples"
|
161 |
+
person1_images = list_dir(f"{example_dir}/person1")
|
162 |
+
person2_images = list_dir(f"{example_dir}/person2")
|
163 |
+
garment_images = list_dir(f"{example_dir}/garment")
|
164 |
+
|
165 |
+
title = "## Leffa: Learning Flow Fields in Attention for Controllable Person Image Generation"
|
166 |
+
link = """[📚 Paper](https://arxiv.org/abs/2412.08486) - [🤖 Code](https://github.com/franciszzj/Leffa) - [🔥 Demo](https://huggingface.co/spaces/franciszzj/Leffa) - [🤗 Model](https://huggingface.co/franciszzj/Leffa)
|
167 |
+
|
168 |
+
Star ⭐ us if you like it!
|
169 |
+
"""
|
170 |
+
news = """## News
|
171 |
+
- 09/Jan/2025. Inference defaults to float16, generating an image in 6 seconds (on A100).
|
172 |
+
|
173 |
+
More news can be found in the [GitHub repository](https://github.com/franciszzj/Leffa).
|
174 |
+
"""
|
175 |
+
description = "Leffa is a unified framework for controllable person image generation that enables precise manipulation of both appearance (i.e., virtual try-on) and pose (i.e., pose transfer)."
|
176 |
+
note = "Note: The models used in the demo are trained solely on academic datasets. Virtual try-on uses VITON-HD/DressCode, and pose transfer uses DeepFashion."
|
177 |
+
|
178 |
+
with gr.Blocks(theme=gr.themes.Default(primary_hue=gr.themes.colors.pink, secondary_hue=gr.themes.colors.red)).queue() as demo:
|
179 |
+
gr.Markdown(title)
|
180 |
+
gr.Markdown(link)
|
181 |
+
gr.Markdown(news)
|
182 |
+
gr.Markdown(description)
|
183 |
+
|
184 |
+
with gr.Tab("Control Appearance (Virtual Try-on)"):
|
185 |
+
with gr.Row():
|
186 |
+
with gr.Column():
|
187 |
+
gr.Markdown("#### Person Image")
|
188 |
+
vt_src_image = gr.Image(
|
189 |
+
sources=["upload"],
|
190 |
+
type="filepath",
|
191 |
+
label="Person Image",
|
192 |
+
width=512,
|
193 |
+
height=512,
|
194 |
+
)
|
195 |
+
|
196 |
+
gr.Examples(
|
197 |
+
inputs=vt_src_image,
|
198 |
+
examples_per_page=10,
|
199 |
+
examples=person1_images,
|
200 |
+
)
|
201 |
+
|
202 |
+
with gr.Column():
|
203 |
+
gr.Markdown("#### Garment Image")
|
204 |
+
vt_ref_image = gr.Image(
|
205 |
+
sources=["upload"],
|
206 |
+
type="filepath",
|
207 |
+
label="Garment Image",
|
208 |
+
width=512,
|
209 |
+
height=512,
|
210 |
+
)
|
211 |
+
|
212 |
+
gr.Examples(
|
213 |
+
inputs=vt_ref_image,
|
214 |
+
examples_per_page=10,
|
215 |
+
examples=garment_images,
|
216 |
+
)
|
217 |
+
|
218 |
+
with gr.Column():
|
219 |
+
gr.Markdown("#### Generated Image")
|
220 |
+
vt_gen_image = gr.Image(
|
221 |
+
label="Generated Image",
|
222 |
+
width=512,
|
223 |
+
height=512,
|
224 |
+
)
|
225 |
+
|
226 |
+
with gr.Row():
|
227 |
+
vt_gen_button = gr.Button("Generate")
|
228 |
+
|
229 |
+
with gr.Accordion("Advanced Options", open=False):
|
230 |
+
vt_model_type = gr.Radio(
|
231 |
+
label="Model Type",
|
232 |
+
choices=[("VITON-HD (Recommended)", "viton_hd"),
|
233 |
+
("DressCode (Experimental)", "dress_code")],
|
234 |
+
value="viton_hd",
|
235 |
+
)
|
236 |
+
|
237 |
+
vt_garment_type = gr.Radio(
|
238 |
+
label="Garment Type",
|
239 |
+
choices=[("Upper", "upper_body"),
|
240 |
+
("Lower", "lower_body"),
|
241 |
+
("Dress", "dresses")],
|
242 |
+
value="upper_body",
|
243 |
+
)
|
244 |
+
|
245 |
+
vt_ref_acceleration = gr.Radio(
|
246 |
+
label="Accelerate Reference UNet (may slightly reduce performance)",
|
247 |
+
choices=[("True", True), ("False", False)],
|
248 |
+
value=False,
|
249 |
+
)
|
250 |
+
|
251 |
+
vt_repaint = gr.Radio(
|
252 |
+
label="Repaint Mode",
|
253 |
+
choices=[("True", True), ("False", False)],
|
254 |
+
value=False,
|
255 |
+
)
|
256 |
+
|
257 |
+
vt_step = gr.Number(
|
258 |
+
label="Inference Steps", minimum=30, maximum=100, step=1, value=30)
|
259 |
+
|
260 |
+
vt_scale = gr.Number(
|
261 |
+
label="Guidance Scale", minimum=0.1, maximum=5.0, step=0.1, value=2.5)
|
262 |
+
|
263 |
+
vt_seed = gr.Number(
|
264 |
+
label="Random Seed", minimum=-1, maximum=2147483647, step=1, value=42)
|
265 |
+
|
266 |
+
with gr.Accordion("Debug", open=False):
|
267 |
+
vt_mask = gr.Image(
|
268 |
+
label="Generated Mask",
|
269 |
+
width=256,
|
270 |
+
height=256,
|
271 |
+
)
|
272 |
+
|
273 |
+
vt_densepose = gr.Image(
|
274 |
+
label="Generated DensePose",
|
275 |
+
width=256,
|
276 |
+
height=256,
|
277 |
+
)
|
278 |
+
|
279 |
+
vt_gen_button.click(fn=leffa_predictor.leffa_predict_vt, inputs=[
|
280 |
+
vt_src_image, vt_ref_image, vt_ref_acceleration, vt_step, vt_scale, vt_seed, vt_model_type, vt_garment_type, vt_repaint], outputs=[vt_gen_image, vt_mask, vt_densepose])
|
281 |
+
|
282 |
+
with gr.Tab("Control Pose (Pose Transfer)"):
|
283 |
+
with gr.Row():
|
284 |
+
with gr.Column():
|
285 |
+
gr.Markdown("#### Person Image")
|
286 |
+
pt_ref_image = gr.Image(
|
287 |
+
sources=["upload"],
|
288 |
+
type="filepath",
|
289 |
+
label="Person Image",
|
290 |
+
width=512,
|
291 |
+
height=512,
|
292 |
+
)
|
293 |
+
|
294 |
+
gr.Examples(
|
295 |
+
inputs=pt_ref_image,
|
296 |
+
examples_per_page=10,
|
297 |
+
examples=person1_images,
|
298 |
+
)
|
299 |
+
|
300 |
+
with gr.Column():
|
301 |
+
gr.Markdown("#### Target Pose Person Image")
|
302 |
+
pt_src_image = gr.Image(
|
303 |
+
sources=["upload"],
|
304 |
+
type="filepath",
|
305 |
+
label="Target Pose Person Image",
|
306 |
+
width=512,
|
307 |
+
height=512,
|
308 |
+
)
|
309 |
+
|
310 |
+
gr.Examples(
|
311 |
+
inputs=pt_src_image,
|
312 |
+
examples_per_page=10,
|
313 |
+
examples=person2_images,
|
314 |
+
)
|
315 |
+
|
316 |
+
with gr.Column():
|
317 |
+
gr.Markdown("#### Generated Image")
|
318 |
+
pt_gen_image = gr.Image(
|
319 |
+
label="Generated Image",
|
320 |
+
width=512,
|
321 |
+
height=512,
|
322 |
+
)
|
323 |
+
|
324 |
+
with gr.Row():
|
325 |
+
pose_transfer_gen_button = gr.Button("Generate")
|
326 |
+
|
327 |
+
with gr.Accordion("Advanced Options", open=False):
|
328 |
+
pt_ref_acceleration = gr.Radio(
|
329 |
+
label="Accelerate Reference UNet",
|
330 |
+
choices=[("True", True), ("False", False)],
|
331 |
+
value=False,
|
332 |
+
)
|
333 |
+
|
334 |
+
pt_step = gr.Number(
|
335 |
+
label="Inference Steps", minimum=30, maximum=100, step=1, value=30)
|
336 |
+
|
337 |
+
pt_scale = gr.Number(
|
338 |
+
label="Guidance Scale", minimum=0.1, maximum=5.0, step=0.1, value=2.5)
|
339 |
+
|
340 |
+
pt_seed = gr.Number(
|
341 |
+
label="Random Seed", minimum=-1, maximum=2147483647, step=1, value=42)
|
342 |
+
|
343 |
+
with gr.Accordion("Debug", open=False):
|
344 |
+
pt_mask = gr.Image(
|
345 |
+
label="Generated Mask",
|
346 |
+
width=256,
|
347 |
+
height=256,
|
348 |
+
)
|
349 |
+
|
350 |
+
pt_densepose = gr.Image(
|
351 |
+
label="Generated DensePose",
|
352 |
+
width=256,
|
353 |
+
height=256,
|
354 |
+
)
|
355 |
+
|
356 |
+
pose_transfer_gen_button.click(fn=leffa_predictor.leffa_predict_pt, inputs=[
|
357 |
+
pt_src_image, pt_ref_image, pt_ref_acceleration, pt_step, pt_scale, pt_seed], outputs=[pt_gen_image, pt_mask, pt_densepose])
|
358 |
+
|
359 |
+
gr.Markdown(note)
|
360 |
+
|
361 |
+
demo.launch(share=True, server_port=7860,
|
362 |
+
allowed_paths=["./ckpts/examples"])
|