MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / create

Function create

util/smplx/smplx/body_models.py:2273–2333  ·  view source on GitHub ↗

Method for creating a model from a path and a model type. Parameters ---------- model_path: str Either the path to the model you wish to load or a folder, where each subfolder contains the differents types, i.e.: model_path: | |-- smpl

(model_path: str,
           model_type: str = 'smpl',
           **kwargs)

Source from the content-addressed store, hash-verified

2271
2272
2273def create(model_path: str,
2274 model_type: str = 'smpl',
2275 **kwargs) -> Union[SMPL, SMPLH, SMPLX, MANO, FLAME]:
2276 """Method for creating a model from a path and a model type.
2277
2278 Parameters
2279 ----------
2280 model_path: str
2281 Either the path to the model you wish to load or a folder,
2282 where each subfolder contains the differents types, i.e.:
2283 model_path:
2284 |
2285 |-- smpl
2286 |-- SMPL_FEMALE
2287 |-- SMPL_NEUTRAL
2288 |-- SMPL_MALE
2289 |-- smplh
2290 |-- SMPLH_FEMALE
2291 |-- SMPLH_MALE
2292 |-- smplx
2293 |-- SMPLX_FEMALE
2294 |-- SMPLX_NEUTRAL
2295 |-- SMPLX_MALE
2296 |-- mano
2297 |-- MANO RIGHT
2298 |-- MANO LEFT
2299
2300 model_type: str, optional
2301 When model_path is a folder, then this parameter specifies the
2302 type of model to be loaded
2303 **kwargs: dict
2304 Keyword arguments
2305
2306 Returns
2307 -------
2308 body_model: nn.Module
2309 The PyTorch module that implements the corresponding body model
2310 Raises
2311 ------
2312 ValueError: In case the model type is not one of SMPL, SMPLH,
2313 SMPLX, MANO or FLAME
2314 """
2315
2316 # If it's a folder, assume
2317 if osp.isdir(model_path):
2318 model_path = os.path.join(model_path, model_type)
2319 else:
2320 model_type = osp.basename(model_path).split('_')[0].lower()
2321
2322 if model_type.lower() == 'smpl':
2323 return SMPL(model_path, **kwargs)
2324 elif model_type.lower() == 'smplh':
2325 return SMPLH(model_path, **kwargs)
2326 elif model_type.lower() == 'smplx':
2327 return SMPLX(model_path, **kwargs)
2328 elif 'mano' in model_type.lower():
2329 return MANO(model_path, **kwargs)
2330 elif 'flame' in model_type.lower():

Callers

nothing calls this directly

Calls 5

SMPLHClass · 0.85
SMPLClass · 0.70
SMPLXClass · 0.70
MANOClass · 0.70
FLAMEClass · 0.70

Tested by

no test coverage detected