Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -69,11 +69,10 @@ COLORS = [
|
|
69 |
def process(query_img, state,
|
70 |
cfg_path='configs/demo_b.py'):
|
71 |
cfg = Config.fromfile(cfg_path)
|
|
|
72 |
kp_src_np = np.array(state['kp_src']).copy().astype(np.float32)
|
73 |
-
kp_src_np[:, 0] = kp_src_np[:,
|
74 |
-
|
75 |
-
kp_src_np[:, 1] = kp_src_np[:,
|
76 |
-
1] / 128. * cfg.model.encoder_config.img_size
|
77 |
kp_src_np = np.flip(kp_src_np, 1).copy()
|
78 |
kp_src_tensor = torch.tensor(kp_src_np).float()
|
79 |
preprocess = transforms.Compose([
|
@@ -83,7 +82,7 @@ def process(query_img, state,
|
|
83 |
cfg.model.encoder_config.img_size)])
|
84 |
|
85 |
if len(state['skeleton']) == 0:
|
86 |
-
skeleton = [(0, 0)]
|
87 |
|
88 |
support_img = preprocess(state['original_support_image']).flip(0)[None]
|
89 |
np_query = np.array(query_img)[:, :, ::-1].copy()
|
@@ -296,7 +295,8 @@ with gr.Blocks() as demo:
|
|
296 |
state['skeleton'].clear()
|
297 |
state['kp_src'].clear()
|
298 |
state['original_support_image'] = np.array(support_img)[:, :, ::-1].copy()
|
299 |
-
|
|
|
300 |
return support_img, support_img, state
|
301 |
|
302 |
|
|
|
69 |
def process(query_img, state,
|
70 |
cfg_path='configs/demo_b.py'):
|
71 |
cfg = Config.fromfile(cfg_path)
|
72 |
+
width, height, _ = state['original_support_image'].shape
|
73 |
kp_src_np = np.array(state['kp_src']).copy().astype(np.float32)
|
74 |
+
kp_src_np[:, 0] = kp_src_np[:,0] / (width // 2) * cfg.model.encoder_config.img_size
|
75 |
+
kp_src_np[:, 1] = kp_src_np[:,1] / (height // 2) * cfg.model.encoder_config.img_size
|
|
|
|
|
76 |
kp_src_np = np.flip(kp_src_np, 1).copy()
|
77 |
kp_src_tensor = torch.tensor(kp_src_np).float()
|
78 |
preprocess = transforms.Compose([
|
|
|
82 |
cfg.model.encoder_config.img_size)])
|
83 |
|
84 |
if len(state['skeleton']) == 0:
|
85 |
+
state['skeleton'] = [(0, 0)]
|
86 |
|
87 |
support_img = preprocess(state['original_support_image']).flip(0)[None]
|
88 |
np_query = np.array(query_img)[:, :, ::-1].copy()
|
|
|
295 |
state['skeleton'].clear()
|
296 |
state['kp_src'].clear()
|
297 |
state['original_support_image'] = np.array(support_img)[:, :, ::-1].copy()
|
298 |
+
width, height = support_img.size
|
299 |
+
support_img = support_img.resize((width // 2, width // 2), Image.Resampling.LANCZOS)
|
300 |
return support_img, support_img, state
|
301 |
|
302 |
|