Code Monkey home page Code Monkey logo

tiny's Introduction

Demo result

Finding Tiny Faces

By Peiyun Hu and Deva Ramanan at Carnegie Mellon University.

Introduction

We develop a face detector (Tiny Face Detector) that can find ~800 faces out of ~1000 reportedly present, by making use of novel characterization of scale, resolution, and context to find small objects. Can you confidently identify errors?

Tiny Face Detector was initially described in an arXiv tech report.

In this repo, we provide a MATLAB implementation of Tiny face detector, including both training and testing code. A demo script is also provided.

Citing us

If you find our work useful in your research, please consider citing:

@InProceedings{Hu_2017_CVPR,
  author = {Hu, Peiyun and Ramanan, Deva},
  title = {Finding Tiny Faces},
  booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
  month = {July},
  year = {2017}
}

Installation

Clone the repo recursively so you have my fork of MatConvNet.

git clone --recursive [email protected]:peiyunh/tiny.git

Compile MatConvNet by running following commands in MATLAB (see Installing - MatConvNet for more details):

>> cd matconvnet/;
>> addpath matlab/; 
>> vl_compilenn('enableImreadJpeg', true, 'enableGpu', true, 'cudaRoot', [cuda_dir],...
                'cudaMethod', 'nvcc', 'enableCudnn', true, 'cudnnRoot', [cudnn_dir]);
>> vl_testnn('gpu', true);  % vl_testnn('gpu', false) for cpu-only 

Compile our MEX function in MATLAB and test if it works as expected:

>> cd utils/;
>> compile_mex;
>> test_compute_dense_overlap;

Download WIDER FACE and unzip data and annotation files to data/widerface such that:

$ ls data/widerface
wider_face_test.mat   wider_face_train.mat    wider_face_val.mat
WIDER_test/           WIDER_train/            WIDER_val/

Demo

We provide a minimal demo tiny_face_detector.m that runs our detector on an single input image and output face detections:

function bboxes = tiny_face_detector(image_path, output_path, prob_thresh, nms_thresh, gpu_id)

Here is a command you can run to reproduce our detection results on the world's largest selfie:

>> bboxes = tiny_face_detector('data/demo/selfie.jpg', './selfie.png', 0.5, 0.1, 1)

The demo script will start by downloading an off-the-shelf ResNet101-based model, if it does not find one. Models based on other architecture are also available below:

Training

To train a ResNet101-based Tiny Face Detector, run following command in MATLAB:

>> hr_res101('train');           % which calls cnn_widerface.m

After training, run the following command to test on the validation set:

>> hr_res101('test');            % which calls cnn_widerface_test_AB.m 

Finally, run the following command to evaluate the trained models:

>> hr_res101('eval');            % which calls cnn_widerface_eval.m

Please refer to scripts/hr_res101.m for more details on how training/testing/evaluation is configured.

Clustering

We derive canonical bounding box shapes by K-medoids clustering (cluster_rects.m). For reproducibility, we provide our clustering results in data/widerface/RefBox_N25.mat. We also provide the version after template resolution analysis in data/widerface/RefBox_N25_scaled.mat (Fig. 8 in our paper).

Evaluation

We provide both our own version of evaluation script (cnn_widerface_eval.m) and official evaluation script (eval_tools/). Our implementation runs much faster and is easier to customize. However, our version produces slightly lower numbers comparing to the official one. We use our evaluation script only for prototyping. All numbers in the paper are based on the official evaluation script.

FAQ

How do I train it on my own datasets?

Training a tiny-X-detector on your own dataset takes just a little bit of coding and it is certainly doable. I would suggest start from the script named cnn_setup_imdb.m. The script produces a imdb.mat file which contains information about the path of images and the ground truth bounding boxes. Try modifying cnn_setup_imdb.m to make sure such information of your dataset goes into imdb.mat.

Third-party re-implementations

tiny's People

Contributors

ifreilicht avatar peiyunh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tiny's Issues

"RefBox_N25.mat"

I am sorry, I want to know where can find script about generated "RefBox_N25.mat, RefBox_N25_scaled.mat, imageStats.mat, imdb.mat" files in your code.

About Templates

Hello @peiyunh
I read your paper regarding this work. But I didn't get the template extraction(
We explore
multi-scale features extracted from the last layer of each
res-block, i.e. (res2cx, res3dx, res4fx, res5cx) in terms of
ResNet-50
-- in your paper
). Which part of the network contains template? Do you mean templates are nothing but the last layer of res2, res3, res4, res5? And what does cluster do(in the code net.meta.clusters) ?
And What is the significance of scale convolution in that above network?
Looking for your answer.

Problem when running tiny_face_detector.m

Hi,
Thanks for your sharing. But I met a problem when running the demo.
I have compiled mex and matconvnet successfully, but when I ran tiny_face_detector.m, there is a problem as follow:
`Undefined function or variable 'nms_mex'.

Error in nms (line 43)
pick = nms_mex(double(boxes), double(overlap));

Error in tiny_face_detector (line 172)
ridx = nms(bboxes(:,[1:4 end]), nms_thresh);`

How could I solve this problem?

About the function 'nms_mex'

Hello Peiyunh,
I am using your code in matlab r2014a. I have encountered the stated issues and rectified them. After that, I have faced a new issue which I can't fixed even though searching online.
When running this -- bboxes = tiny_face_detector('data/demo/selfie.jpg', './selfie.png', 0.5, 0.1, 1)
I found the following error

Loading pretrained detector model...
Processing data/demo/selfie.jpg at scale 0.031250.
Error using vl_nnconv
An input is not a numeric array (or GPU support not
compiled).

Error in dagnn.Conv/forward (line 11)
      outputs{1} = vl_nnconv(...

Error in dagnn.Layer/forwardAdvanced (line 85)
      outputs = obj.forward(inputs,
      {net.params(par).value}) ;

Error in dagnn.DagNN/eval (line 91)
  obj.layers(l).block.forwardAdvanced(obj.layers(l)) ;

Error in tiny_face_detector (line 130)
  net.eval(inputs);

As I am using CPU version of matconvnet so I changed gpu = 0
as -- bboxes = tiny_face_detector('data/demo/selfie.jpg', './selfie.png', 0.5, 0.1, 0)
The error is

Loading pretrained detector model...
Processing data/demo/selfie.jpg at scale 0.031250.
Processing data/demo/selfie.jpg at scale 0.062500.
Processing data/demo/selfie.jpg at scale 0.125000.
Processing data/demo/selfie.jpg at scale 0.250000.
Processing data/demo/selfie.jpg at scale 0.500000.
Processing data/demo/selfie.jpg at scale 1.000000.
Processing data/demo/selfie.jpg at scale 1.414214.
Processing data/demo/selfie.jpg at scale 2.000000.
Undefined function 'nms_mex' for input arguments of type
'double'.

Error in nms (line 43)
    pick = nms_mex(double(boxes), double(overlap));

Error in tiny_face_detector (line 172)
ridx = nms(bboxes(:,[1:4 end]), nms_thresh);

I am unable to fix this. Please answer my question.
Thank you.

CUDNN_STATUS_NOT_SUPPORTED when running example on GPU

Symptoms

Trying to run the provided example on the GPU leads to an error message from MatConvNet:

>> tiny_face_detector('data/demo/selfie.jpg', './selfie.png', 0.5, 0.1, 1);
Loading pretrained detector model...
Processing data/demo/selfie.jpg at scale 0.031250.
Error using vl_nnconv
forward: cuDNN error [cudnn:
"/home.net/ga82vac/deep-learning-for-face-and-people-detection/networks/tiny/matconvnet/matlab/src/bits/impl/nnconv_cudnn.cu":174
(CUDNN_STATUS_NOT_SUPPORTED)]

Error in dagnn.Conv/forward (line 18)
      outputs{1} = vl_nnconv(...

Error in dagnn.Layer/forwardAdvanced (line 85)
      outputs = obj.forward(inputs, {net.params(par).value}) ;

Error in dagnn.DagNN/eval (line 92)
  obj.layers(l).block.forwardAdvanced(obj.layers(l)) ;

Error in tiny_face_detector (line 126)
  net.eval(inputs);

Running the demo on the CPU as shown below works perfectly fine, but takes about a minute:

>> tiny_face_detector('data/demo/selfie.jpg', './selfie.png', 0.5, 0.1, 0);
[...]
Detection was finished in 49.513439 seconds

System Information

Hardware

➜  ~ nvidia-smi
Fri May  5 17:48:08 2017       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 361.93.02              Driver Version: 361.93.02                 |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX TIT...  On   | 0000:01:00.0     Off |                  N/A |
| 22%   30C    P8    31W / 250W |    236MiB / 12210MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0     26141    C   /usr/local/MATLAB/R2016a/bin/glnxa64/MATLAB    234MiB |
+-----------------------------------------------------------------------------+

Software

➜  ~ cat /usr/local/cuda/version.txt
CUDA Version 8.0.61
>> ver
----------------------------------------------------------------------------------------------------
MATLAB Version: 9.0.0.341360 (R2016a)
MATLAB License Number: [...]
Operating System: Linux 4.4.0-75-generic #96~14.04.1-Ubuntu SMP Thu Apr 20 11:06:30 UTC 2017 x86_64
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------

Debugging approaches

To debug, I inserted the line fprintf('l = %d\n', l); above dagnn.DagNN/eval (line 92). Re-running after that, the error message reads:

[...]
Processing data/demo/selfie.jpg at scale 0.031250.
l = 1
Error using vl_nnconv
[...]

So this fails on the first layer already. I also added the following lines above dagnn.Conv/forward (line 18) to capture the input argument the failing function vl_nnconv is receiving:

assignin('base', 'inputs', inputs{1})
assignin('base', 'params1', params{1})
assignin('base', 'params2', params{2})
assignin('base', 'pad', obj.pad)
assignin('base', 'stride', obj.stride)
assignin('base', 'dilate', obj.dilate)

And sure enough, using these captured values, the error can easily be reproduced:

>> vl_nnconv(inputs, params1, params2, 'pad', pad, 'stride', stride, 'dilate', dilate);

How to replicate

  1. Download the .mat file of the workspace(~103MB) I created as described above.
  2. Open Matlab and run the startup.m script
  3. Open the file from (1) in Matlab
  4. Run this command: >> vl_nnconv(inputs, params1, params2, 'pad', pad, 'stride', stride, 'dilate', dilate);

How to add layers of different scale

Thank you for your good job .
There is Res4+Res3+Res2 in your article . They are in different scale . How to add them together in your paper?

RUN demo has error

Loading pretrained detector model...
Processing data/demo/selfie.jpg at scale 0.031250.
Processing data/demo/selfie.jpg at scale 0.062500.
Processing data/demo/selfie.jpg at scale 0.125000.
Processing data/demo/selfie.jpg at scale 0.250000.
Processing data/demo/selfie.jpg at scale 0.500000.
Processing data/demo/selfie.jpg at scale 1.000000.
Processing data/demo/selfie.jpg at scale 1.414214.
Processing data/demo/selfie.jpg at scale 2.000000.
error use vl_nnbnorm
Out of memory on device. To view more detail about available memory on the GPU, use 'gpuDevice()'. If the problem persists,
reset the GPU by calling 'gpuDevice(1)'.

error use dagnn.BatchNorm/forward (line 15)
outputs{1} = vl_nnbnorm(inputs{1}, params{1}, params{2}, ...

error use dagnn.Layer/forwardAdvanced (line 85)
outputs = obj.forward(inputs, {net.params(par).value}) ;

error use dagnn.DagNN/eval (line 91)
obj.layers(l).block.forwardAdvanced(obj.layers(l)) ;

error use tiny_face_detector (line 130)
net.eval(inputs);

my gpu is 4g memory
gpuDevice(1)

ans =

CUDADevice:

                  Name: 'GeForce GTX 1050 Ti'
                 Index: 1
     ComputeCapability: '6.1'
        SupportsDouble: 1
         DriverVersion: 8
        ToolkitVersion: 5.5000
    MaxThreadsPerBlock: 1024
      MaxShmemPerBlock: 49152
    MaxThreadBlockSize: [1024 1024 64]
           MaxGridSize: [2.1475e+09 65535 65535]
             SIMDWidth: 32
           TotalMemory: 4.2950e+09
            FreeMemory: 3.5271e+09
   MultiprocessorCount: 6
          ClockRateKHz: 1392000
           ComputeMode: 'Default'
  GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
      CanMapHostMemory: 1
       DeviceSupported: 1
        DeviceSelected: 1

how can I deal with this error??

Do you have any idea how to solve the following error?

>> mex compute_dense_overlap.cc CXXFLAGS='$CXXFLAGS -fopenmp' ...
LDFLAGS='$LDFLAGS -fopenmp' CXXOPTIMFLAGS='-O3 -DNDEBUG' 
Building with 'g++'.
Error using mex
/home/yxchng/tiny/utils/compute_dense_overlap.cc: In function ‘void mexFunction(int, mxArray**,
int, const mxArray**)’:
/home/yxchng/tiny/utils/compute_dense_overlap.cc:70:77: error: cannot convert ‘const int*’ to
‘const size_t* {aka const long unsigned int*}’ for argument ‘2’ to ‘mxArray*
mxCreateNumericArray(size_t, const size_t*, mxClassID, mxComplexity)’
   mxArray *mx_overlap = mxCreateNumericArray(4, dims, mxDOUBLE_CLASS, mxREAL);
                                                                             ^
/home/yxchng/tiny/utils/compute_dense_overlap.cc:75:38: warning: narrowing conversion of
‘(((double)((int)vsy + -1) * ((double)zmy)) + 1.0e+0)’ from ‘double’ to ‘const int’ inside { }
[-Wnarrowing]
   const int tmp_dims[] = {(vsy-1)*zmy+1, (vsx-1)*zmx+1, nt};
                                      ^
/home/yxchng/tiny/utils/compute_dense_overlap.cc:75:53: warning: narrowing conversion of
‘(((double)((int)vsx + -1) * ((double)zmx)) + 1.0e+0)’ from ‘double’ to ‘const int’ inside { }
[-Wnarrowing]
   const int tmp_dims[] = {(vsy-1)*zmy+1, (vsx-1)*zmx+1, nt};
                                                     ^
/home/yxchng/tiny/utils/compute_dense_overlap.cc:76:85: error: cannot convert ‘const int*’ to
‘const size_t* {aka const long unsigned int*}’ for argument ‘2’ to ‘mxArray*
mxCreateNumericArray(size_t, const size_t*, mxClassID, mxComplexity)’
   mxArray *mx_tmp_overlap = mxCreateNumericArray(3, tmp_dims, mxDOUBLE_CLASS, mxREAL);
                                                                                  ^

Ask for training code ,and HR-VGG16

@peiyunh Hi, peiyun, I have ran your offered demo, the face detection results are very good. Now I have some questions :

  1. Can you share your model mentioned in the paper, e.g., HR-VGG16.
  2. The detect time? I try the HR-Res101 model, but it works very slowly.
  3. How to train model on my own dataset. Can you share the training code?
    Looking forward to your reply.

error when trying to run the demo selfe demo photo

Thank you very much for your sharing the code.
I tried to run the code but got the following error when trying to run the demo on worlds largest selfie:
Warning: Name is nonexistent or not a directory: toolbox\export_fig

In path (line 109)
In addpath (line 88)
In tiny_face_detector (line 45)
Loading pretrained detector model...
Processing data/demo/selfie.jpg at scale 0.031250.
Attempt to execute SCRIPT vl_nnconv as a function:
D:\MATLAB\tiny\matconvnet\matlab\vl_nnconv.m

Error in dagnn.Conv/forward (line 11)
outputs{1} = vl_nnconv(...

Error in dagnn.Layer/forwardAdvanced (line 85)
outputs = obj.forward(inputs, {net.params(par).value}) ;

Error in dagnn.DagNN/eval (line 91)
obj.layers(l).block.forwardAdvanced(obj.layers(l)) ;

Error in tiny_face_detector (line 130)
net.eval(inputs);
....

appreciating your feed back

Thank you.

hr_res101('train') error with ‘compute_dense_overlap.mexa64’

i met this problem-------------------------------
Invalid MEX-file '/home/vis/dukang/tiny/utils/compute_dense_overlap.mexa64': dlopen: cannot load any more object with static TLS.

And in this link, #22, @niamul070 met the same problem. We have not solved it till now. Maybe it is helpful to know the version of your matlab. We both use matlab r2016b, so what is your version?

Hope you can reply to me asap.
Best Regards.

the usage of clusters in the training

Hello Peiyun:

I found that the clusters in your demo as blow:

-86.3382 -113.4441 86.3382 113.4441 0.5000
-48.7500 -65.2500 48.7500 65.2500 0.5000
-33.2500 -43.7500 33.2500 43.7500 0.5000
-25.7500 -33.7500 25.7500 33.7500 0.5000
-40.5000 -54.5000 40.5000 54.5000 1.0000
-34.5000 -43.5000 34.5000 43.5000 1.0000
-28.5000 -38.0000 28.5000 38.0000 1.0000
-25.6589 -31.3221 25.6589 31.3221 1.0000
-21.6137 -27.5977 21.6137 27.5977 1.0000
-20.0000 -22.5000 20.0000 22.5000 1.0000
-17.5000 -25.5000 17.5000 25.5000 1.0000
-16.3280 -20.8856 16.3280 20.8856 1.0000
-29.4755 -34.4803 29.4755 34.4803 2.0000
-25.4202 -37.1061 25.4202 37.1061 2.0000
-24.2118 -30.2146 24.2118 30.2146 2.0000
-22.0129 -24.7059 22.0129 24.7059 2.0000
-19.3142 -28.0202 19.3142 28.0202 2.0000
-17.9677 -22.7849 17.9677 22.7849 2.0000
-15.6123 -19.5907 15.6123 19.5907 2.0000
-13.1842 -18.3421 13.1842 18.3421 2.0000
-13.5028 -15.0792 13.5028 15.0792 2.0000
-11.1091 -16.4909 11.1091 16.4909 2.0000
-10.9769 -14.0478 10.9769 14.0478 2.0000
-9.9722 -12.4105 9.9722 12.4105 2.0000
-9.6613 -10.6161 9.6613 10.6161 2.0000

I just want to know should I put all the 25 clusters into the training for all image pyramid(including 0.5X, 1X,2X) or should I only put the relative clusters base on the scale factor in the last column to the relative scaled image in training? I mean [0,4] for 0.5X images training, [5,12] for 1X images training and [13:24] for 2X image training?
Thanks.

run hr_res('train') has error

hello,dear peiyun ,
I can run the demo ,but when I run the hr_res('train') got the follow error:

Start using dagnn.DetLoss for loss
cnn_train_dag_hardmine: resetting GPU
train: epoch 01: 1/1074:Error using vl_nnconv
Out of memory on device. To view more detail about available memory on the GPU, use 'gpuDevice()'. If the problem persists, reset the GPU by calling
'gpuDevice(1)'.

Error in dagnn.Conv/forward (line 11)
outputs{1} = vl_nnconv(...

Error in dagnn.Layer/forwardAdvanced (line 85)
outputs = obj.forward(inputs, {net.params(par).value}) ;

Error in dagnn.DagNN/forward (line 28)
obj.layers(l).block.forwardAdvanced(obj.layers(l)) ;

Error in cnn_train_dag_hardmine>process_epoch (line 286)
net.forward(inputs, opts.derOutputs);

Error in cnn_train_dag_hardmine (line 148)
[stats.train(epoch),prof] = process_epoch(net, state, opts, 'train') ;

Error in cnn_widerface (line 212)
[net, info] = trainFn(net, imdb, getBatchFn(batchGetter, opts, net.meta), ...

Error in hr_res101 (line 42)
cnn_widerface('inputSize', inputSize, ...

compile_mex was successfully, can you help me solve it ? Thx

This matconvnet version may not use fixed moments in batch normalization when call net.eval

As usual, we want to use fixed moments when data flow into the batch normalization layer in a testing case, this may help us to improve the test performance. However, When I made a calculation by hand with the net.vars in the matlab command window, I had got that the net.eval HAD NOT USE the fixed moments in the net.params but the moments calculated according to the input image(even while the net.mode was set to 'test'). That may reduce the performance in the test case.

Training hr_res101('train') error

Hello I am trying to train hr_res101('train') with Wider face data. I compiled a CPU only version with matlab 2016b and matconvnet in ubuntu 14.04. After running the hr_res101('train') script I am getting the following error.

Trying to initialize the structure of resnet-101-simple
Unknown model: cannot initialize.
Loading pretrained weights from models/imagenet-resnet-101-dag.mat
Loaded imdb from data/widerface/imdb.mat
cluster path: data/widerface/RefBox_N25_scaled.mat
Undefined variable "dagnn" or class "dagnn.Split".

Error in cnn_add_loss_fcn8s_resnet101_simple (line 120)
net.addLayer('split', dagnn.Split('childIds', {1:N, N+1:5*N}), ...

Error in cnn_widerface (line 181)
net = cnn_add_loss_fcn8s_resnet101_simple(opts, net);

Error in hr_res101 (line 41)
cnn_widerface('inputSize', inputSize, ...

A question about function 'constr()'

Hello, Peiyun Hu.
I've read your paper. And I downloaded the code for testing. But I met a problem when I run minimal_demo.m as follow:

>> minimal_demo
Undefined function or variable 'dagnn.Split'.

Error in dagnn.DagNN.loadobj (line 27)
      block = constr() ;

Error in minimal_demo (line 31)
net = dagnn.DagNN.loadobj(net.net);

I think I've installed matconvnet successfully since vl_testnn works well. And I've search on Google about constr() but found nothing to do. So would you give me some suggestion about this problem?
Thank you very much!

no gpu

Hello. Can I use the model without GPU?
What parameters should be changed?

Error while train the model using 'hr_res101('train')

when i'm using the command

'hr_res101('train')
an error occured like this:
'Unable to read file 'data/widerface/event_diffmap.mat': no such file or directory'
And i dont know where can i get this file. Can anyone solve it?

problem :Undefined function or variable 'dagnn.Split'.

when i run bboxes = tiny_face_detector('data/demo/selfie.jpg', './selfie.png', 0.5, 0.1, 0), we have meet some other problem :Undefined function or variable 'dagnn.Split'.

Error in dagnn.DagNN.loadobj (line 26)
block = constr() ;

Error in tiny_face_detector (line 66)
net = dagnn.DagNN.loadobj(net.net);

Do not have the trained_model hr_res101.mat

could you please give me a trained_model?
I want to run the Demo to see the perfermance,but didn't have the mat file.

I get the Mat file with the url provided in the tiny_face_detector.m.

Questions on cnn_add_loss_fcn8s_resnet101_simple.m

% adapt for different input sizes (we end up using 500x500)
if all(opts.inputSize==500)
    ctblk = dagnn.ConvTranspose('size', size(filter), 'upsample', 2, ...
                                'crop', [1,2,1,2], 'hasBias', false);
  1. Can I know where do you use 500x500 size image? In the demo, you seem to be using images of different scales and not 500x500.
  2. Also, isn't the input image for resnet101 224x224? Why is it stated as 500x500 here?
  3. How does the crop being [1,2,1,2] work? From this visualization http://ethereon.github.io/netscope/#/gist/8a0d5ef37da9dc4cd611d178404b3641, the crop goes from 30x30 to 28x28. This code seems to suggest that it will crop the image to 27x27?

invitation letter for a tiny face report

Dear Dr. Hu,

I am Fei Jiang, and sent you an invitation letter yesterday with the title "invitation letter for a tiny face report". Have you received it ? I am afraid the Email will automatically labeled as a spam, and you did not read it. Could you please check it ? If you did not receive that Email, Please let me know and I will send it again. Thank you so much!

Looking forward to your reply, and hope you can accept our invitation!

Best,
Fei Jiang

how to run the demo on video?

i have run the demo on the images,and the results are excellent!!
so i think whether i can try to run it on videos?
but i dont know how to do that?anyone help me?
thanks a lot!!

未定义函数或变量 'nms_mex'。

未定义函数或变量 'nms_mex'。

出错 nms (line 43)
pick = nms_mex(double(boxes), double(overlap));

出错 tiny_face_detector (line 172)
ridx = nms(bboxes(:,[1:4 end]), nms_thresh);
I get the error,why?

Error in compile_mex (line 8).

I'm using matlab2017a, cuda 8 and cudnn5.1 for cuda 8.
matconvnet compiled and tested without any fail. I just can't compile youe file. could you help please or tell me what configuration you used to compile it.
thanks

compile_mex
Building with 'Microsoft Visual C++ 2013 Professional'.
Error using mex
compute_dense_overlap.cc
C:\Users\Administrator\Documents\MATLAB\Tiny2\tiny3\utils\compute_dense_overlap.cc(48) : warning C4244: 'initializing' :
conversion from 'double' to 'const int', possible loss of data
C:\Users\Administrator\Documents\MATLAB\Tiny2\tiny3\utils\compute_dense_overlap.cc(49) : warning C4244: 'initializing' :
conversion from 'double' to 'const int', possible loss of data
C:\Users\Administrator\Documents\MATLAB\Tiny2\tiny3\utils\compute_dense_overlap.cc(51) : warning C4267: 'initializing' :
conversion from 'size_t' to 'const int', possible loss of data
C:\Users\Administrator\Documents\MATLAB\Tiny2\tiny3\utils\compute_dense_overlap.cc(57) : warning C4267: 'initializing' :
conversion from 'size_t' to 'const int', possible loss of data
C:\Users\Administrator\Documents\MATLAB\Tiny2\tiny3\utils\compute_dense_overlap.cc(70) : error C2664: 'mxArray
*mxCreateNumericArray_730(size_t,const size_t *,mxClassID,mxComplexity)' : cannot convert argument 2 from 'const int [4]' to
'const size_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Users\Administrator\Documents\MATLAB\Tiny2\tiny3\utils\compute_dense_overlap.cc(75) : warning C4244: 'initializing' :
conversion from 'const double' to 'const int', possible loss of data
C:\Users\Administrator\Documents\MATLAB\Tiny2\tiny3\utils\compute_dense_overlap.cc(76) : error C2664: 'mxArray
*mxCreateNumericArray_730(size_t,const size_t *,mxClassID,mxComplexity)' : cannot convert argument 2 from 'const int [3]' to
'const size_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Users\Administrator\Documents\MATLAB\Tiny2\tiny3\utils\compute_dense_overlap.cc(143) : warning C4244: 'initializing' :
conversion from 'const double' to 'int', possible loss of data
C:\Users\Administrator\Documents\MATLAB\Tiny2\tiny3\utils\compute_dense_overlap.cc(144) : warning C4244: 'initializing' :
conversion from 'const double' to 'int', possible loss of data

Error in compile_mex (line 8)
mex compute_dense_overlap.cc CXXOPTIMFLAGS='-O3 -DNDEBUG'

hr_res101('train') error : "Error using gpuDevice (line 26) Invalid CUDA device id"

When I run hr_res101('train"), I am getting the error mentioned above. Can you tell how to fix it. Below is the detailed output and error message:

hr_res101('train');

ans =

models/widerface-resnet-101-simple-sample256-posfrac0.5-N25-bboxreg-cluster-scaled

Trying to initialize the structure of resnet-101-simple
Unknown model: cannot initialize.
Loading pretrained weights from ./trained_models/imagenet-resnet-101-dag.mat
Loaded imdb from data/widerface/imdb.mat
cluster path: data/widerface/RefBox_N25_scaled.mat

opts =

struct with fields:

  keepDilatedZeros: 0
         inputSize: [500 500]
      learningRate: [1×30 double]
           trainFn: '@cnn_train_dag_hardmine'
     batchGetterFn: '@cnn_get_batch_hardmine'
      freezeResNet: 0
               tag: ''
        clusterNum: 25
       clusterName: 'scaled'
           bboxReg: 1
        skipLRMult: [0 1 0.1000]
        sampleSize: 256
       posFraction: 0.5000
         posThresh: 0.7000
         negThresh: 0.3000
            border: [0 0]
 pretrainModelPath: './trained_models/imagenet-resnet-101-dag.mat'
           dataDir: 'data/widerface'
         modelType: 'resnet-101-simple'
       networkType: 'dagnn'
batchNormalization: 1
  weightInitMethod: 'gaussian'
    minClusterSize: [10 10]
    maxClusterSize: [Inf Inf]
            expDir: 'models/widerface-resnet-101-simple-sample256-posf...'
         batchSize: 48
     numSubBatches: 1
         numEpochs: 50
              gpus: [1 2 3 4]
   numFetchThreads: 8
              lite: 0
          imdbPath: 'data/widerface/imdb.mat'
             train: [1×1 struct]

ans =

struct with fields:

            gpus: [1 2 3 4]
       batchSize: 48
   numSubBatches: 1
       numEpochs: 50
    learningRate: [1×30 double]
keepDilatedZeros: 0

Start using dagnn.DetLoss for loss
Starting parallel pool (parpool) using the 'local' profile ... Warning: The system time zone setting, 'US/Eastern', does not specify a single
time zone unambiguously. It will be treated as 'America/New_York'. See the datetime.TimeZone property for
details about specifying time zones.

In verifyTimeZone (line 23)
In datetime (line 503)
In parallel.internal.cluster.FileSerializer>iLoadDate (line 345)
In parallel.internal.cluster.FileSerializer/getFields (line 100)
In parallel.internal.cluster.CJSSupport/getProperties (line 252)
In parallel.internal.cluster.CJSSupport/getJobProperties (line 463)
In parallel.internal.cluster.CJSJobMixin/hGetProperty (line 70)
In parallel.internal.cluster.CJSJobMixin/hSetTerminalStateFromCluster (line 98)
In parallel.cluster.CJSCluster/hGetJobState (line 361)
In parallel.internal.cluster.CJSJobMixin/getStateEnum (line 136)
In parallel.Job/get.StateEnum (line 214)
In parallel.Job/get.State (line 206)
In parallel.internal.customattr.CustomGetSet>iVectorisedGetHelper (line 107)
In parallel.internal.customattr.CustomGetSet>@(a,b,c)iVectorisedGetHelper(obj,a,b,c) (line 89)
In parallel.internal.customattr.CustomGetSet/doVectorisedGet (line 90)
In parallel.internal.customattr.CustomGetSet/hVectorisedGet (line 64)
In parallel.internal.customattr.GetSetImpl>iAccessProperties (line 289)
In parallel.internal.customattr.GetSetImpl>iGetAllProperties (line 250)
In parallel.internal.customattr.GetSetImpl.getImpl (line 124)
In parallel.internal.customattr.CustomGetSet/get (line 30)
In parallel.internal.pool.InteractiveClient/pRemoveOldJobs (line 464)
In parallel.internal.pool.InteractiveClient/start (line 311)
In parallel.Pool>iStartClient (line 567)
In parallel.Pool.hBuildPool (line 446)
In parallel.internal.pool.doParpool (line 15)
In parpool (line 89)
In cnn_train_dag_hardmine>prepareGPUs (line 604)
In cnn_train_dag_hardmine (line 132)
In cnn_widerface (line 212)
In hr_res101 (line 41)
connected to 4 workers.
cnn_train_dag_hardmine: resetting GPU
Error using cnn_train_dag_hardmine>prepareGPUs (line 616)
Error detected on worker 3.

Error in cnn_train_dag_hardmine (line 132)
prepareGPUs(opts, epoch == start+1) ;

Error in cnn_widerface (line 212)
[net, info] = trainFn(net, imdb, getBatchFn(batchGetter, opts, net.meta), ...

Error in hr_res101 (line 41)
cnn_widerface('inputSize', inputSize, ...

Caused by:
Error using gpuDevice (line 26)
Invalid CUDA device id: 3. Select a device id from the range 1:1.

When I run gpuDevice from matlab prompt this is what I get:

gpuDevice

ans =

CUDADevice with properties:

                  Name: 'Quadro M4000'
                 Index: 1
     ComputeCapability: '5.2'
        SupportsDouble: 1
         DriverVersion: 8
        ToolkitVersion: 7.5000
    MaxThreadsPerBlock: 1024
      MaxShmemPerBlock: 49152
    MaxThreadBlockSize: [1024 1024 64]
           MaxGridSize: [2.1475e+09 65535 65535]
             SIMDWidth: 32
           TotalMemory: 8.4922e+09
       AvailableMemory: 7.5519e+09
   MultiprocessorCount: 13
          ClockRateKHz: 772500
           ComputeMode: 'Default'
  GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
      CanMapHostMemory: 1
       DeviceSupported: 1
        DeviceSelected: 1

hr_res101('eval') ignore_list do not exist

i use the command hr_res101('eval');

error is as followed:

'ignore_list' do not exist。

error cnn_widerface_eval (line 191)
easy_gt(i).ign(easy_info.ignore_list{eventId}{img_idx}) = 0;

error hr_res101 (line 118)
cnn_widerface_eval('clusterNum', clusterNum, ...

info is from:

easy_info = load('eval_tools/ground_truth/wider_easy_val.mat');

line 191 is:

 easy_gt(i).ign(easy_info.ignore_list{eventId}{img_idx}) = 0;
med_gt(i).ign(med_info.ignore_list{eventId}{img_idx}) = 0;
hard_gt(i).ign(hard_info.ignore_list{eventId}{img_idx}) = 0;

A few train-related questions

Hi Peiyun,
Thank you so much for sharing with us your awesome work!
While I've been experimenting with training this net and analyzing your train code, a few points have come up on which i would be very happy to hear your thoughts:

  1. You chose summing the heatmap predictors of conv3&4 other than, say, concatenating the features then learning a single predictor over the concatenated feature. Have you tried other alternatives over sum? Many works on CNN object detection use concatenation for multi-scale features so your opinion is interesting.

  2. If I'd want to use only single-scale prediction at test time (e.g. no budget for pyramid, especially not x2 res), and to re-train for this scenario, which configuration of anchor boxes would you suggest me to use for train? Should the unscaled version of your given clusters be good for this, or maybe doing clustering from scratch? I think in this scenario the A/B pattern is no longer desired.

  3. The fixed OHEM threshold of 0.03. This value seems to have a very big impact on the net's convergence. Setting it to zero (i.e. no OHEM) causes the training loss to explode. Setting it to a smaller number hurts the detection quality. It seems very delicate. Empirically it filters on average 99.9% of the negatives and 10-70% of the positives per batch. Any insights on how this number was chosen? Also, in the paper the effect of it on mAP is almost negligible, while in reality I'm seeing quite the opposite.

  4. What is the rationale for choosing x10 smaller LR for conv3 predictor over conv4?

  5. Why are the weights for the predictor conv layers zero-initialized and not randomly initialized as usual? It's not very common to see zero init for conv weights.

Thank you for your patience reading this,
And again, great work!

Unable to clone submodule matconvnet

Trying to clone tiny or to update the submodules leads to this error:

➜  tiny git:(master) ✗ git submodule update --recursive --remote
Cloning into 'matconvnet'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Clone of '[email protected]:peiyunh/matconvnet.git' into submodule path 'matconvnet' failed

The easy fix is to change the url in .gitmodules. I'll submit a pull request shortly.

hr_res101('train') error with gpu,cuda,ubuntu

I am getting the following error. Can you help. I changed the gpus=[1 2 3 4] to gpus=[1] in the hr_res101('train') because it was saying device id from 1:1 is needed. Now I am getting the following error (at the bottom of the page):

hr_res101('train');

ans =

models/widerface-resnet-101-simple-sample256-posfrac0.5-N25-bboxreg-cluster-scaled

Trying to initialize the structure of resnet-101-simple
Unknown model: cannot initialize.
Loading pretrained weights from ./trained_models/imagenet-resnet-101-dag.mat
Loaded imdb from data/widerface/imdb.mat
cluster path: data/widerface/RefBox_N25_scaled.mat

opts =

struct with fields:

  keepDilatedZeros: 0
         inputSize: [500 500]
      learningRate: [1×30 double]
           trainFn: '@cnn_train_dag_hardmine'
     batchGetterFn: '@cnn_get_batch_hardmine'
      freezeResNet: 0
               tag: ''
        clusterNum: 25
       clusterName: 'scaled'
           bboxReg: 1
        skipLRMult: [0 1 0.1000]
        sampleSize: 256
       posFraction: 0.5000
         posThresh: 0.7000
         negThresh: 0.3000
            border: [0 0]
 pretrainModelPath: './trained_models/imagenet-resnet-101-dag.mat'
           dataDir: 'data/widerface'
         modelType: 'resnet-101-simple'
       networkType: 'dagnn'
batchNormalization: 1
  weightInitMethod: 'gaussian'
    minClusterSize: [10 10]
    maxClusterSize: [Inf Inf]
            expDir: 'models/widerface-resnet-101-simple-sample256-posfrac0.5-N25-bboxreg-cluster…'
         batchSize: 12
     numSubBatches: 1
         numEpochs: 50
              gpus: 1
   numFetchThreads: 8
              lite: 0
          imdbPath: 'data/widerface/imdb.mat'
             train: [1×1 struct]

ans =

struct with fields:

            gpus: 1
       batchSize: 12
   numSubBatches: 1
       numEpochs: 50
    learningRate: [1×30 double]
keepDilatedZeros: 0

Start using dagnn.DetLoss for loss
cnn_train_dag_hardmine: resetting GPU
train: epoch 01: 1/1074:Invalid MEX-file '/purcell1/mbaqui/Documents/tiny/utils/compute_dense_overlap.mexa64': dlopen: cannot
load any more object with static TLS.

Error in cnn_get_batch_hardmine (line 378)
iou = compute_dense_overlap(ofx,ofy,stx,sty,vsx,vsy,...

Error in cnn_widerface>getDagNNBatch (line 258)
[images, clsmaps, regmaps] = batchGetter(imagePaths, imageSizes, labelRects, ...

Error in cnn_widerface>@(x,y)getDagNNBatch(batchGetter,bopts,useGpu,x,y) (line 243)
fn = @(x,y) getDagNNBatch(batchGetter, bopts,useGpu,x,y) ;

Error in cnn_train_dag_hardmine>process_epoch (line 268)
inputs = state.getBatch(state.imdb, batch) ;

Error in cnn_train_dag_hardmine (line 148)
[stats.train(epoch),prof] = process_epoch(net, state, opts, 'train') ;

Error in cnn_widerface (line 212)
[net, info] = trainFn(net, imdb, getBatchFn(batchGetter, opts, net.meta), ...

Error in hr_res101 (line 42)
cnn_widerface('inputSize', inputSize, ...

Would please release the training code?

Dear peiyunh,
I've used your demo and got a really excellent result. Now I want to train a model in my own dataset. So would release the training code please? Thank you very much!

imdb.mat

I am sorry, I want to know the "imdb.mat" files of "set" value is ?

what can cause memory problems?

thanks for the code which really helps me a lot!!
but a warning occurs while the demo is running,it is as follows:

Warning: print2array generating a 168.1M pixel image. This could be slow and might also cause memory problems.

In print2array at 70
In export_fig at 516
In tiny_face_detector at 201
In demo_video at 11

and the speed is very slow which is about 8 seconds per image,so i wonder if it is the command "export_fig" that cause memory problems? and how should i solve it???
i want to save every image after i run the demo without display it on my screen , can anyone tell me what command should i add ?
thanks a lot!!!

request~~

@peiyunh
I want to train a model with other datasets,But there is not train code , if you could give me one ,I will very appreciate!!!
request.txt

Training hr_res101('train') error in class dagnn.DagNN

Hello I am trying to train hr_res101('train') with Wider face data. After running the hr_res101('train') script I am getting the following error.

Start using dagnn.DetLoss for loss
cnn_train_dag_hardmine: resetting GPU
train: epoch 01: 1/1074:No appropriate method, property, or field forward for class dagnn.DagNN.

Error in cnn_train_dag_hardmine>process_epoch (line 286)
net.forward(inputs, opts.derOutputs);

Error in cnn_train_dag_hardmine (line 148)
[stats.train(epoch),prof] = process_epoch(net, state, opts, 'train') ;

Error in cnn_widerface (line 212)
[net, info] = trainFn(net, imdb, getBatchFn(batchGetter, opts, net.meta), ...

Error in hr_res101 (line 41)
cnn_widerface('inputSize', inputSize, ...

segmentation fault when i use vl_imreadjpeg

When i use this, all succeed.
vl_compilenn('enableImreadJpeg', true,'enableGpu', true,'enableGpu', true, 'cudaRoot', '/usr/local/cuda', 'enableCudnn', true,'cudaMethod', 'nvcc','ImageLibrary','libjpeg','imageLibraryCompileFlags', {'­-I/home/vis/.jumbo/include','-­L/home/vis/.jumbo/lib','-­ljpeg'},'cudnnRoot','/home/work/cudnn/cudnn_v5/cuda')

but when i use
vl_test_imreadjpeg
Segmentation fault

Hope you can help me to solve this problem

image

About the mode 'normal' in model

Hello peiyun,
Your work is so amazing and i have read a part of the source code. But i didn't understand a detail that why you use the mode 'normal' rather than 'test' in the model, downloaded at https://www.cs.cmu.edu/~peiyunh/tiny/hr_res101.mat.
I found the code in file BatchNorm.m, line 13,

    function outputs = forward(obj, inputs, params)
      if strcmp(obj.net.mode, 'test')
        outputs{1} = vl_nnbnorm(inputs{1}, params{1}, params{2}, ...
                                'moments', params{3}, ...
                                'epsilon', obj.epsilon, ...
                                obj.opts{:}) ;
      else
        [outputs{1},obj.moments] = ...
            vl_nnbnorm(inputs{1}, params{1}, params{2}, ...
                       'epsilon', obj.epsilon, ...
                       obj.opts{:}) ;
      end
    end

Setting the mode to 'normal' will make the vl_nnbnorm return moments.
What i didn't understand is why don't you use the mode 'test' and the params 'bn_conv1_moments'?
Hope you will answer my question. Thank you very much.

Train and out of memory issue

Hi, thanks for your work.
When I use hr_res101('train') , I had a bug,,
Error is below:

train: epoch 01:   1/1074:Error using gpuArray/max
Out of memory on device. To view more detail about available memory on the GPU, use 'gpuDevice()'. If the problem persists, reset the GPU by calling 'gpuDevice(1)'.

My notebook has GTX1050,ComputeCapability: '6.1', TotalMemory: 4g.
Q:which parameter should I change?

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.