Home

Awesome

<h1 align="center">Semantify:<br>Simplifying the Control of 3D Morphable Models using CLIP<br>ICCV 2023</h1> <h2 align="center"><p> <a href="https://Omergral.github.io/Semantify" align="center">🖥️ Project Page</a> | <a href="https://arxiv.org/abs/2308.07415" align="center">📄 Paper</a> </p></h2> <p align="center"> <img src="https://github.com/Omergral/Semantify/blob/master/static/images/semantify_teaser-bg.png" alt="example" width=80%> <br> <em>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).</em> </p>

Installation

  1. Clone the repo:
git clone https://github.com/Omergral/Semantify.git
cd Semantify 
  1. Create new conda environment:
conda env create -f requirements.yml
conda activate semantify
pip install -e .

Download Models

Semantify Mappers

3D Morphable Models

Pose Estimation

Run Demos

Sliders Application

python semantify/applications/sliders_demo_py3d.py --model_type <MODELTYPE> --specific <SPECIFIC>

<ins>Arguments Description:</ins>

<p align="center"> <img src="https://github.com/Omergral/Semantify/blob/master/static/images/semantify_smplx_male_app.gif" alt="example" width=50%> </p>

Image-to-Shape

python semantify/applications/image2shape.py --images_paths <IMAGES_PATHS> --model_type <TYPE> --specific <SPECIFIC> --output_path <PATH>

<ins>Arguments Description</ins>

Dataset Creation

  1. 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 .png file and .json file that contains the sampled shape coefficients.<br><br> <ins>Arguments Description:</ins>

    • output_path (str) - Path to a folder to store the data
    • use_tex - Use models textures (if any) - HIGHLY RECOMMENDED
    • multiview - Render the model from both frontal and side views instead of frontal only
    • num_of_imgs (int) - How many images to create
  2. Generate CLIP's Ratings

    python semantify/data_management/creation/clip_encoder.py --imgs_dir <PATH> --model_type <TYPE> --specific <SPECIFIC> --multiview
    

    This 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 .json file that contains the ratings for each descriptor.<br><br> <ins>Arguments Description:</ins><br>

    • 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.<br><br>

Train from Scratch

First in semantify/config/train_mapper.yaml fill the following fields:

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}
}