Sierkinhane / mtcnn-pytorch

A face detection algorithm
317 stars 162 forks source link

Traceback (most recent call last): File "mtcnn/data_preprocess/gen_Pnet_train_data.py", line 94, in <module> delta_x = np.random.randint(max(-size, -x1), w) File "mtrand.pyx", line 630, in numpy.random.mtrand.RandomState.randint File "bounded_integers.pyx", line 1228, in numpy.random.bounded_integers._rand_int64 ValueError: low >= high #13

Open ouening opened 4 years ago

ouening commented 4 years ago

Hi, when I generate the Pnet train data, some errors happend:

12880 pics in total
/media/gaoya/disk/Applications/pytorch/目标检测/人脸检测/dataset/WIDER_FACE/WIDER_train/images/0--Parade/0_Parade_marchingband_1_849.jpg
/media/gaoya/disk/Applications/pytorch/目标检测/人脸检测/dataset/WIDER_FACE/WIDER_train/images/0--Parade/0_Parade_Parade_0_904.jpg
Traceback (most recent call last):
  File "mtcnn/data_preprocess/gen_Pnet_train_data.py", line 94, in <module>
    delta_x = np.random.randint(max(-size, -x1), w)
  File "mtrand.pyx", line 630, in numpy.random.mtrand.RandomState.randint
  File "bounded_integers.pyx", line 1228, in numpy.random.bounded_integers._rand_int64
ValueError: low >= high

How can I solve it?

Z-Jeff commented 4 years ago

There is a bug in "mtcnn/data_preprocess/gen_Pnet_train_data.py". 'boxes' should be the form of [x1, y1, x2, y2], while the data in "./anno_store/anno_train.txt" is [x1, x2, dx, dy].

So, correct the form of 'boxes' can solve the problem. Here is my solution:

for box in boxes:
        box[2] = box[0] + box[2]
        box[3] = box[1] + box[3]

Add these lines between line 48 and 49. Then the error disappears.

Z-Jeff commented 4 years ago

What's more, there is a same question in "gen_Rnet_train_data.py" and "gen_Onet_train_data.py". Deal it in the same way.

ysf465639310 commented 4 years ago

In .mat file of wilder_face , Number of bounding box: x1, y1, w, h, blur, expression, illumination, invalid, occlusion, pose

not x1 y1 x2 y2 so you should fix it

like:

for box in boxes:
    # box (x_left, y_top, x_right, y_bottom)
    x1, y1, w, h = box
    # w = x2 - x1 + 1
    # h = y2 - y1 + 1
    x2 = x1 + w - 1
    y2 = y1 + h - 1
SURABHI-GUPTA commented 4 years ago

@Z-Jeff why are we not generating landmark data for pnet and rnet ?

LiYunJamesPhD commented 3 years ago

When I ran mtcnn/data_preprocess/gen_Pnet_train_data.py, I received an error from this implementation. How did I resolve this issue? Thanks.

Traceback (most recent call last): File "mtcnn/data_preprocess/gen_Pnet_train_data.py", line 162, in delta_x = np.random.randint(-w 0.2, w 0.2) File "mtrand.pyx", line 743, in numpy.random.mtrand.RandomState.randint File "_bounded_integers.pyx", line 1260, in numpy.random._bounded_integers._rand_int64 ValueError: low >= high

DantesDawn commented 2 years ago

@LiYunJamesPhD ,I also encountered the same problem. Have you solved it?

LiYunJamesPhD commented 2 years ago

@DantesDawn Hi, no, I could not solve this issue.

DantesDawn commented 2 years ago

@LiYunJamesPhD , Thank you for your reply. I have solved this problem. The simplest method is to delete the error data 5-29. Another method is that I see that the warehouse provides the annotation file conversion tool code for x, y, w, h and x1, y1, x2, y2. I think I can try. Well, the third method should be to modify the error code, but I haven't read the code in detail.

LiYunJamesPhD commented 2 years ago

@DantesDawn Sounds great! I have not touched this code for a while because I was done with my internship (this code is part of my internship works). It is still good to know the solutions for that issue. Thanks.