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"] 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 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.") 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