xiaxuehai / faceboxes Goto Github PK
View Code? Open in Web Editor NEWfaceboxes implement by pytorch
faceboxes implement by pytorch
path/image_name.jpg num_face x y w h 1 x y w h 1,这是数据标注,这里的x,y是候选框的中心吗,还是左上角坐标啊
the implement of hard negative mining actually decrease the anchor number so when positive number = 0,negative number will be = 0 too
why add 4 in the inference.py when drawing rectangle?
for i, (box) in enumerate(boxes):
print('i=', i, 'box=', box)
x1 = int(box[0])
x2 = int(box[2])
y1 = int(box[1])
y2 = int(box[3])
cv2.rectangle(im,(x1,y1+4),(x2,y2),(0,255,0),2)
The image feeding into the network is between (0, 255) during testing, you can print the value of it:
https://github.com/XiaXuehai/faceboxes/blob/master/predict.py#L19
However, the image during training is between (0, 1.) because Totensor function
:
https://github.com/pytorch/vision/blob/master/torchvision/transforms/functional.py#L51
will divide 255 to the original image for the training dataset:
https://github.com/XiaXuehai/faceboxes/blob/master/dataset.py#L78
I found that nms implementation (https://github.com/XiaXuehai/faceboxes/blob/master/encoderl.py#L95) use clamp.
without clamp, the result is wrong, but I have no idea why you apply clamp here.
second, you also compute pad (https://github.com/XiaXuehai/faceboxes/blob/master/predict.py#L14), I have no idea why you compute pad here.
any idea?
thanks
i run sudo python3 trainvisdom.py
load model...
Traceback (most recent call last):
File "trainvisdom.py", line 112, in
train()
File "trainvisdom.py", line 27, in train
net.load_state_dict(torch.load('weight/faceboxes.pt'))
File "/usr/local/lib/python3.5/dist-packages/torch/serialization.py", line 356, in load
f = open(f, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'weight/faceboxes.pt'
I get this when I run trainvisdom.py ,shall I do some preparation before running the script??
Traceback (most recent call last):
File "E:\My_Project\face_recognition\faceboxes-master\trainvisdom.py", line 112, in
train()
File "E:\My_Project\face_recognition\faceboxes-master\trainvisdom.py", line 27, in train
net.load_state_dict(torch.load('weight/faceboxes.pt'))
File "C:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 721, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for FaceBox:
Unexpected key(s) in state_dict: "bn1.num_batches_tracked", "bn2.num_batches_tracked", "inception1.conv1.1.num_batches_tracked", "inception1.conv2.1.num_batches_tracked", "inception1.conv3.1.num_batches_tracked", "inception1.conv4.1.num_batches_tracked", "inception1.conv5.1.num_batches_tracked", "inception1.conv6.1.num_batches_tracked", "inception1.conv7.1.num_batches_tracked", "inception2.conv1.1.num_batches_tracked", "inception2.conv2.1.num_batches_tracked", "inception2.conv3.1.num_batches_tracked", "inception2.conv4.1.num_batches_tracked", "inception2.conv5.1.num_batches_tracked", "inception2.conv6.1.num_batches_tracked", "inception2.conv7.1.num_batches_tracked", "inception3.conv1.1.num_batches_tracked", "inception3.conv2.1.num_batches_tracked", "inception3.conv3.1.num_batches_tracked", "inception3.conv4.1.num_batches_tracked", "inception3.conv5.1.num_batches_tracked", "inception3.conv6.1.num_batches_tracked", "inception3.conv7.1.num_batches_tracked", "conv3_1.1.num_batches_tracked", "conv3_2.1.num_batches_tracked", "conv4_1.1.num_batches_tracked", "conv4_2.1.num_batches_tracked".
I tried to train the network with WIDERFACE, But I found that it's difficult to converge.
after the several epochs, both the precision and recall are less than 1%, did you have the similar problem?
it seems that the paper work is trained at least 200 epochs, did you train such a long epochs?
I tried to mask the small face of the training data (https://github.com/zeusees/FaceBoxes), but it does not speed up the training.
Thank you for your great work. But I can't get the speed described in paper Faceboxes. Just 20fps in GPU.
I simply run inference.py with model weight/faceboxes.pt on images under picture/ folder, but cannot detect face on any of the images. what's the problem?
/opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/THC/THCTensorScatterGather.cu:97: void THCudaTensor_gatherKernel(TensorInfo<Real, IndexType>, TensorInfo<Real, IndexType>, TensorInfo<long, IndexType>, int, IndexType) [with IndexType = unsigned int, Real = float, Dims = 2]: block: [314,0,0], thread: [33,0,0] Assertion indexValue >= 0 && indexValue < src.sizes[dim]
failed.
/opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/THC/THCTensorScatterGather.cu:97: void THCudaTensor_gatherKernel(TensorInfo<Real, IndexType>, TensorInfo<Real, IndexType>, TensorInfo<long, IndexType>, int, IndexType) [with IndexType = unsigned int, Real = float, Dims = 2]: block: [314,0,0], thread: [37,0,0] Assertion indexValue >= 0 && indexValue < src.sizes[dim]
failed.
/opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/THC/THCTensorScatterGather.cu:97: void THCudaTensor_gatherKernel(TensorInfo<Real, IndexType>, TensorInfo<Real, IndexType>, TensorInfo<long, IndexType>, int, IndexType) [with IndexType = unsigned int, Real = float, Dims = 2]: block: [314,0,0], thread: [41,0,0] Assertion indexValue >= 0 && indexValue < src.sizes[dim]
failed.
/opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/THC/THCTensorScatterGather.cu:97: void THCudaTensor_gatherKernel(TensorInfo<Real, IndexType>, TensorInfo<Real, IndexType>, TensorInfo<long, IndexType>, int, IndexType) [with IndexType = unsigned int, Real = float, Dims = 2]: block: [314,0,0], thread: [46,0,0] Assertion indexValue >= 0 && indexValue < src.sizes[dim]
failed.
/opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/THC/THCTensorScatterGather.cu:97: void THCudaTensor_gatherKernel(TensorInfo<Real, IndexType>, TensorInfo<Real, IndexType>, TensorInfo<long, IndexType>, int, IndexType) [with IndexType = unsigned int, Real = float, Dims = 2]: block: [314,0,0], thread: [50,0,0] Assertion indexValue >= 0 && indexValue < src.sizes[dim]
failed.
/opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/THC/THCTensorScatterGather.cu:97: void THCudaTensor_gatherKernel(TensorInfo<Real, IndexType>, TensorInfo<Real, IndexType>, TensorInfo<long, IndexType>, int, IndexType) [with IndexType = unsigned int, Real = float, Dims = 2]: block: [314,0,0], thread: [60,0,0] Assertion indexValue >= 0 && indexValue < src.sizes[dim]
failed.
/opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/THC/THCTensorScatterGather.cu:97: void THCudaTensor_gatherKernel(TensorInfo<Real, IndexType>, TensorInfo<Real, IndexType>, TensorInfo<long, IndexType>, int, IndexType) [with IndexType = unsigned int, Real = float, Dims = 2]: block: [315,0,0], thread: [200,0,0] Assertion indexValue >= 0 && indexValue < src.sizes[dim]
failed.
/opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/THC/THCTensorScatterGather.cu:97: void THCudaTensor_gatherKernel(TensorInfo<Real, IndexType>, TensorInfo<Real, IndexType>, TensorInfo<long, IndexType>, int, IndexType) [with IndexType = unsigned int, Real = float, Dims = 2]: block: [315,0,0], thread: [219,0,0] Assertion indexValue >= 0 && indexValue < src.sizes[dim]
failed.
/opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/THC/THCTensorScatterGather.cu:97: void THCudaTensor_gatherKernel(TensorInfo<Real, IndexType>, TensorInfo<Real, IndexType>, TensorInfo<long, IndexType>, int, IndexType) [with IndexType = unsigned int, Real = float, Dims = 2]: block: [262,0,0], thread: [117,0,0] Assertion indexValue >= 0 && indexValue < src.sizes[dim]
failed.
Traceback (most recent call last):
File "/home/t1070/TeddyZhang/DEEP_LEARNING/faceboxes-master/trainvisdom.py", line 116, in
train()
File "/home/t1070/TeddyZhang/DEEP_LEARNING/faceboxes-master/trainvisdom.py", line 73, in train
loss = criterion(loc_preds,loc_targets,conf_preds,conf_targets)
File "/home/t1070/anaconda2/envs/TeddyZhang/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(input, **kwargs)
File "/home/t1070/TeddyZhang/DEEP_LEARNING/faceboxes-master/multibox_loss.py", line 64, in forward
neg = self.hard_negative_mining(conf_loss, pos) # (1621824, (16,21824))
File "/home/t1070/TeddyZhang/DEEP_LEARNING/faceboxes-master/multibox_loss.py", line 29, in hard_negative_mining
conf_loss[pos.view(-1,1)] = 0 #去掉正样本,the rest are neg conf_loss
RuntimeError: device-side assert triggered
Any License here?
@XiaXuehai
在训练时,通过
net.load_state_dict(torch.load('weight/faceboxes.pt'))
载入了模型,但这个模型应该是1个训练好的模型吧.
那么模型(各个网络层)该如何初始化化呢??在code中,貌似并没有这部分的代码.
File "predict.py", line 120, in
net.load_state_dict(torch.load('weight/faceboxes_add_norm.pt', map_location=lambda storage, loc:storage))
File "/home/.../miniconda3/envs/face/lib/python3.6/site-packages/torch/nn/modules/module.py", line 721, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for FaceBox:
Unexpected key(s) in state_dict: "bn1.num_batches_tracked", "bn2.num_batches_tracked", "inception1.conv1.1.num_batches_tracked", "inception1.conv2.1.num_batches_tracked", "inception1.conv3.1.num_batches_tracked", "inception1.conv4.1.num_batches_tracked", "inception1.conv5.1.num_batches_tracked", "inception1.conv6.1.num_batches_tracked", "inception1.conv7.1.num_batches_tracked", "inception2.conv1.1.num_batches_tracked", "inception2.conv2.1.num_batches_tracked", "inception2.conv3.1.num_batches_tracked", "inception2.conv4.1.num_batches_tracked", "inception2.conv5.1.num_batches_tracked", "inception2.conv6.1.num_batches_tracked", "inception2.conv7.1.num_batches_tracked", "inception3.conv1.1.num_batches_tracked", "inception3.conv2.1.num_batches_tracked", "inception3.conv3.1.num_batches_tracked", "inception3.conv4.1.num_batches_tracked", "inception3.conv5.1.num_batches_tracked", "inception3.conv6.1.num_batches_tracked", "inception3.conv7.1.num_batches_tracked", "conv3_1.1.num_batches_tracked", "conv3_2.1.num_batches_tracked", "conv4_1.1.num_batches_tracked", "conv4_2.1.num_batches_tracked".
it seems there is an issue in your predict.py. when training, images are rescaled into [0,1] by transform.ToTensor, but in your predict.py, I don't see any operattions that rescales a image into [0,1]
@XiaXuehai HI
在encoderl.py中,在计算anchors时,有一个疑问:
for j,ar in enumerate(aspect_ratios[i]):
if i == 0:
for dx,dy in itertools.product(density[j], repeat=2): ### 21 = 4*4 + 2*2 + 1
boxes.append((cx+dx/8.*s*ar, cy+dy/8.*s*ar, s*ar, s*ar)) # add the offset
此时,当i=0,j=1,ar=2时.即在第1个检测分支(特征图尺寸=32,stride=32)上,当anchor size = 64时,对应的4个anchors为:
(0.0, 0.0, 0.0625, 0.0625),
(0.0, 0.03125, 0.0625, 0.0625),
(0.03125, 0.0, 0.0625, 0.0625),
(0.03125, 0.03125, 0.0625, 0.0625)
对应回1024的image,其形式为:
(0.0, 0.0, 64.0 64.0),
(0.0, 32.0, 64.0 64.0),
(32.0, 0.0, 64.0 64.0),
(32.0, 32.0, 64.0 64.0)
发现2个anchors之间的的stride并不等于16,仍是32,即其密度是2.这貌似并不满足paper的设置???
https://github.com/zeusees/FaceBoxes
want to know why fddb val performance different between your pytorch and zeusees caffe version.
I have compare the model, diff is conv1 pool1 pad. but this small diff affect the performance?
or something diff between generate priorbox or loss layer? have not compare priorbox and loss.
batch_size=32,image_size=1024.
这么大的batch_size+image_size,却只占了很小一部分显存,仅仅就因为网络模型很小吗?还是有什么其他原因??
Looking forward your reply!
Thank you for your sharing!
Traceback (most recent call last):
File "predict.py", line 145, in <module>
testVideo()
File "predict.py", line 44, in testVideo
boxes, probs= detect(im)
File "predict.py", line 21, in detect
F.softmax(conf.squeeze(0)).data)
File "C:\Users\buliqoqo\Desktop\faceboxes-master\encoderl.py", line 263, in decode
ids = labels.nonzero().squeeze(1)
RuntimeError: Dimension out of range (expected to be in range of [-1, 0], but got 1)
I changed testvideo() function to test camera and got this problem when there is no face in input image. Can you help me?
Hi,
When increasing the density of the anchors (https://github.com/XiaXuehai/faceboxes/blob/master/encoderl.py#L34),
I don't understand why you divide 8.
(cx+dx/8.*s*ar, cy+dy/8.*s*ar, s*ar, s*ar)
Why divide by 8?
Do you mind to uploadval.txt
and train.txt
or how to generate these two files?
The respect ratio is kept during the testing:
https://github.com/XiaXuehai/faceboxes/blob/master/predict.py#L13
However, it is not for training:
https://github.com/XiaXuehai/faceboxes/blob/master/dataset.py#L74
Do you think it is necessary to keep the respect ration during training?
Xiaxuehai老师你好,看您坐标南京,我就打中文提问吧。今天download了这个faceboxes来研究,目前参照import把环境搭载了,每页import处已均可顺利运行。
但是现在比较迷茫,您这个项目还有您在readme中提及的参照了的两个项目都没有太详细介绍这个怎么来用。
可以进行简单的指导吗?
我现在有这么几个问题:
1.正确的使用顺序是什么样的
2.我只有一台macbook pro可以用吗
3.faceboxe.pt这是什么文件
4.data中的两个txt文件可以删除或清空吗。
老师如果有空的时候可以回答一下吗。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.