Skip to content

Commit c9e3a25

Browse files
committed
Update webui
1 parent 81f44a1 commit c9e3a25

File tree

7 files changed

+316
-119
lines changed

7 files changed

+316
-119
lines changed

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,12 @@
1717

1818
</div>
1919

20-
21-
2220
<div align="center">
2321

24-
2522
https://github.com/OpenMotionLab/MotionGPT/assets/120085716/a741e162-b2f4-4f65-af8e-aa19c4115a9e
2623

2724
https://github.com/OpenMotionLab/MotionGPT/assets/120085716/5b60aebc-ce80-42e8-8a4c-1f673e85b84e
2825

29-
30-
31-
3226
<!-- <img src="https://cdn.discordapp.com/attachments/941582479117127680/1111543600879259749/20230526075532.png" width="350px"> -->
3327
</div>
3428

@@ -223,7 +217,7 @@ YOUR_BLENDER_PYTHON_PATH/python -m pip install -r prepare/requirements_render.tx
223217
Run the following command using blender:
224218

225219
```
226-
YOUR_BLENDER_PATH/blender --background --python render.py -- --cfg=./configs/render.yaml --dir=YOUR_NPY_FOLDER --mode=video --joint_type=HumanML3D
220+
YOUR_BLENDER_PATH/blender --background --python render.py -- --cfg=./configs/render.yaml --dir=YOUR_NPY_FOLDER --mode=video
227221
```
228222

229223
### 2. Create SMPL meshes with:
@@ -242,7 +236,7 @@ This outputs:
242236
Run the following command to render SMPL using blender:
243237

244238
```
245-
YOUR_BLENDER_PATH/blender --background --python render.py -- --cfg=./configs/render.yaml --dir=YOUR_NPY_FOLDER --mode=video --joint_type=HumanML3D
239+
YOUR_BLENDER_PATH/blender --background --python render.py -- --cfg=./configs/render.yaml --dir=YOUR_NPY_FOLDER --mode=video
246240
```
247241

248242
optional parameters:

app.py

Lines changed: 277 additions & 63 deletions
Large diffs are not rendered by default.

mGPT/utils/demo_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def render(execute_python, npy_path, jointtype, cfg_path):
3232
export_scripts = "render.py"
3333

3434
os.system(
35-
f"{execute_python} --background --python {export_scripts} -- --cfg={cfg_path} --npy={npy_path} --joint_type={jointtype}"
35+
f"{execute_python} --background --python {export_scripts} -- --cfg={cfg_path} --npy={npy_path}"
3636
)
3737

3838
fig_path = Path(str(npy_path).replace(".npy", ".png"))

mGPT/utils/geometry_conver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def estimate_translation(S, joints_2d, focal_length=5000., img_size=224.):
447447
joints_2d = joints_2d[:, 25:, :].cpu().numpy()
448448
joints_conf = joints_2d[:, :, -1]
449449
joints_2d = joints_2d[:, :, :-1]
450-
trans = np.zeros((S.shape[0], 3), dtype=np.float6432)
450+
trans = np.zeros((S.shape[0], 3), dtype=np.float32)
451451
# Find the translation for each example in the batch
452452
for i in range(S.shape[0]):
453453
S_i = S[i]

public/css/custom.css

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,26 @@
3535
min-height: 500px;
3636
}
3737

38+
[class*='message-buttons'] {
39+
visibility: hidden;
40+
}
41+
3842
[class*='message'] {
39-
border-radius: var(--radius-xl) !important;
4043
border: none;
41-
padding: var(--spacing-xl) !important;
42-
font-size: var(--text-xl) !important;
43-
line-height: var(--line-lg) !important;
44-
min-height: calc(var(--text-lg) * var(--line-lg) + 2 * var(--spacing-xl));
45-
min-width: calc(var(--text-lg) * var(--line-lg) + 2 * var(--spacing-xl));
44+
border-radius: var(--radius-xl) !important;
45+
/* font-size: var(--text-xl) !important;
46+
line-height: var(--line-xl) !important; */
4647
}
48+
4749
[data-testid='bot'] {
48-
max-width: 85%;
50+
max-width: 70%;
4951
width: auto !important;
50-
border-bottom-left-radius: 0 !important;
52+
/* border-bottom-left-radius: 0 !important; */
5153
}
5254
[data-testid='user'] {
53-
max-width: 85%;
55+
max-width: 70%;
5456
width: auto !important;
55-
border-bottom-right-radius: 0 !important;
57+
/* border-bottom-right-radius: 0 !important; */
5658
}
5759

5860
/* Text & Video */
@@ -64,22 +66,7 @@
6466
max-width: 340px;
6567
}
6668

67-
@media only screen and (min-width: 768px) {
68-
.side-content {
69-
float: left;
70-
overflow-wrap: break-word;
71-
padding-right: 2rem;
72-
}
73-
74-
.side-video {
75-
float: right;
76-
}
77-
}
78-
7969
/* Buttom */
80-
#upload {
81-
color: #000000;
82-
}
8370

8471
.videodl-button {
8572
position: absolute;

scripts/fit_motion_parallel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# parallel render
2-
for i in `seq 0 4`
2+
for i in `seq 0 7`
33
do
44
for j in `seq 0 1`
55
do

scripts/get_code_visual.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
from mGPT.models.build_model import build_model
1010
from mGPT.utils.load_checkpoint import load_pretrained, load_pretrained_vae
1111

12+
1213
def main():
1314

1415
# parse options
1516
cfg = parse_args(phase="test") # parse config file
1617
cfg.TRAIN.STAGE = "token"
1718
cfg.TRAIN.BATCH_SIZE = 1
18-
19+
1920
model_name = cfg.model.target.split('.')[-2].lower()
20-
output_dir = Path(os.path.join(cfg.FOLDER, model_name, cfg.NAME, "tokens_visual_" + cfg.TIME))
21+
output_dir = Path(
22+
os.path.join(cfg.FOLDER, model_name, cfg.NAME,
23+
"tokens_visual_" + cfg.TIME))
2124

2225
# set seed
2326
pl.seed_everything(cfg.SEED_VALUE)
@@ -44,39 +47,38 @@ def main():
4447
# loading state dict
4548
if cfg.TEST.CHECKPOINTS:
4649
load_pretrained(cfg, model, phase="test")
47-
50+
4851
if cfg.ACCELERATOR == "gpu":
4952
model = model.cuda()
50-
53+
5154
model.eval()
5255
codes = cfg.model.params.codebook_size
5356
with torch.no_grad():
5457
for i in tqdm(range(codes)):
55-
58+
5659
# Generate motion from token
5760
m_token = torch.LongTensor(1, 1).fill_(i).to(model.device)
5861
# vq_latent = model.vae.quantizer.dequantize(m_token)
5962
gen_motion = model.vae.decode(m_token)
6063
gen_motion = model.feats2joints(gen_motion).to('cpu').numpy()
61-
64+
6265
# Generate translation from token
63-
texts = [f'Generate text: <motion_id_{codes}><motion_id_{i}><motion_id_{codes +1}>']
66+
texts = [
67+
f'Generate text: <motion_id_{codes}><motion_id_{i}><motion_id_{codes +1}>'
68+
]
6469
# texts = [f'Use only one word to describe: <motion_id_{codes}><motion_id_{i}><motion_id_{codes +1}>']
65-
batch = {
66-
"text": texts,
67-
"length": [0]
68-
}
69-
70-
out_text = model(batch)['texts']
71-
print(out_text)
72-
out_text_path = os.path.join(output_dir, f'{i}.txt')
73-
Path(out_text_path).parent.mkdir(parents=True, exist_ok=True)
74-
with open(out_text_path, 'w') as f:
75-
f.write(out_text[0])
76-
70+
batch = {"text": texts, "length": [0]}
71+
72+
# out_text = model(batch)['texts']
73+
# print(out_text)
74+
# out_text_path = os.path.join(output_dir, f'{i}.txt')
75+
# Path(out_text_path).parent.mkdir(parents=True, exist_ok=True)
76+
# with open(out_text_path, 'w') as f:
77+
# f.write(out_text[0])
78+
7779
target_path = os.path.join(output_dir, f'{i}.npy')
7880
Path(target_path).parent.mkdir(parents=True, exist_ok=True)
79-
81+
8082
np.save(target_path, gen_motion)
8183

8284
print(

0 commit comments

Comments
 (0)