Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using im2rec in MXnet to create dataset with png images

I am trying to follow the example here and create my own dataset for training using MXnet. My data is organized as specified in the example:

/data
    yes/
        file1.png
        file2.png
        ...
    no/
        file1.png
        file2.png
        ...

The tutorial says the first step is to run im2rec.py to create a .lst file, then run im2rec.py again (different options) to create the .rec file. To create the .lst file I type:

> python tools/im2rec.py my_data /data --list True --recursive True --train-ratio .75 --exts .png

After doing this, two files are created (as expected), my_data_train.lst and my_data_val.lst. The total number of lines in the two files is the same as the number of files in my yes/ and no/ directory combined. Then, I attempt to run im2rec a second time to create the .rec file using:

> python tools/im2rec.py my_data /data --resize 227 --num-thread 16

This runs for a few seconds and then (silently) crashes. In the process it creates 4 empty files: my_data_train.idx, my_data_train.rec, my_data_val.idx, and my_data_val.rec.

Question: What do I need to do differently to be able to create a proper .rec file containing my own .png images?

Extra Details:

I am working inside a docker container (mxnet/python:gpu) provided by dmlc on docker hub; they also provided the example on their github page. The data is available through a shared directory in the container. So it is presumably possible that this is a docker issue. What makes me slightly worried that it is a docker issue is that I had to pip install opencv-python in order for im2rec to be able to import cv2... I would have hoped that the people providing the container would have taken care of this.

like image 227
TravisJ Avatar asked Nov 07 '22 23:11

TravisJ


1 Answers

You are right that the image is missing opencv for python. Instead of installing via pip, please do apt-get install python-opencv.

PR posted here: Using im2rec in MXnet to create dataset with png images

like image 142
lynguyen Avatar answered Nov 15 '22 07:11

lynguyen