From 4049dd647590050ed533df7ecef1d86e6ec5bbcb Mon Sep 17 00:00:00 2001 From: Gustavo Alberto <83519205+gustavo-alberto@users.noreply.github.com> Date: Thu, 19 Dec 2024 08:39:01 -0300 Subject: [PATCH 1/4] chore: add requirements.txt for dependency management This commit adds a requirements.txt file with specific package versions to ensure compatibility and correct installation of dependencies. The project hasn't been updated since 2020, so these versions are locked to maintain stability and avoid potential issues with newer releases of the packages. --- requirements.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c93cfbf --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +setuptools==61.0.0 +numpy==1.19.4 +cmake==3.18.4 +openmesh==1.1.6 From 4b3a7c0552238d4eec1698b19023334cef4390ae Mon Sep 17 00:00:00 2001 From: Gustavo Alberto <83519205+gustavo-alberto@users.noreply.github.com> Date: Thu, 19 Dec 2024 08:40:01 -0300 Subject: [PATCH 2/4] chore: add Dockerfile for containerizing the application This commit introduces a `Dockerfile` to containerize the application, making it easier to deploy and run in consistent environments. This will help standardize the development and production setup, ensuring the application works seamlessly across different machines. --- Dockerfile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..448c814 --- /dev/null +++ b/Dockerfile @@ -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"] From 89c78f326dc054a206b5993d7970a1bf84206386 Mon Sep 17 00:00:00 2001 From: Gustavo Alberto <83519205+gustavo-alberto@users.noreply.github.com> Date: Thu, 19 Dec 2024 08:41:47 -0300 Subject: [PATCH 3/4] fix: update path references in Python scripts for Docker compatibility This commit updates the path references in Python scripts to ensure compatibility with the new Docker structure. The changes were made to correctly resolve file paths when the application is containerized, preventing errors related to file access in the Docker environment. --- Scripts/read_identity.py | 6 +++--- Scripts/sample_random.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Scripts/read_identity.py b/Scripts/read_identity.py index 2514c8c..d83c671 100644 --- a/Scripts/read_identity.py +++ b/Scripts/read_identity.py @@ -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() diff --git a/Scripts/sample_random.py b/Scripts/sample_random.py index c35def7..156821f 100644 --- a/Scripts/sample_random.py +++ b/Scripts/sample_random.py @@ -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): @@ -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.") From 7ba941483a2796fdb2ef5d90e9a0eac2f78d63b9 Mon Sep 17 00:00:00 2001 From: Gustavo Alberto <83519205+gustavo-alberto@users.noreply.github.com> Date: Thu, 19 Dec 2024 08:51:11 -0300 Subject: [PATCH 4/4] docs: update README.md with Docker usage instructions --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index f2c28d2..b939202 100644 --- a/README.md +++ b/README.md @@ -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