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
)
| 2203 | |
| 2204 | |
| 2205 | def build_layer( |
| 2206 | model_path: str, |
| 2207 | model_type: str = 'smpl', |
| 2208 | **kwargs |
| 2209 | ) -> Union[SMPLLayer, SMPLHLayer, SMPLXLayer, MANOLayer, FLAMELayer]: |
| 2210 | """Method for creating a model from a path and a model type. |
| 2211 | |
| 2212 | Parameters |
| 2213 | ---------- |
| 2214 | model_path: str |
| 2215 | Either the path to the model you wish to load or a folder, |
| 2216 | where each subfolder contains the differents types, i.e.: |
| 2217 | model_path: |
| 2218 | | |
| 2219 | |-- smpl |
| 2220 | |-- SMPL_FEMALE |
| 2221 | |-- SMPL_NEUTRAL |
| 2222 | |-- SMPL_MALE |
| 2223 | |-- smplh |
| 2224 | |-- SMPLH_FEMALE |
| 2225 | |-- SMPLH_MALE |
| 2226 | |-- smplx |
| 2227 | |-- SMPLX_FEMALE |
| 2228 | |-- SMPLX_NEUTRAL |
| 2229 | |-- SMPLX_MALE |
| 2230 | |-- mano |
| 2231 | |-- MANO RIGHT |
| 2232 | |-- MANO LEFT |
| 2233 | |-- flame |
| 2234 | |-- FLAME_FEMALE |
| 2235 | |-- FLAME_MALE |
| 2236 | |-- FLAME_NEUTRAL |
| 2237 | |
| 2238 | model_type: str, optional |
| 2239 | When model_path is a folder, then this parameter specifies the |
| 2240 | type of model to be loaded |
| 2241 | **kwargs: dict |
| 2242 | Keyword arguments |
| 2243 | |
| 2244 | Returns |
| 2245 | ------- |
| 2246 | body_model: nn.Module |
| 2247 | The PyTorch module that implements the corresponding body model |
| 2248 | Raises |
| 2249 | ------ |
| 2250 | ValueError: In case the model type is not one of SMPL, SMPLH, |
| 2251 | SMPLX, MANO or FLAME |
| 2252 | """ |
| 2253 | |
| 2254 | if osp.isdir(model_path): |
| 2255 | model_path = os.path.join(model_path, model_type) |
| 2256 | else: |
| 2257 | model_type = osp.basename(model_path).split('_')[0].lower() |
| 2258 | |
| 2259 | if model_type.lower() == 'smpl': |
| 2260 | return SMPLLayer(model_path, **kwargs) |
| 2261 | elif model_type.lower() == 'smplh': |
| 2262 | return SMPLHLayer(model_path, **kwargs) |
nothing calls this directly
no test coverage detected