o –üeø ã@s˜ddlmZddlmZddlmZddlmZddlm Z dede fd d „Z defd d „Z dede fd d„Z defdd„Zdedeejfdd„ZdS)é)ÚOptional)Únn)ÚCfgNodeé)ÚEmbedder©ÚDensePoseDataFilterÚcfgÚinput_channelscCó&ddlm}|jjj}| |¡||ƒS)a Create an instance of DensePose predictor based on configuration options. Args: cfg (CfgNode): configuration options input_channels (int): input tensor size along the channel dimension Return: An instance of DensePose predictor r)ÚDENSEPOSE_PREDICTOR_REGISTRYN)Z predictorsr ÚMODELÚROI_DENSEPOSE_HEADÚPREDICTOR_NAMEÚget)r r r Zpredictor_name©rúL/home/jovyan/fileviewer/workspace/yisol/IDM-VTON/densepose/modeling/build.pyÚbuild_densepose_predictor ó rcCs t|ƒ}|S)an Build DensePose data filter which selects data for training Args: cfg (CfgNode): configuration options Return: Callable: list(Tensor), list(Instances) -> list(Tensor), list(Instances) An instance of DensePose filter, which takes feature tensors and proposals as an input and returns filtered features and proposals Nr)r Z dp_filterrrrÚbuild_densepose_data_filters rcCr )zô Build DensePose head based on configurations options Args: cfg (CfgNode): configuration options input_channels (int): input tensor size along the channel dimension Return: An instance of DensePose head r)ÚROI_DENSEPOSE_HEAD_REGISTRYN)Zroi_heads.registryrr rÚNAMEr)r r rZ head_namerrrÚbuild_densepose_head,rrcCs$ddlm}|jjj}| |¡|ƒS)z¨ Build DensePose loss based on configurations options Args: cfg (CfgNode): configuration options Return: An instance of DensePose loss r)ÚDENSEPOSE_LOSS_REGISTRYN)Úlossesrr rÚ LOSS_NAMEr)r rÚ loss_namerrrÚbuild_densepose_losses<s rÚreturncCs|jjjjr t|ƒSdS)zå Build embedder used to embed mesh vertices into an embedding space. Embedder contains sub-embedders, one for each mesh ID. Args: cfg (cfgNode): configuration options Return: Embedding module N)r rÚCSEÚ EMBEDDERSr)r rrrÚbuild_densepose_embedderKs r!N)ÚtypingrÚtorchrÚdetectron2.configrZ cse.embedderrÚfilterrÚintrrrrÚModuler!rrrrÚs