Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker Support and Fix Dependencies for Compatibility #26

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Base image
FROM python:3.8-slim

# Update the system and install required dependencies for CMake and compilation
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
gcc \
g++ \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Set the working directory inside the container
WORKDIR /app

# Copy the Python dependency file into the container
COPY requirements.txt /app/

# Set up a virtual environment, upgrade pip, and install dependencies
RUN python -m venv /app/venv && \
/app/venv/bin/pip install --no-cache-dir --upgrade pip && \
/app/venv/bin/pip install --no-cache-dir -r /app/requirements.txt

# Copy all project files to the working directory
COPY . /app/

# Create a persistent volume for storing output data
VOLUME ["/app/sample_data_out"]

# Define the default command to run when the container starts
CMD ["/bin/bash", "-c", ". /app/venv/bin/activate \
&& python Scripts/sample_random.py \
&& python Scripts/read_identity.py"]
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,32 @@ Run example scripts:

Outputs will be written in `/sample_data_out`

## Running with Docker

### Build the Docker image

To build the Docker image, run the following command (make sure you're located at the root of the project):

```bash
docker build -t ict-facekit .
```

### Run the Docker container

To run the container, use the following command:

```bash
docker run -it --rm --name ict-facekit-container -v "$(pwd)/sample_data_out:/app/sample_data_out" ict-facekit
```

In this command:

- The container is run in interactive mode (`-it`), allowing you to see the output of the scripts.
- The `--rm` flag ensures the container is removed after it exits.
- The volume mapping `-v "$(pwd)/sample_data_out:/app/sample_data_out"` saves the output of the example scripts in a directory on the host machine (`sample_data_out`), outside of the container.

The two example scripts will be executed, and the results will be saved in the host machine's volume.

## Publications

### Learning Formation of Physically Based Face Attributes
Expand Down
6 changes: 3 additions & 3 deletions Scripts/read_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ def main():
"""Reads an ICT FaceModel .json file and writes its mesh.
"""
# Create a new FaceModel and load the model
id_coeffs, ex_coeffs = face_model_io.read_coefficients('../sample_data/sample_identity_coeffs.json')
face_model = face_model_io.load_face_model('../FaceXModel')
id_coeffs, ex_coeffs = face_model_io.read_coefficients('sample_data/sample_identity_coeffs.json')
face_model = face_model_io.load_face_model('FaceXModel')
face_model.from_coefficients(id_coeffs, ex_coeffs)

# Deform the mesh
face_model.deform_mesh()

# Write the deformed mesh
face_model_io.write_deformed_mesh('../sample_data_out/sample_identity.obj', face_model)
face_model_io.write_deformed_mesh('sample_data_out/sample_identity.obj', face_model)

if __name__ == '__main__':
main()
4 changes: 2 additions & 2 deletions Scripts/sample_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def main():
"""Loads the ICT Face Mode and samples and writes 10 random identities.
"""
# Create a new FaceModel and load the model
face_model = face_model_io.load_face_model('../FaceXModel')
face_model = face_model_io.load_face_model('FaceXModel')

print("Writing 10 random identities...")
for i in range(10):
Expand All @@ -42,7 +42,7 @@ def main():
face_model.deform_mesh()

# Write the deformed mesh
write_path = '../sample_data_out/random_identity{:02d}.obj'.format(i)
write_path = 'sample_data_out/random_identity{:02d}.obj'.format(i)
face_model_io.write_deformed_mesh(write_path, face_model)

print("Finished writing meshes.")
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
setuptools==61.0.0
numpy==1.19.4
cmake==3.18.4
openmesh==1.1.6