README.md
May 6, 2026 ยท View on GitHub
Semantify:
Simplifying the Control of 3D Morphable Models using CLIP
ICCV 2023
๐ฅ๏ธ Project Page | ๐ Paper
Semantify offers a method to create and edit a 3D parametric model using semantically meaningful descriptors. Semantify is based on a self-supervised method that utilizes the semantic power of CLIP language-vision model to build a mapping between semantic descriptors to 3DMM model coefficients. This can be used in an interactive application defining a slider for each descriptor (a), or to fit a model to an image in a zero shot manner by feeding the image into CLIP and obtaining a vector of semantic scores that can be mapped to shape parameters (b).
Installation
- Clone the repo:
git clone https://github.com/Omergral/Semantify.git
cd Semantify
- Create new conda environment:
conda env create -f requirements.yml
conda activate semantify
pip install -e .
Download Models
Semantify Mappers
- run
bash ./get_mappers.shmodels_ckpts โโโ flame โย ย โโโ expression โย ย โย ย โโโ flame_expression.ckpt โย ย โย ย โโโ flame_expression_metadata.json โย ย โโโ shape โย ย โโโ flame_shape.ckpt โย ย โโโ flame_shape_metadata.json โโโ smal โย ย โโโ smal.ckpt โย ย โโโ smal_metadata.json โโโ smpl โย ย โโโ smpl_female.ckpt โย ย โโโ smpl_female_metadata.json โย ย โโโ smpl_male.ckpt โย ย โโโ smpl_male_metadata.json โย ย โโโ smpl_neutral.ckpt โย ย โโโ smpl_neutral_metadata.json โโโ smplx โโโ smplx_female.ckpt โโโ smplx_female_metadata.json โโโ smplx_male.ckpt โโโ smplx_male_metadata.json โโโ smplx_neutral.ckpt โโโ smplx_neutral_metadata.json
3D Morphable Models
-
FLAME [Li et al. 2017]
- Register to FLAME and download the following:
- FLAME 2020
- FLAME texture space
- Download static landmarks embedding
- Then organize the files in
semantify/assets/flameas follows:โโโ flame ย ย โโโ female_model.pkl ย ย โโโ flame.py ย ย โโโ flame_static_embedding_68.pkl ย ย โโโ ft.npy ย ย โโโ generic_model.pkl ย ย โโโ male_model.pkl ย ย โโโ mean.npy ย ย โโโ vt.npy
- Register to FLAME and download the following:
-
SMPL [Loper et al. 2015]
- Register to SMPL and download the following:
- Download version 1.1.0 for python 2.7
- Download UV map in OBJ format
- Textures could be downloaded from MeshCapade
- Then organize the files in
semantify/assets/smplas follows:โโโ smpl ย ย โโโ SMPL_FEMALE.pkl ย ย โโโ SMPL_MALE.pkl ย ย โโโ SMPL_NEUTRAL.pkl ย ย โโโ smpl_texture.png ย ย โโโ smpl_uv.obj
- Register to SMPL and download the following:
-
SMPL-X [Pavlakos et al. 2019]
- Register to SMPLX and download the following:
- SMPL-X v1.1 (NPZ+PKL, 830MB)
- Textures could be downloaded from qzane or using the SMPL texture which will not fit perfectly, but our method works well with it.
- Then organize the files in
semantify/assets/smplxas follows:โโโ smplx ย ย โโโ a_pose.npy ย ย โโโ SMPLX_FEMALE.npz ย ย โโโ SMPLX_MALE.npz ย ย โโโ SMPLX_NEUTRAL.npz ย ย โโโ smplx_texture.png
- Register to SMPLX and download the following:
-
SMAL [Zuffi et al. 2017]
- Register to SMAL and download the following:
- SMAL model version 1.0.0
- Then get
smal_CVPR2017.pklfile and place it insemantify/assets/smalโโโ smal ย ย โโโ smal_CVPR2017.pkl ย ย โโโ smal_layer.py
- Register to SMAL and download the following:
Pose Estimation
- SPIN [Kolotouros et al. 2019]
- Clone SPIN repo, then run:
cd SPIN ./fetch_data.sh - Then copy
SPIN/data/smpl_mean_params.npzandSPIN/data/model_checkpoint.pttosemantify/assets/spinโโโ spin โโโ model_checkpoint.pt โโโ smpl_mean_params.npz โโโ spin_model.py
- Clone SPIN repo, then run:
Run Demos
Sliders Application
python semantify/applications/sliders_demo_py3d.py --model_type <MODELTYPE> --specific <SPECIFIC>
Arguments Description:
model_type (str)- "smplx" | "smpl" | "flame" | "smal"specific (str)- "male" | "female" | "neutral" | "expression" | "shape"image_path (Optional[str])- If you want to run the demo on an image, provide the path to the imagemapper_path (Optional[str])- If you don't want to use Semantify's mappers, set the path to desired ckpt fileuse_raw_blendshapes (Optional)- Use the raw parametric blendshapes of the modelout_dir (Optional[str])- Path of directory to save outputs in
for more optional arguments please visitsemantify/applications/sliders_demo_py3d.py
Image-to-Shape
python semantify/applications/image2shape.py --images_paths <IMAGES_PATHS> --model_type <TYPE> --specific <SPECIFIC> --output_path <PATH>
Arguments Description
images_paths (List[str])- Paths to the images you wish to run the demo onmodel_type (str)- "smplx" | "smpl" | "flame" | "smal"specific (str)- "male" | "female" | "neutral" | "expression" | "shape"mapper_path (Optional[str])- If you don't want to use Semantify's mappers, set the path to desired ckpt file
Dataset Creation
-
Create Data
python semantify/data_management/creation/create_data.py --output_path <PATH> --model_type <TYPE> --specific <SPECIFIC> --use_tex --multiview --num_of_imgs <NUM>This script will create as many images as you like, by randomly sample the parametric space of the given 3DMM. The output for a single sample will be a
.pngfile and.jsonfile that contains the sampled shape coefficients.
Arguments Description:output_path (str)- Path to a folder to store the datause_tex- Use models textures (if any) - HIGHLY RECOMMENDEDmultiview- Render the model from both frontal and side views instead of frontal onlynum_of_imgs (int)- How many images to create
-
Generate CLIP's Ratings
python semantify/data_management/creation/clip_encoder.py --imgs_dir <PATH> --model_type <TYPE> --specific <SPECIFIC> --multiviewThis script will run over the directory of images provided as input, along with a set of word descriptors and generate CLIP's ratings for each image against all descriptors. The output for a single sample will be a
.jsonfile that contains the ratings for each descriptor.
Arguments Description:imgs_dir (str)- Path to the directory of created images from phase (1).descriptors (List[str])- List of descriptors to use. We supply a default set, so this field is optional.
Train from Scratch
First in semantify/config/train_mapper.yaml fill the following fields:
output_path- Where to store the mapperrun_name- Name the rundataset.datadir- Path to the data directorydataset.optimize_feature- betas (SMPLX | SMPL) / beta (SMPL) / expression_params (FLAME) / shape_params (FLAME)dataset.labels_to_get- On which descriptors to optimize
These are MUST arguments to fill in order to train the mapper, in the.yamlfile you will find more configuration options.
Then, to train the mapper run:
python semantify/train/train_mapper.py
Citation
If you make use of our work, please cite our paper:
@InProceedings{Gralnik_2023_ICCV,
author = {Gralnik, Omer and Gafni, Guy and Shamir, Ariel},
title = {Semantify: Simplifying the Control of 3D Morphable Models Using CLIP},
booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
month = {October},
year = {2023},
pages = {14554-14564}
}
License
The Semantify codebase is released under the MIT License.
Third-party code
The following files included in this repository are from third-party sources and retain their original licenses:
| File | Source | License |
|---|---|---|
semantify/assets/flame/flame.py | soubhiksanyal/FLAME_PyTorch | MIT |
semantify/assets/smal/smal_layer.py | silviazuffi/smalst | MIT |
semantify/assets/spin/spin_model.py | nkolot/SPIN | BSD 3-Clause |
Third-party model weights
The 3D morphable model weights used by Semantify are not included in this repository and are subject to their own separate licenses. You must register and agree to each model's terms before downloading:
- FLAME โ flame.is.tue.mpg.de
- SMPL โ smpl.is.tue.mpg.de
- SMPL-X โ smpl-x.is.tue.mpg.de
- SMAL โ smal.is.tue.mpg.de