Skip to content

Commit

Permalink
Code release.
Browse files Browse the repository at this point in the history
  • Loading branch information
guipotje committed Dec 11, 2024
1 parent 04b9d5b commit 40cd451
Show file tree
Hide file tree
Showing 33 changed files with 5,824 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Base image
FROM tensorflow/tensorflow:1.15.5-py3

# Install necessary dependencies
RUN apt-get update && apt-get install -y \
cmake \
pkg-config \
wget \
unzip && \
rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /src

#Install OpenCV 3.4.8
RUN wget "https://github.com/opencv/opencv/archive/3.4.8.zip" && \
unzip 3.4.8.zip && \
mkdir -p opencv-3.4.8/build && \
cd opencv-3.4.8/build && \
cmake -DCMAKE_BUILD_TYPE=Release \
-DBUILD_LIST=core,highgui,imgproc,features2d .. && \
make -j$(nproc) && \
make install


# Download and extract SimulationICCV.tar.gz
RUN wget "https://www.verlab.dcc.ufmg.br/nonrigid/SimulationICCV.tar.gz" && \
tar -xvf SimulationICCV.tar.gz

RUN pip3 install opencv-python-headless==3.4.3.18 scipy --prefer-binary

# Copy geopatch source from the current directory into the container
COPY . /src

# Build geopatch-forge/geopatch
RUN cd /src/geopatch && \
mkdir -p build && cd build && \
cmake .. && make -j$(nproc)

# Clean up temporary files to reduce image size
RUN rm -rf /src/opencv-3.4.8 /src/3.4.8.zip /src/SimulationICCV.tar.gz

# Default command
CMD ["/bin/bash"]

93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)


# GeoPatch Descriptor

This repository contains the original implementation of the descriptor "<b>Learning Geodesic-Aware Local Features from RGB-D Images</b>", published at Computer Vision and Image Understanding journal. GeoPatch is by design invariant to isometric non-rigid deformations of surfaces by leveraging geodesic-invariant sampling, designed as a mapping function before descriptor computation is performed from photometric information.


## <b>Learning Geodesic-Aware Local Features from RGB-D Images</b> <br>[[Project Page]](https://www.verlab.dcc.ufmg.br/descriptors/cviu2022/) [[Paper]](https://arxiv.org/abs/2203.12016)

<img src='./images/teaser.jpg' align="center" width=900 />



## Ready to use Docker container

We recommend running the project with Docker, which requires a single command to build the entire project.

First, build the container:

```sh
docker compose build
```

Then, run the docker in interactive mode:

```sh
docker compose run --rm geopatch
```

Finally, you can run the provided demo, which runs both geodesic patch extraction and local feature computation:

```sh
sh run_demo.sh
```

Notice that the output files are being saved inside the container.

## Ready to use Singularity container

Alternatively we also provide a singularity recipe so you can easily and smoothly build the project.

First, build the container:

```sh
sudo singularity build geopatch.sif Singularity.geopatch
```

Then, run the container in interactive mode:

```sh
singularity shell --writable-tmpfs --pwd /src geopatch.sif
```

Finally, you can run the provided demo, which runs both geodesic patch extraction and local feature computation:

```sh
sh run_demo.sh
```

Notice that the output files are being saved inside the container.

## Datasets

All available datasets and ground-truth files are available for download at [https://verlab.dcc.ufmg.br/descriptors](https://verlab.dcc.ufmg.br/descriptors)


## Non-Rigid Simulator

The code for the non-rigid simulator used in our work is available in the [`nonrigid_sim`](nonrigid_sim/) folder. For detailed instructions on usage, please refer to the [`README.md`](nonrigid_sim/README.md) inside the folder.


## Published works

If you find this code useful for your research, please cite the paper:

```
@article{potje2022learning,
title={Learning geodesic-aware local features from RGB-D images},
author={Potje, Guilherme and Martins, Renato and Cadar, Felipe and Nascimento, Erickson R},
journal={Computer Vision and Image Understanding},
volume={219},
pages={103409},
year={2022},
publisher={Elsevier}
}
```

**VeRLab:** Laboratory of Computer Vison and Robotics https://www.verlab.dcc.ufmg.br
<br>
<img align="left" width="auto" height="50" src="./images/ufmg.png">
<img align="right" width="auto" height="50" src="./images/verlab.png">
<br/>
45 changes: 45 additions & 0 deletions Singularity.geopatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Bootstrap: docker
From: tensorflow/tensorflow:1.15.5-py3

%files
. /src

%post
# Install necessary dependencies
apt-get update && apt-get install -y \
cmake \
pkg-config \
wget \
unzip && \
rm -rf /var/lib/apt/lists/*

# Set working directory
cd /src

# Install OpenCV 3.4.8
wget "https://github.com/opencv/opencv/archive/3.4.8.zip" && \
unzip 3.4.8.zip && \
mkdir -p opencv-3.4.8/build && \
cd opencv-3.4.8/build && \
cmake -DCMAKE_BUILD_TYPE=Release \
-DBUILD_LIST=core,highgui,imgproc,features2d .. && \
make -j$(nproc) && \
make install

# Download and extract SimulationICCV.tar.gz
cd /src
wget "https://www.verlab.dcc.ufmg.br/nonrigid/SimulationICCV.tar.gz" && \
tar -xvf SimulationICCV.tar.gz

# Install Python dependencies
pip3 install opencv-python-headless==3.4.3.18 scipy --prefer-binary

# Build geopatch
cd /src/geopatch
mkdir -p build && cd build
cmake .. && make -j$(nproc)

# Clean up temporary files
rm -rf /src/opencv-3.4.8 /src/3.4.8.zip /src/SimulationICCV.tar.gz

chmod -R 777 /src
61 changes: 61 additions & 0 deletions architecture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#% This file is part of https://github.com/verlab/GeoPatch_CVIU_2022
#
# geopatch-descriptor is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# geopatch-descriptor is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with geopatch-descriptor. If not, see <http://www.gnu.org/licenses/>.
#%
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

from __future__ import absolute_import
from __future__ import print_function
import numpy as np
import cv2
import math

from tensorflow.keras.utils import plot_model
from tensorflow.keras.models import Model
from tensorflow.keras import backend as K
from tensorflow.keras.models import model_from_json

import os
###############################################################
#Configure Session for Memory Limit on TensorFlow using Keras
# session config
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
tf.keras.backend.set_session(tf.Session(config=config))
###############################################################

pretrained_path = os.path.dirname(os.path.realpath(__file__)) +'/weights'

class TinyDesc(object):
model = None
PATCH_SIZE = 32

def __init__(self, model_name):
# load json and create model
json_file = open(pretrained_path + '/' + model_name + '.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)
# load weights into new model
loaded_model.load_weights(pretrained_path + '/' + model_name + '.h5')

print("Loaded model from disk")

# evaluate loaded model on test data
#loaded_model.compile(loss='mean_squared_error', optimizer='rmsprop', metrics=['accuracy'])

self.model = loaded_model
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3.8'

services:
geopatch:
image: geopatch-1.0
build: .
container_name: geopatch_container
stdin_open: true
tty: true

Loading

0 comments on commit 40cd451

Please sign in to comment.