Code Monkey home page Code Monkey logo

3d_face_class's Introduction

3D Face Classification with Graph Neural Networks

In this project I built a simple Graph Neural Network model to attack the problem of 3D data classification. The datasets employed in this project are graph-representations of triangular meshes of facial data, obtained with structured-light based 3D system.

Repository structure

The repository is structured as following:

  • config.py : Python dictionary containing the hyperparameters for the training procedure.
  • data.py: Input data pipeline (loading, pre-processing, ...)
  • main.py: Script that handles the training phase
  • models.py: Contains the code for a few GNN models
  • test.py: Script that handles the testing phase
  • graph_data/: Directory containing the datasets
  • runs/: Directory containing the experiments

The data

I cannot share my data but, if you want to build a new dataset, follow this procedure: assuming that you have a set of 3D meshes in .obj format you have to group them by class into their relative sub-directories. Let' say you have a dataset like this:

./data/my_dataset/

where every subdirectory of my_dataset/ represents an identity, which contains a number of meshes, e.g.

./data/my_dataset/id000/id000_0.obj
./data/my_dataset/id000/id000_1.obj
...

You just have to run ./data/to_graph.py and a new directory will be created under ./graph_data/, containing the freshly build dataset of graphs derived by their relative meshes.

This is an example of the data I've dealt with

The model

You can look at my slides to gain insights about the (simple) model(s) I've coded.

Running a new experiment

Once you're set up with the data you just have to set your hyperparameters under ./config.py and run python main.py.

A Tensorboard log containing the hyperparameters, learning curves and histograms will be logged under ./runs/

Every 100 epochs both the model state and optimizer state dictionaries will be saved inside the same sub-directory.

Testing a model

If you want to test a model you just need to pass the relative ./runs/ sub-directory to the ./test.py script. Let's say you want to test the model logged under ./runs/exp_000/, then you just need to run

python test.py --exp_dir ./runs/exp000

Dependencies

Running

conda env create -f torchgeom.yml

will create an environment containing all the packages needed for this project (CUDA 10.2, cudnn 7.6).

The main dependencies are

python 3.7.7
torch 1.5.1
torch_geometric 1.6.0
tensorboard 2.2.2
scipy 1.5.1
numpy 1.18.5
scikit-learn 0.23.1
trimesh 3.8.8
tqdm 4.47.0

3d_face_class's People

Contributors

w00zie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

3d_face_class's Issues

unable to run your 3d_face_class on the RPi 4B platform.

First of all, thanks to share your great project.
but it's unable to run on my RaspiBerry 4B with the errors as below with the command:
$ python test.py --exp_dir ./runs/bosphorus

Testing ./runs/bosphorus/

Traceback (most recent call last):
File "/home/pi/src/ai/3d_face_class/test.py", line 39, in
train_list, test_list = get_train_test_split(config=config,
File "/home/pi/src/ai/3d_face_class/data.py", line 198, in get_train_test_split
train_list = _build_data_list(config, data_dir, train_ids, classes_dict)
File "/home/pi/src/ai/3d_face_class/data.py", line 211, in _build_data_list
e = np.load(e_fname)
File "/home/pi/.local/lib/python3.9/site-packages/numpy/lib/npyio.py", line 407, in load
fid = stack.enter_context(open(os_fspath(file), "rb"))
FileNotFoundError: [Errno 2] No such file or directory: 'graph_data/bosphorus_full/bs009/edges_bs009_LFAU_17_0.npy'

By the way, the test commands unable to find in your projects, such as there is not /runs//exp000 but runs/bosphorus & runs/frgc

Thanks & Best Regards
Sui

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.