FangSen9000 commited on
Commit ·
2a1ef7e
1
Parent(s): fdc5154
Add a setting that enables hiding and showing the main line.
Browse files- ControlNeXt-SVD-v2/utils/__pycache__/pre_process_direct.cpython-310.pyc +0 -0
- README.md +4 -0
- easy_dwpose/draw/__pycache__/controlnext.cpython-310.pyc +0 -0
- easy_dwpose/draw/controlnext.py +17 -6
- generated_pose_video/NOT_FIND_YET_38868_21853_18535_20250804_164149.mp4 +0 -3
- generated_pose_video/{GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_160832.mp4 → WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315.mp4} +2 -2
- generated_pose_video/WHERE_IS_MY_CAT_63084_57261_37469_65313_20250804_164233.mp4 +0 -3
- generated_sign_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_160832.mp4 +0 -3
- generated_sign_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_160832_combined.mp4 +0 -3
- generated_sign_video/HELLO_WORLD_27184_63831_20250804_163910.mp4 +0 -3
- generated_sign_video/HELLO_WORLD_27184_63831_20250804_163910_combined.mp4 +0 -3
- generated_sign_video/I_WILL_ATTEND_THIS_DINNER_PARTY_28794_63364_04007_66628_16327_41325_20250804_164010.mp4 +0 -3
- generated_sign_video/I_WILL_ATTEND_THIS_DINNER_PARTY_28794_63364_04007_66628_16327_41325_20250804_164010_combined.mp4 +0 -3
- generated_sign_video/NOT_FIND_YET_38868_21853_18535_20250804_164149.mp4 +0 -3
- generated_sign_video/NOT_FIND_YET_38868_21853_18535_20250804_164149_combined.mp4 +0 -3
- generated_pose_video/HELLO_WORLD_27184_63831_20250804_163910.mp4 → generated_sign_video/WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315.mp4 +2 -2
- generated_pose_video/I_WILL_ATTEND_THIS_DINNER_PARTY_28794_63364_04007_66628_16327_41325_20250804_164010.mp4 → generated_sign_video/WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315_combined.mp4 +2 -2
- generated_sign_video/WHERE_IS_MY_CAT_63084_57261_37469_65313_20250804_164233.mp4 +0 -3
- generated_sign_video/WHERE_IS_MY_CAT_63084_57261_37469_65313_20250804_164233_combined.mp4 +0 -3
- text2pose.py +179 -9
- useless/abandon_cmd.md +1 -1
ControlNeXt-SVD-v2/utils/__pycache__/pre_process_direct.cpython-310.pyc
CHANGED
|
Binary files a/ControlNeXt-SVD-v2/utils/__pycache__/pre_process_direct.cpython-310.pyc and b/ControlNeXt-SVD-v2/utils/__pycache__/pre_process_direct.cpython-310.pyc differ
|
|
|
README.md
CHANGED
|
@@ -16,6 +16,10 @@ The entire project is divided into two parts: `text_or_gloss2pose` and `pose2vid
|
|
| 16 |
first, change `good morning afternoon`, and run:
|
| 17 |
|
| 18 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
python text2pose.py --gloss "good morning afternoon" --npz-interpolation 20 --width 512 --height 768 --fps 30
|
| 20 |
```
|
| 21 |
|
|
|
|
| 16 |
first, change `good morning afternoon`, and run:
|
| 17 |
|
| 18 |
```python
|
| 19 |
+
python text2pose.py --gloss "where is my cat" --scale-y 1.4 --scale-x 1.3 --npz-interpolation 20 --width 512 --height 768 --fps 30 --hide-torso-lines false
|
| 20 |
+
|
| 21 |
+
or
|
| 22 |
+
|
| 23 |
python text2pose.py --gloss "good morning afternoon" --npz-interpolation 20 --width 512 --height 768 --fps 30
|
| 24 |
```
|
| 25 |
|
easy_dwpose/draw/__pycache__/controlnext.cpython-310.pyc
CHANGED
|
Binary files a/easy_dwpose/draw/__pycache__/controlnext.cpython-310.pyc and b/easy_dwpose/draw/__pycache__/controlnext.cpython-310.pyc differ
|
|
|
easy_dwpose/draw/controlnext.py
CHANGED
|
@@ -19,7 +19,7 @@ def alpha_blend_color(color, alpha):
|
|
| 19 |
"""
|
| 20 |
return [int(c * alpha) for c in color]
|
| 21 |
|
| 22 |
-
def draw_bodypose(canvas, candidate, subset, score, transparent=False):
|
| 23 |
"""Draw body pose on canvas
|
| 24 |
Args:
|
| 25 |
canvas: numpy array canvas to draw on
|
|
@@ -27,6 +27,7 @@ def draw_bodypose(canvas, candidate, subset, score, transparent=False):
|
|
| 27 |
subset: pose subset
|
| 28 |
score: confidence scores
|
| 29 |
transparent: whether to use transparent background
|
|
|
|
| 30 |
Returns:
|
| 31 |
canvas: drawn canvas
|
| 32 |
"""
|
|
@@ -61,10 +62,19 @@ def draw_bodypose(canvas, candidate, subset, score, transparent=False):
|
|
| 61 |
length = ((X[0] - X[1]) ** 2 + (Y[0] - Y[1]) ** 2) ** 0.5
|
| 62 |
angle = math.degrees(math.atan2(X[0] - X[1], Y[0] - Y[1]))
|
| 63 |
polygon = cv2.ellipse2Poly((int(mY), int(mX)), (int(length / 2), stickwidth), int(angle), 0, 360, 1)
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
else:
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
| 68 |
cv2.fillConvexPoly(canvas, polygon, color)
|
| 69 |
|
| 70 |
canvas = (canvas * 0.6).astype(np.uint8)
|
|
@@ -139,7 +149,7 @@ def draw_facepose(canvas, all_lmks, all_scores, transparent=False):
|
|
| 139 |
cv2.circle(canvas, (x, y), 3, color, thickness=-1)
|
| 140 |
return canvas
|
| 141 |
|
| 142 |
-
def draw_pose(pose, H, W, include_body=True, include_hand=True, include_face=True, ref_w=2160, transparent=False):
|
| 143 |
"""vis dwpose outputs with optional transparent background
|
| 144 |
|
| 145 |
Args:
|
|
@@ -151,6 +161,7 @@ def draw_pose(pose, H, W, include_body=True, include_hand=True, include_face=Tru
|
|
| 151 |
include_face (bool): whether to draw face keypoints
|
| 152 |
ref_w (int, optional): reference width. Defaults to 2160.
|
| 153 |
transparent (bool, optional): whether to use transparent background. Defaults to False.
|
|
|
|
| 154 |
|
| 155 |
Returns:
|
| 156 |
np.ndarray: image pixel value in RGBA mode if transparent=True, otherwise RGB mode
|
|
@@ -171,7 +182,7 @@ def draw_pose(pose, H, W, include_body=True, include_hand=True, include_face=Tru
|
|
| 171 |
canvas = np.zeros(shape=(int(H*sr), int(W*sr), 3), dtype=np.uint8)
|
| 172 |
|
| 173 |
if include_body:
|
| 174 |
-
canvas = draw_bodypose(canvas, candidate, subset, score=bodies['score'], transparent=transparent)
|
| 175 |
|
| 176 |
if include_hand:
|
| 177 |
canvas = draw_handpose(canvas, hands, pose['hands_score'], transparent=transparent)
|
|
|
|
| 19 |
"""
|
| 20 |
return [int(c * alpha) for c in color]
|
| 21 |
|
| 22 |
+
def draw_bodypose(canvas, candidate, subset, score, transparent=False, hide_torso_lines=False):
|
| 23 |
"""Draw body pose on canvas
|
| 24 |
Args:
|
| 25 |
canvas: numpy array canvas to draw on
|
|
|
|
| 27 |
subset: pose subset
|
| 28 |
score: confidence scores
|
| 29 |
transparent: whether to use transparent background
|
| 30 |
+
hide_torso_lines: whether to hide torso lines (neck to hips)
|
| 31 |
Returns:
|
| 32 |
canvas: drawn canvas
|
| 33 |
"""
|
|
|
|
| 62 |
length = ((X[0] - X[1]) ** 2 + (Y[0] - Y[1]) ** 2) ** 0.5
|
| 63 |
angle = math.degrees(math.atan2(X[0] - X[1], Y[0] - Y[1]))
|
| 64 |
polygon = cv2.ellipse2Poly((int(mY), int(mX)), (int(length / 2), stickwidth), int(angle), 0, 360, 1)
|
| 65 |
+
|
| 66 |
+
# Check if this is a torso line (neck to hips)
|
| 67 |
+
# limbSeq[6] = [2, 9] (neck to right hip), limbSeq[9] = [2, 12] (neck to left hip)
|
| 68 |
+
if hide_torso_lines and (i == 6 or i == 9):
|
| 69 |
+
if transparent:
|
| 70 |
+
color = [0, 0, 0, int(255 * conf[0] * conf[1])] # Black with alpha
|
| 71 |
+
else:
|
| 72 |
+
color = [0, 0, 0] # Black
|
| 73 |
else:
|
| 74 |
+
if transparent:
|
| 75 |
+
color = colors[i][:-1] + [int(255 * conf[0] * conf[1])] # Adjust alpha based on confidence
|
| 76 |
+
else:
|
| 77 |
+
color = colors[i]
|
| 78 |
cv2.fillConvexPoly(canvas, polygon, color)
|
| 79 |
|
| 80 |
canvas = (canvas * 0.6).astype(np.uint8)
|
|
|
|
| 149 |
cv2.circle(canvas, (x, y), 3, color, thickness=-1)
|
| 150 |
return canvas
|
| 151 |
|
| 152 |
+
def draw_pose(pose, H, W, include_body=True, include_hand=True, include_face=True, ref_w=2160, transparent=False, hide_torso_lines=False):
|
| 153 |
"""vis dwpose outputs with optional transparent background
|
| 154 |
|
| 155 |
Args:
|
|
|
|
| 161 |
include_face (bool): whether to draw face keypoints
|
| 162 |
ref_w (int, optional): reference width. Defaults to 2160.
|
| 163 |
transparent (bool, optional): whether to use transparent background. Defaults to False.
|
| 164 |
+
hide_torso_lines (bool, optional): whether to hide torso lines (neck to hips). Defaults to False.
|
| 165 |
|
| 166 |
Returns:
|
| 167 |
np.ndarray: image pixel value in RGBA mode if transparent=True, otherwise RGB mode
|
|
|
|
| 182 |
canvas = np.zeros(shape=(int(H*sr), int(W*sr), 3), dtype=np.uint8)
|
| 183 |
|
| 184 |
if include_body:
|
| 185 |
+
canvas = draw_bodypose(canvas, candidate, subset, score=bodies['score'], transparent=transparent, hide_torso_lines=hide_torso_lines)
|
| 186 |
|
| 187 |
if include_hand:
|
| 188 |
canvas = draw_handpose(canvas, hands, pose['hands_score'], transparent=transparent)
|
generated_pose_video/NOT_FIND_YET_38868_21853_18535_20250804_164149.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:aacb7339e2b5feb1aadced3bce1339a3b6e5d08afa10c59443db70394c671b21
|
| 3 |
-
size 1513592
|
|
|
|
|
|
|
|
|
|
|
|
generated_pose_video/{GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_160832.mp4 → WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315.mp4}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2c838110d6b0c453e18eb6b62aebeca205d5a1e7e32ddd35c042daa6e3ef7fed
|
| 3 |
+
size 2813937
|
generated_pose_video/WHERE_IS_MY_CAT_63084_57261_37469_65313_20250804_164233.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:abe64b40412304c19c220efa7b1b33c6924041d886ca58d50e70285a8a447cab
|
| 3 |
-
size 3622601
|
|
|
|
|
|
|
|
|
|
|
|
generated_sign_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_160832.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:1ffbd69305da539b27e681a13954a6b9976ba7602ae2ecea257650ba5857010c
|
| 3 |
-
size 1044299
|
|
|
|
|
|
|
|
|
|
|
|
generated_sign_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_160832_combined.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:022648fc732f606d65c53f97ab8aa0a6cb738116e20790fac96b8cd2d2577337
|
| 3 |
-
size 1421229
|
|
|
|
|
|
|
|
|
|
|
|
generated_sign_video/HELLO_WORLD_27184_63831_20250804_163910.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:e05f456aaf131625320eb4512d2463e5d9da98c7d2015311a4b060e3596302fa
|
| 3 |
-
size 2397707
|
|
|
|
|
|
|
|
|
|
|
|
generated_sign_video/HELLO_WORLD_27184_63831_20250804_163910_combined.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:7c1b6268c7c731fbcb17a38053d0a3bae156002aa6e21ebf52ff8b2e5fb025b2
|
| 3 |
-
size 2843671
|
|
|
|
|
|
|
|
|
|
|
|
generated_sign_video/I_WILL_ATTEND_THIS_DINNER_PARTY_28794_63364_04007_66628_16327_41325_20250804_164010.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:33b7baa95da80eeeb16e0c3b2a3cc77f5940a2262f9cfa148893d39aa20633e7
|
| 3 |
-
size 2681235
|
|
|
|
|
|
|
|
|
|
|
|
generated_sign_video/I_WILL_ATTEND_THIS_DINNER_PARTY_28794_63364_04007_66628_16327_41325_20250804_164010_combined.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:32f7bc9803c0362d1b6290bd317d0591bf765f4c2a3281c2d63e2d9b34593518
|
| 3 |
-
size 3476159
|
|
|
|
|
|
|
|
|
|
|
|
generated_sign_video/NOT_FIND_YET_38868_21853_18535_20250804_164149.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:bbec8a0943a242a548840e0e4e95316d756dec08180af0597dac259dcaf92d9b
|
| 3 |
-
size 838458
|
|
|
|
|
|
|
|
|
|
|
|
generated_sign_video/NOT_FIND_YET_38868_21853_18535_20250804_164149_combined.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:387c34fcfdc1f60d2a441a441151121831cd8de3d67ea85390fed7202ba6f21f
|
| 3 |
-
size 1151859
|
|
|
|
|
|
|
|
|
|
|
|
generated_pose_video/HELLO_WORLD_27184_63831_20250804_163910.mp4 → generated_sign_video/WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315.mp4
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:771c9a92c0901a0fc897c5a2c7142954ba7dfc02cde76834b4c8e678fa532bb9
|
| 3 |
+
size 3010816
|
generated_pose_video/I_WILL_ATTEND_THIS_DINNER_PARTY_28794_63364_04007_66628_16327_41325_20250804_164010.mp4 → generated_sign_video/WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315_combined.mp4
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:51601f233e5df4c9888351074699c398c934f7041dafb1f18e084e315fd13e86
|
| 3 |
+
size 3590703
|
generated_sign_video/WHERE_IS_MY_CAT_63084_57261_37469_65313_20250804_164233.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:1238bb70c042fdb2f4d2600e22d0fe138068572274e8daf11245cb60d80e3064
|
| 3 |
-
size 1635482
|
|
|
|
|
|
|
|
|
|
|
|
generated_sign_video/WHERE_IS_MY_CAT_63084_57261_37469_65313_20250804_164233_combined.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:358a7345c340a04b85dc5ecadf3bd7b79d5933c47364ae1c810453adf22cb5f4
|
| 3 |
-
size 2354924
|
|
|
|
|
|
|
|
|
|
|
|
text2pose.py
CHANGED
|
@@ -20,6 +20,7 @@ from datetime import datetime
|
|
| 20 |
from easy_dwpose import DWposeDetector
|
| 21 |
from easy_dwpose.draw.controlnext import draw_pose, process_pose_data
|
| 22 |
from utils.npz_interpolation import interpolate_pose_npz, ease_in_out_cubic
|
|
|
|
| 23 |
|
| 24 |
# Fixed configuration
|
| 25 |
JSON_FILE = "pose_dict/WLASL_train.json" # JSON mapping file
|
|
@@ -208,9 +209,13 @@ class SignLanguageQA:
|
|
| 208 |
frame_keys = [k for k in npz_data.keys() if k.startswith('frame_') and k.endswith('_bodies')]
|
| 209 |
return len(frame_keys)
|
| 210 |
|
| 211 |
-
def create_pose_frame(self, frame_data, width=480, height=480):
|
| 212 |
-
"""Create single frame pose image"""
|
| 213 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
processed_pred = process_pose_data(frame_data, height, width)
|
| 215 |
|
| 216 |
vis_img = draw_pose(
|
|
@@ -219,18 +224,172 @@ class SignLanguageQA:
|
|
| 219 |
W=width,
|
| 220 |
include_body=True,
|
| 221 |
include_hand=True,
|
| 222 |
-
include_face=True
|
|
|
|
| 223 |
)
|
| 224 |
|
| 225 |
return vis_img.transpose(1, 2, 0)
|
| 226 |
|
| 227 |
except Exception as e:
|
|
|
|
| 228 |
print(f"⚠️ Failed to create pose frame: {e}")
|
|
|
|
|
|
|
| 229 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
def generate_video_from_glosses(self, gloss_list, output_path, fps=30, width=480, height=480,
|
| 232 |
-
smoothing_frames=5, smoothing_method='none', npz_interpolation_frames=0
|
| 233 |
-
|
|
|
|
| 234 |
# Create output directory
|
| 235 |
output_path.parent.mkdir(parents=True, exist_ok=True)
|
| 236 |
|
|
@@ -282,7 +441,7 @@ class SignLanguageQA:
|
|
| 282 |
for frame_num in range(start_frame, end_frame + 1):
|
| 283 |
frame_data = self.get_frame_data(npz_data, frame_num)
|
| 284 |
if frame_data and self.check_frame_quality(frame_data):
|
| 285 |
-
pose_frame = self.create_pose_frame(frame_data, width, height)
|
| 286 |
if pose_frame is not None:
|
| 287 |
gloss_frames.append(pose_frame)
|
| 288 |
|
|
@@ -352,7 +511,7 @@ class SignLanguageQA:
|
|
| 352 |
|
| 353 |
# Create visual frame
|
| 354 |
if frame_data:
|
| 355 |
-
pose_frame = self.create_pose_frame(frame_data, width, height)
|
| 356 |
if pose_frame is not None:
|
| 357 |
interpolated_pose_frames.append(pose_frame)
|
| 358 |
|
|
@@ -558,7 +717,8 @@ class SignLanguageQA:
|
|
| 558 |
gloss_list, output_file,
|
| 559 |
smoothing_frames=smoothing_frames,
|
| 560 |
smoothing_method=smoothing_method,
|
| 561 |
-
npz_interpolation_frames=npz_interpolation_frames
|
|
|
|
| 562 |
)
|
| 563 |
|
| 564 |
except KeyboardInterrupt:
|
|
@@ -601,6 +761,12 @@ def main():
|
|
| 601 |
help='Smoothing frames (default: 5)')
|
| 602 |
parser.add_argument('--npz-interpolation', type=int, default=0,
|
| 603 |
help='Number of NPZ interpolation frames between glosses (default: 0)')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 604 |
|
| 605 |
args = parser.parse_args()
|
| 606 |
|
|
@@ -628,10 +794,14 @@ def main():
|
|
| 628 |
|
| 629 |
if args.smoothing != 'none':
|
| 630 |
print(f"🌊 Using {args.smoothing} smoothing ({args.smoothing_frames} frames)")
|
|
|
|
|
|
|
|
|
|
| 631 |
|
| 632 |
success = qa_system.generate_video_from_glosses(
|
| 633 |
gloss_list, output_file, args.fps, args.width, args.height,
|
| 634 |
-
args.smoothing_frames, args.smoothing, args.npz_interpolation
|
|
|
|
| 635 |
)
|
| 636 |
|
| 637 |
if not success:
|
|
|
|
| 20 |
from easy_dwpose import DWposeDetector
|
| 21 |
from easy_dwpose.draw.controlnext import draw_pose, process_pose_data
|
| 22 |
from utils.npz_interpolation import interpolate_pose_npz, ease_in_out_cubic
|
| 23 |
+
import copy
|
| 24 |
|
| 25 |
# Fixed configuration
|
| 26 |
JSON_FILE = "pose_dict/WLASL_train.json" # JSON mapping file
|
|
|
|
| 209 |
frame_keys = [k for k in npz_data.keys() if k.startswith('frame_') and k.endswith('_bodies')]
|
| 210 |
return len(frame_keys)
|
| 211 |
|
| 212 |
+
def create_pose_frame(self, frame_data, width=480, height=480, scale_x=1.0, scale_y=1.0, hide_torso_lines=False):
|
| 213 |
+
"""Create single frame pose image with progressive scaling"""
|
| 214 |
try:
|
| 215 |
+
# Apply progressive scaling if needed
|
| 216 |
+
if scale_x != 1.0 or scale_y != 1.0:
|
| 217 |
+
frame_data = self.apply_progressive_scaling(frame_data, scale_x, scale_y)
|
| 218 |
+
|
| 219 |
processed_pred = process_pose_data(frame_data, height, width)
|
| 220 |
|
| 221 |
vis_img = draw_pose(
|
|
|
|
| 224 |
W=width,
|
| 225 |
include_body=True,
|
| 226 |
include_hand=True,
|
| 227 |
+
include_face=True,
|
| 228 |
+
hide_torso_lines=hide_torso_lines
|
| 229 |
)
|
| 230 |
|
| 231 |
return vis_img.transpose(1, 2, 0)
|
| 232 |
|
| 233 |
except Exception as e:
|
| 234 |
+
import traceback
|
| 235 |
print(f"⚠️ Failed to create pose frame: {e}")
|
| 236 |
+
print("Traceback:")
|
| 237 |
+
traceback.print_exc()
|
| 238 |
return None
|
| 239 |
+
|
| 240 |
+
def apply_progressive_scaling(self, frame_data, scale_x, scale_y):
|
| 241 |
+
"""Apply progressive scaling - minimal at top, maximal at bottom"""
|
| 242 |
+
scaled_data = copy.deepcopy(frame_data)
|
| 243 |
+
|
| 244 |
+
# Process bodies
|
| 245 |
+
if 'bodies' in scaled_data and scaled_data['bodies'] is not None:
|
| 246 |
+
bodies = scaled_data['bodies'].copy()
|
| 247 |
+
|
| 248 |
+
# Debug: check shape
|
| 249 |
+
# print(f"Bodies shape: {bodies.shape}")
|
| 250 |
+
|
| 251 |
+
# Find the top point (minimum Y) to use as anchor
|
| 252 |
+
y_values = bodies[:, 1]
|
| 253 |
+
valid_mask = y_values > 0
|
| 254 |
+
valid_y = y_values[valid_mask]
|
| 255 |
+
if len(valid_y) > 0:
|
| 256 |
+
min_y = np.min(valid_y)
|
| 257 |
+
max_y = np.max(valid_y)
|
| 258 |
+
y_range = max_y - min_y if max_y > min_y else 1.0
|
| 259 |
+
|
| 260 |
+
# Apply progressive scaling
|
| 261 |
+
for i in range(len(bodies)):
|
| 262 |
+
if bodies[i, 1] > 0: # Valid point
|
| 263 |
+
# Calculate progress from top to bottom (0 to 1)
|
| 264 |
+
progress = (bodies[i, 1] - min_y) / y_range
|
| 265 |
+
|
| 266 |
+
# Progressive Y scaling: 1.0 at top, scale_y at bottom
|
| 267 |
+
y_scale = 1.0 + (scale_y - 1.0) * progress
|
| 268 |
+
|
| 269 |
+
# Progressive X scaling: adjust to maintain proportions
|
| 270 |
+
x_scale = 1.0 + (scale_x - 1.0) * progress
|
| 271 |
+
|
| 272 |
+
# Apply scaling relative to the top anchor point
|
| 273 |
+
# Y: scale from the top point
|
| 274 |
+
bodies[i, 1] = min_y + (bodies[i, 1] - min_y) * y_scale
|
| 275 |
+
|
| 276 |
+
# X: scale from center of the pose
|
| 277 |
+
center_x = 0.5 # Assume normalized coordinates
|
| 278 |
+
bodies[i, 0] = center_x + (bodies[i, 0] - center_x) * x_scale
|
| 279 |
+
|
| 280 |
+
scaled_data['bodies'] = bodies
|
| 281 |
+
|
| 282 |
+
# Apply same scaling to hands
|
| 283 |
+
if 'hands' in scaled_data and scaled_data['hands'] is not None:
|
| 284 |
+
hands = scaled_data['hands'].copy()
|
| 285 |
+
|
| 286 |
+
# Debug: check hands shape
|
| 287 |
+
# print(f"Hands shape: {hands.shape}")
|
| 288 |
+
|
| 289 |
+
# Find reference points for hands
|
| 290 |
+
if 'bodies' in frame_data and frame_data['bodies'] is not None and len(frame_data['bodies']) > 0:
|
| 291 |
+
# Use the same min_y from bodies
|
| 292 |
+
y_values = frame_data['bodies'][:, 1]
|
| 293 |
+
valid_mask = y_values > 0
|
| 294 |
+
valid_y = y_values[valid_mask]
|
| 295 |
+
if len(valid_y) > 0:
|
| 296 |
+
min_y = np.min(valid_y)
|
| 297 |
+
max_y = np.max(valid_y)
|
| 298 |
+
y_range = max_y - min_y if max_y > min_y else 1.0
|
| 299 |
+
|
| 300 |
+
# Hands might be shape (2, 21, 2) or similar - iterate over hands
|
| 301 |
+
if len(hands.shape) == 3:
|
| 302 |
+
# Multiple hands
|
| 303 |
+
for h in range(hands.shape[0]):
|
| 304 |
+
for i in range(hands.shape[1]):
|
| 305 |
+
y_val = float(hands[h, i, 1])
|
| 306 |
+
if y_val > 0: # Valid point
|
| 307 |
+
progress = (y_val - min_y) / y_range
|
| 308 |
+
progress = np.clip(progress, 0, 1)
|
| 309 |
+
|
| 310 |
+
y_scale = 1.0 + (scale_y - 1.0) * progress
|
| 311 |
+
x_scale = 1.0 + (scale_x - 1.0) * progress
|
| 312 |
+
|
| 313 |
+
x_val = float(hands[h, i, 0])
|
| 314 |
+
hands[h, i, 1] = min_y + (y_val - min_y) * y_scale
|
| 315 |
+
center_x = 0.5
|
| 316 |
+
hands[h, i, 0] = center_x + (x_val - center_x) * x_scale
|
| 317 |
+
else:
|
| 318 |
+
# Single array of points
|
| 319 |
+
for i in range(len(hands)):
|
| 320 |
+
y_val = float(hands[i, 1])
|
| 321 |
+
if y_val > 0: # Valid point
|
| 322 |
+
progress = (y_val - min_y) / y_range
|
| 323 |
+
progress = np.clip(progress, 0, 1)
|
| 324 |
+
|
| 325 |
+
y_scale = 1.0 + (scale_y - 1.0) * progress
|
| 326 |
+
x_scale = 1.0 + (scale_x - 1.0) * progress
|
| 327 |
+
|
| 328 |
+
x_val = float(hands[i, 0])
|
| 329 |
+
hands[i, 1] = min_y + (y_val - min_y) * y_scale
|
| 330 |
+
center_x = 0.5
|
| 331 |
+
hands[i, 0] = center_x + (x_val - center_x) * x_scale
|
| 332 |
+
|
| 333 |
+
scaled_data['hands'] = hands
|
| 334 |
+
|
| 335 |
+
# Apply same scaling to faces
|
| 336 |
+
if 'faces' in scaled_data and scaled_data['faces'] is not None:
|
| 337 |
+
faces = scaled_data['faces'].copy()
|
| 338 |
+
|
| 339 |
+
# Debug: check faces shape
|
| 340 |
+
# print(f"Faces shape: {faces.shape}")
|
| 341 |
+
|
| 342 |
+
# Faces are usually at the top, so apply minimal scaling
|
| 343 |
+
if 'bodies' in frame_data and frame_data['bodies'] is not None and len(frame_data['bodies']) > 0:
|
| 344 |
+
y_values = frame_data['bodies'][:, 1]
|
| 345 |
+
valid_mask = y_values > 0
|
| 346 |
+
valid_y = y_values[valid_mask]
|
| 347 |
+
if len(valid_y) > 0:
|
| 348 |
+
min_y = np.min(valid_y)
|
| 349 |
+
max_y = np.max(valid_y)
|
| 350 |
+
y_range = max_y - min_y if max_y > min_y else 1.0
|
| 351 |
+
|
| 352 |
+
# Faces might be shape (1, 68, 2) or similar - iterate properly
|
| 353 |
+
if len(faces.shape) == 3:
|
| 354 |
+
# Multiple faces
|
| 355 |
+
for f in range(faces.shape[0]):
|
| 356 |
+
for i in range(faces.shape[1]):
|
| 357 |
+
y_val = float(faces[f, i, 1])
|
| 358 |
+
if y_val > 0: # Valid point
|
| 359 |
+
progress = (y_val - min_y) / y_range
|
| 360 |
+
progress = np.clip(progress, 0, 1)
|
| 361 |
+
|
| 362 |
+
y_scale = 1.0 + (scale_y - 1.0) * progress
|
| 363 |
+
x_scale = 1.0 + (scale_x - 1.0) * progress
|
| 364 |
+
|
| 365 |
+
x_val = float(faces[f, i, 0])
|
| 366 |
+
faces[f, i, 1] = min_y + (y_val - min_y) * y_scale
|
| 367 |
+
center_x = 0.5
|
| 368 |
+
faces[f, i, 0] = center_x + (x_val - center_x) * x_scale
|
| 369 |
+
else:
|
| 370 |
+
# Single array of points
|
| 371 |
+
for i in range(len(faces)):
|
| 372 |
+
y_val = float(faces[i, 1])
|
| 373 |
+
if y_val > 0: # Valid point
|
| 374 |
+
progress = (y_val - min_y) / y_range
|
| 375 |
+
progress = np.clip(progress, 0, 1)
|
| 376 |
+
|
| 377 |
+
y_scale = 1.0 + (scale_y - 1.0) * progress
|
| 378 |
+
x_scale = 1.0 + (scale_x - 1.0) * progress
|
| 379 |
+
|
| 380 |
+
x_val = float(faces[i, 0])
|
| 381 |
+
faces[i, 1] = min_y + (y_val - min_y) * y_scale
|
| 382 |
+
center_x = 0.5
|
| 383 |
+
faces[i, 0] = center_x + (x_val - center_x) * x_scale
|
| 384 |
+
|
| 385 |
+
scaled_data['faces'] = faces
|
| 386 |
+
|
| 387 |
+
return scaled_data
|
| 388 |
|
| 389 |
def generate_video_from_glosses(self, gloss_list, output_path, fps=30, width=480, height=480,
|
| 390 |
+
smoothing_frames=5, smoothing_method='none', npz_interpolation_frames=0,
|
| 391 |
+
scale_x=1.0, scale_y=1.0, hide_torso_lines=False):
|
| 392 |
+
"""Generate video from gloss list with optional progressive scaling"""
|
| 393 |
# Create output directory
|
| 394 |
output_path.parent.mkdir(parents=True, exist_ok=True)
|
| 395 |
|
|
|
|
| 441 |
for frame_num in range(start_frame, end_frame + 1):
|
| 442 |
frame_data = self.get_frame_data(npz_data, frame_num)
|
| 443 |
if frame_data and self.check_frame_quality(frame_data):
|
| 444 |
+
pose_frame = self.create_pose_frame(frame_data, width, height, scale_x, scale_y, hide_torso_lines)
|
| 445 |
if pose_frame is not None:
|
| 446 |
gloss_frames.append(pose_frame)
|
| 447 |
|
|
|
|
| 511 |
|
| 512 |
# Create visual frame
|
| 513 |
if frame_data:
|
| 514 |
+
pose_frame = self.create_pose_frame(frame_data, width, height, scale_x, scale_y, hide_torso_lines)
|
| 515 |
if pose_frame is not None:
|
| 516 |
interpolated_pose_frames.append(pose_frame)
|
| 517 |
|
|
|
|
| 717 |
gloss_list, output_file,
|
| 718 |
smoothing_frames=smoothing_frames,
|
| 719 |
smoothing_method=smoothing_method,
|
| 720 |
+
npz_interpolation_frames=npz_interpolation_frames,
|
| 721 |
+
hide_torso_lines=False
|
| 722 |
)
|
| 723 |
|
| 724 |
except KeyboardInterrupt:
|
|
|
|
| 761 |
help='Smoothing frames (default: 5)')
|
| 762 |
parser.add_argument('--npz-interpolation', type=int, default=0,
|
| 763 |
help='Number of NPZ interpolation frames between glosses (default: 0)')
|
| 764 |
+
parser.add_argument('--scale-x', type=float, default=1.0,
|
| 765 |
+
help='Progressive X-axis scaling factor (default: 1.0)')
|
| 766 |
+
parser.add_argument('--scale-y', type=float, default=1.0,
|
| 767 |
+
help='Progressive Y-axis scaling factor (default: 1.0)')
|
| 768 |
+
parser.add_argument('--hide-torso-lines', type=str, choices=['true', 'false'], default='false',
|
| 769 |
+
help='Hide torso lines from neck to hips (set to black). Choices: true/false (default: false)')
|
| 770 |
|
| 771 |
args = parser.parse_args()
|
| 772 |
|
|
|
|
| 794 |
|
| 795 |
if args.smoothing != 'none':
|
| 796 |
print(f"🌊 Using {args.smoothing} smoothing ({args.smoothing_frames} frames)")
|
| 797 |
+
|
| 798 |
+
if args.scale_x != 1.0 or args.scale_y != 1.0:
|
| 799 |
+
print(f"📏 Using progressive scaling: X={args.scale_x}, Y={args.scale_y}")
|
| 800 |
|
| 801 |
success = qa_system.generate_video_from_glosses(
|
| 802 |
gloss_list, output_file, args.fps, args.width, args.height,
|
| 803 |
+
args.smoothing_frames, args.smoothing, args.npz_interpolation,
|
| 804 |
+
args.scale_x, args.scale_y, args.hide_torso_lines == 'true'
|
| 805 |
)
|
| 806 |
|
| 807 |
if not success:
|
useless/abandon_cmd.md
CHANGED
|
@@ -67,7 +67,7 @@ CUDA_VISIBLE_DEVICES=3 python ControlNeXt-SVD-v2/run_controlnext_optimized.py \
|
|
| 67 |
--width 512 \
|
| 68 |
--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \
|
| 69 |
--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \
|
| 70 |
-
--pose_video_path generated_pose_video/
|
| 71 |
--ref_image_path ref_img_dict/lis_ref.jpg \
|
| 72 |
--precision fp16 \
|
| 73 |
--decode_chunk_size 2 \
|
|
|
|
| 67 |
--width 512 \
|
| 68 |
--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \
|
| 69 |
--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \
|
| 70 |
+
--pose_video_path generated_pose_video/WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315.mp4 \
|
| 71 |
--ref_image_path ref_img_dict/lis_ref.jpg \
|
| 72 |
--precision fp16 \
|
| 73 |
--decode_chunk_size 2 \
|