MOnocular Depth Estimation and SegmenTation (MODEST) Museum Dataset

Link to Dataset: https://www.kaggle.com/shanwizard/modest-museum-dataset

Directory Structure

The dataset comprises seven parts, which are stored inside the root directory.

*(d): Directory, (f): File

dataset
    ├── bg
    |   ├── bg001.jpeg
    |   ├── bg002.jpeg
    |   ├── ...
    |   ├── bg100.jpeg
    ├── fg
    |   ├── fg001.png
    |   ├── fg002.png
    |   ├── ...
    |   └── fg100.png
    ├── fg_mask
    |   ├── fg001_mask.png
    |   ├── fg002_mask.png
    |   ├── ...
    |   └── fg100_mask.png
    ├── bg_fg
    |   ├── bg001_fg001_01.jpeg
    |   ├── bg001_fg001_02.jpeg
    |   ├── ...
    |   └── bg100_fg100_40.jpeg
    ├── bg_fg_mask
    |   ├── bg001_fg001_01_mask.jpeg
    |   ├── bg001_fg001_02_mask.jpeg
    |   ├── ...
    |   └── bg100_fg100_40_mask.jpeg
    ├── bg_fg_depth_map
    |   ├── bg001_fg001_01_depth_map.jpeg
    |   ├── bg001_fg001_02_depth_map.jpeg
    |   ├── ...
    |   └── bg100_fg100_40_depth_map.jpeg
    ├── file_map.txt
    └── bbox.txt

Content Description

bg

This directory contains images of museum interiors. These are called background images.

backgrounds

fg

This directory contains images of humans with transparent background. These are called foreground images.

foregrounds

fg_mask

This directory contains mask of foregrounds. These are called foreground masks.

foreground masks

bg_fg

This directory contains images where foregrounds are overlayed on backgrounds. These are called background-foreground images.

background-foreground

bg_fg_mask

This directory contains mask of background-foreground images. These are called background-foreground masks.

background-foreground masks

bg_fg_depth_map

This directory contains depth map of background-foreground images. These are called background-foreground depth maps.

background-foreground depth maps

file_map.txt

This file contains the mapping between images across different parts of the dataset.

To see an overview of the contents of the file, go here.

bbox.txt

This file contains the bounding box (bbox) top-left coordinate and bbox size of the foreground in each background image.

To see an overview of the contents of the file, go here.

Statistics

Open In Colab

Dataset Creation

Open In Colab

The dataset was created as follows

Download background and foreground images

Resizing backgrounds

All the background images are resized into a fixed size of 704x704. This is done for the following reasons

Reason for choosing initial background size of 704x704:
This shape was chosen because during our trials we found that this was the minimum shape at which DenseDepth gave very accurate depth maps.
Later, after all the images and depth maps are created, all the images will be resized to a size of 224x224.

Sample background images

bg

Background removal from foregrounds

All the downloaded foreground images should have a transparent background in order to overlay them on top of background images.

For removing backgrounds, the open-source software GIMP - GNU Image Manipulation Program can be used. Steps for removing background using GIMP has been shown below:

background_removal_with_gimp

Images are exported as PNG because it allows the image to have a transparent background.

Sample foreground images

fg

Mask creation for foregrounds

Concept of alpha channel

Creating mask

Sample foreground masks

fg_mask

Resizing foregrounds

All the foreground images are resized to have a fixed height of 340.
Since the background image is of fixed dimension 704x704, the foreground that has to be overlayed on top of it should be in proportion. Also in order to maintain the aspect ratio of the foreground, we find the corresponding width with respect to a height of 340 and then resize it to (340, new_width).

Reason for choosing foreground height as 340:
After many attempts of overlaying different foregrounds on different backgrounds, we found 340 to be the most optimum height for the foregrounds with respect to the background size of 704x704.

Overlaying foregrounds on backgrounds

Foregrounds are overlayed on backgrounds to create background-foreground images. A corresponding mask of background-foreground image will also be created.

Creating a single image and its mask

  1. Find a random location (x,y) on the background image. Make sure that x ranges between [0, background_height-foreground_height] and y ranges between [0, background_width-foreground_width]. This ensures that foreground is always completely inside the background.
  2. Place the foreground image on top of the background image with (x,y) as the top left corner. This will be the background-foreground image.
  3. Calculate the bounding box values for this image
    • Current image size is 704x704 and the final image size will be 224x224, so the bounding box values will be calculated with respect to the final image size
    • Calculate the scale ratio = 224 / 704
    • Multiply the x, y, foreground width and height values with the scale ratio to obtain the bounding box values
  4. Place the mask of the foreground on a black image that has same shape as that of the background at (x,y) as the top left corner. This will be the mask for the background-foreground image.
  5. Since the mask is in grayscale, the number of channels in these images is reduced to 1 to save storage space.

Dataset Creation

Now for each background-foreground pair:

Images created in this step

Each of background-foreground, background-foreground mask and background-foreground depth map will have 400,000 images.

Thus, total number of images in the dataset is 1,200,000.

Sample background-foreground images

bg_fg

Sample background-foreground masks

bg_fg_mask

Depth map

To create the monocular depth estimation map of the background-foreground images, we use pretrained DenseNet-201. Implementation for the model inference was referenced from this repository.

Since the depth maps are in grayscale, the number of channels for these images is reduced to 1 to save storage space.

Note: Since we don’t have a DepthCam, we rely on a pretrained DenseNet-201 model to generate depth maps.

Sample background-foreground depth maps

bg_fg_depth_map

Final resize of the dataset

Since the dimension 704x704 is quite big and it will take huge amount of time to train so we resize the entire dataset which consists of background images, background-foreground images, background-foreground mask and background-foreground depth maps to 224x224 which is big enough to get a good accuracy as well as train faster.

The background images have been resized by a factor of 3.1428 (704 / 224), so the foreground images would have to be resized as well. The new size of foreground images becomes 108 (340 / 3.1428).

Dump file relations

The relationships between various parts of the dataset are dumped in a file named file_map.txt. The contents of the file are as follows:

bg001 bg001_fg001_01  bg001_fg001_01_mask bg001_fg001_01_depth_map
bg001 bg001_fg001_02  bg001_fg001_02_mask bg001_fg001_02_depth_map
...
bg029 bg029_fg010_18  bg029_fg010_18_mask bg029_fg010_18_depth_map
...
bg100 bg100_fg100_40  bg100_fg100_40_mask bg100_fg100_40_depth_map

Dump bounding box data

The bounding box data for each background-foreground image is dumped in a file named bbox.txt. The contents of the file are as follows:

bg001_fg001_01.jpeg     123     113     35      108
bg001_fg001_02.jpeg     101     81      35      108
...
bg050_fg084_17.jpeg     90      70      39      108
...

The steps for calculation of bounding box for each image is described in this section.

Contributors