Add Control v2 incremental experiment results (evidence, visuals, 42 fixed samples)
a64600b verified Download method_v2/evidence/code/suite/momask_loading.py from CharlesZhang-USTC/snf_experiments: direct link, hf CLI and curl.
- Browser
- Download file 1.82 kB
-
https://huggingface.co/CharlesZhang-USTC/snf_experiments/resolve/main/method_v2/evidence/code/suite/momask_loading.py
- Command line
-
hf download hf://CharlesZhang-USTC/snf_experiments/method_v2/evidence/code/suite/momask_loading.py
-
curl -L -o momask_loading.py https://huggingface.co/CharlesZhang-USTC/snf_experiments/resolve/main/method_v2/evidence/code/suite/momask_loading.py
1.82 kB
| """Use official loading functions without importing optional legacy BVH exporter. | |
| gen_t2m imports numpy.core.umath_tests through its optional BVH code. That | |
| private NumPy API was removed. Inference only needs its three loading helpers. | |
| We compile those exact upstream AST nodes; upstream code is not edited. | |
| """ | |
| import ast | |
| import os | |
| import torch | |
| from .design import ROOT | |
| def numpy_legacy_aliases(): | |
| """Restore aliases NumPy removed in 1.24; upstream MoMask still uses np.float/np.int. | |
| Applied in the harness process only. Vendored upstream files are untouched, so | |
| packaging/sources.manifest.json keeps verifying all 397 upstream files. | |
| """ | |
| import numpy as np | |
| for name, replacement in (('float', float), ('int', int), ('bool', bool), | |
| ('object', object), ('str', str), ('complex', complex)): | |
| if not hasattr(np, name): | |
| setattr(np, name, replacement) | |
| return np | |
| numpy_legacy_aliases() | |
| def loading_functions(): | |
| from models.mask_transformer.transformer import MaskTransformer,ResidualTransformer | |
| from models.vq.model import RVQVAE | |
| file=ROOT/'vendor/momask/gen_t2m.py' | |
| tree=ast.parse(file.read_text(encoding='utf-8'),filename=str(file)) | |
| names={'load_vq_model','load_trans_model','load_res_model'} | |
| nodes=[node for node in tree.body if isinstance(node,ast.FunctionDef) and node.name in names] | |
| if {node.name for node in nodes}!=names:raise RuntimeError('Upstream loader API changed') | |
| scope=dict(torch=torch,pjoin=os.path.join,clip_version='ViT-B/32',MaskTransformer=MaskTransformer,ResidualTransformer=ResidualTransformer,RVQVAE=RVQVAE) | |
| exec(compile(ast.Module(body=nodes,type_ignores=[]),str(file),'exec'),scope) | |
| return tuple(scope[name] for name in ('load_vq_model','load_trans_model','load_res_model')) | |