shuangxieirene / ssds.pytorch Goto Github PK
View Code? Open in Web Editor NEWRepository for Single Shot MultiBox Detector and its variants, implemented with pytorch, python3.
License: MIT License
Repository for Single Shot MultiBox Detector and its variants, implemented with pytorch, python3.
License: MIT License
I don not understand how the scale is used in L2Norm function
I appreciate it if someone can explain it for me please
您好,在fssd_vgg16_train_coco.yml中RESUME_CHECKPOINT: './weights/fssd/vgg16_fssd_coco_24.5.pth',我在所指目录下没有找到此权重文件,请问哪里可以下载此文件?谢谢! @foreverYoungGitHub @ShuangXieIrene
Encounter an error when running demo.py below:
python3 ./demo.py --cfg=./experiments/cfgs/fssd_lite_mobilenetv1_train_voc.yml --demo=./experiments/person.jpg
===> Building model
/home/topspin/2TB/src/ssds.pytorch/lib/modeling/model_builder.py:51: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad():
instead.
x = torch.autograd.Variable(x, volatile=True) #.cuda()
/usr/local/lib/python3.5/dist-packages/torch/nn/functional.py:1761: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
"See the documentation of nn.Upsample for details.".format(mode))
==>Feature map size:
[(38, 38), (19, 19), (10, 10), (5, 5), (3, 3), (1, 1)]
/home/topspin/2TB/src/ssds.pytorch/lib/ssds.py:21: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad():
instead.
self.priors = Variable(self.priorbox.forward(), volatile=True)
Utilize GPUs for computation
Number of GPU available 1
=> loading checkpoint ./weights/fssd_lite/mobilenet_v1_fssd_lite_voc_78.4.pth
/home/topspin/2TB/src/ssds.pytorch/lib/ssds.py:68: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad():
instead.
x = Variable(self.preprocessor(img)[0].unsqueeze(0),volatile=True)
Traceback (most recent call last):
File "./demo.py", line 154, in
demo(args, args.demo_file)
File "./demo.py", line 59, in demo
_labels, _scores, _coords = object_detector.predict(image)
File "/home/topspin/2TB/src/ssds.pytorch/lib/ssds.py", line 82, in predict
detections = self.detector.forward(out)
File "/home/topspin/2TB/src/ssds.pytorch/lib/layers/functions/detection.py", line 151, in forward
ids, count = nms(boxes, scores, self.nms_thresh, self.top_k)
ValueError: not enough values to unpack (expected 2, got 0)
Hello, I tried run your code using "ssd_vgg16_train_voc.yml"
But, almost results are zero and doesn't increase.
=======================================================
AP for aeroplane = 0.0000
AP for bicycle = 0.0000
AP for bird = 0.0000
AP for boat = 0.0000
AP for bottle = 0.0000
AP for bus = 0.0000
AP for car = 0.0000
AP for cat = 0.0000
AP for chair = 0.0000
AP for cow = 0.0000
AP for diningtable = 0.0000
AP for dog = 0.0000
AP for horse = 0.0000
AP for motorbike = 0.0000
AP for person = 0.0001
AP for pottedplant = 0.0003
AP for sheep = 0.0000
AP for sofa = 0.0000
AP for train = 0.0000
AP for tvmonitor = 0.0000
Mean AP = 0.0000
Results:
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
================================================
Above result are printed at epoch 5.
Although the number epoch is too low, there are problems.
Please tell me the way to fix these problems if you know.
Thank you.
Could you provide the pretrained models?thanks.
I'm a green hand in pytorch. Any help is welcomed. Thank you!
I found that the first feature layer output is 1919 and last two layers both give a 11 size output, dose it correct? Why choosing such a small size comparing to the original structure?
Can the input image size be changed into another?
Hello @ShuangXieIrene and @foreverYoungGitHub ,
I saw that the pretrained of Resnet50+FSSD on COCO is available and really appreciate it. I wonder if it would be possible to also release the pretrained model on VOC.
Thank you!
I wish I could use coco pretrained weights(checkpoint) for training with my own dataset, but I can't find one. Is there something available?
Created an env file which you can use.
Just download the yaml from my repo https://github.com/cardoso-neto/ssds.pytorch/blob/5384d8c27de82919eab956655a88834e29ac8c2d/ssds.yaml and run conda env create -f ssds.yaml
This will, however, require one small modification to line 45 of ssds_train.py
from:
self.priors = self.priorbox.forward()
to:
self.priors = Variable(self.priorbox.forward())
The error message is quite clear and straightforward, suggesting to cast the torch.Tensor
to an autograd.Variable
.
After fiddling a bit with different Python/Pytorch versions, this is seemed to work:
Python=3.6
Pytorch=0.3.1
Not really an issue. Just wanted to leave this somewhere where it'd be helpful.
The _mask
is not getting imported.
its present in pycoco. the previous issue solved it using python3,but I am facing the same using python3. I think the issue is that this file is capable only with python 3.6 not 3.5. ( as the name itself is _mask.cpython-36m-x86_64-linux-gnu.so
)
File "ssds.pytorch/lib/layers/modules/multibox_loss.py", line 91, in forward
loss_c[pos] = 0 # filter out pos boxes for now
RuntimeError: The shape of the mask [32, 11620] at index 0 does not match the shape of the indexed tensor [371840, 1] at index 0
Hello @ShuangXieIrene and @foreverYoungGitHub .
Thank you for your great contribution.
As the title said, what is "Free Image Size" ?
In the .cfg file, there are several settings as below. If i want to change the IMAGE_SIZE: [300, 300] to IMAGE_SIZE: [512, 512], then do i have to change the other parameters as well ? If that's so, how can i change those ?
MODEL:
SSDS: ssd
NETS: resnet_50
IMAGE_SIZE: [300, 300]
NUM_CLASSES: 21
FEATURE_LAYER: [[10, 16, 'S', 'S', '', ''], [512, 1024, 512, 256, 256, 256]]
STEPS: [[8, 8], [16, 16], [32, 32], [64, 64], [100, 100], [300, 300]]
SIZES: [[30, 30], [60, 60], [111, 111], [162, 162], [213, 213], [264, 264], [315, 315]]
ASPECT_RATIOS: [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2], [1, 2]]
Thank you for your time
Do I need to resize the image by myself?and should I change the label to a 0~1 value compare to image size? Thank you for any help!
I have trained ssd with mobilenetv2 on VOC but after almost 500 epochs, the loss is still like this:
517/518 in 0.154s [##########] | loc_loss: 1.4773 cls_loss: 2.3165
==>Train: || Total_time: 79.676s || loc_loss: 1.1118 conf_loss: 2.3807 || lr: 0.000721
Wrote snapshot to: ./experiments/models/ssd_mobilenet_v2_voc/ssd_lite_mobilenet_v2_voc_epoch_525.pth
Epoch 526/1300:
0/518 in 0.193s [----------] | loc_loss: 0.8291 cls_loss: 1.9464
1/518 in 0.186s [----------] | loc_loss: 1.3181 cls_loss: 2.5404
2/518 in 0.184s [----------] | loc_loss: 1.0371 cls_loss: 2.2243
It's doesn't change and loss is very hight...... What's the problem with implementation?
I uncomment the lines that has torch.nn.DataParallel
but the model still cannot run in parallel.
It runs but it still use just one gpu
Any suggestion to solve it?
Hi,
I was reviewing the test code here, and found out that test_epoch defined in ssds_train.py tests one image at a time. Why can't we do this in batch mode (for example as in eval_epoch)?
for mobilenetV2 ssd-lite on COCO dataset. want to train to detect only pedestrians. I am sure that changing "num_classes" arg in the yml file isn't enough. My guess is: change the COCO ann file to "person_keypoints_train/val2017.json" and num_classes to 2. Will it be enough? Thank you.
Hey, thanks for the great repo. I wanna know about the TRAINABLE_SCOPE and
RESUME_SCOPE. Which parameters should I include during the fine-tuning?
Hi,
When I tried to eval the model, I got the problem in visualize_utils.py,that's say:
""
File "/home/ssds.pytorch/lib/utils/visualize_utils.py", line 159, in add_pr_curve_raw
writer.add_pr_curve_raw(
AttributeError: 'SummaryWriter' object has no attribute 'add_pr_curve_raw'
""
I saw from the tensorboardX-1.1,that in the writer.py, only see the 'add_pr_curve' method, so I want to make sure is that the version problem ,and what the version of your tensorboardX is. ; )
Hi.
can you tell me what is the proper way to train object detector from scratch with pretrained base architectures such as Resnet50, VGG16, MobilenetV1, MobilenetV2?
or can you give me some references regarding this?
I first tried by command line below but it seemed that the training starts without pretrained weights.
python train.py --cfg=./experiments/cfgs/ssd_vgg16_train_voc.yml
So now I'm training VGG16-SSD on voc dataset using exactly the same command below
python train.py --cfg=./experiments/cfgs/ssd_vgg16_train_voc.yml
but changed RESUME_CHECKPOINT
and PHASE
like this
RESUME_CHECKPOINT: './weights/ssd/vgg16_reducedfc.pth'
PHASE: ['train']
and also I downloaded vgg16_reducedfc.pth
from https://s3.amazonaws.com/amdegroot-models/vgg16_reducedfc.pth and put into ./weights/ssd/
but I wonder it is the right way to do it.
by the way, thanks for your great project! It seems like well-written, understandable codes! It helps me a lot.
Hi, everyone,
I test the pre-trained model on the VOC dataset, and found the mAP didn't match the expected ones.
Here is my result:
yolo_v2_mobilenetv2_voc: 0.721956
yolo_v3_mobilenetv2_voc: 0.766846
ssd_lite_mobilenetv2_voc: 0.708510
rfb_lite_mobilenetv2_voc: 0.713691
fssd_lite_mobilenetv2_voc: 0.744321
It can be seen, yolov2/3 perform better than the author's result, however the other three are bad than the expected result.
Have anyone met this problem?
can someone tell me what loc.append(l(x).permute(0, 2, 3, 1).contiguous())
does?
I dont understand what permute and contiguous does, and how they wrk
Hi,
I'm trying to do a test for the ssd_vgg model on VOC dataset, but I'm getting the following error :
Segmentation fault (core dumped)
I was using Python3.6 and Pytorch 0.4.1, after seeing this error I switched back to Pytorch 0.4.0. But the error is still there.
The command I run is:
python test.py --cfg=./experiments/cfgs/ssd_vgg16_train_voc.yml
I have changed the corresponding directories and weights in the yml file to be those I need.
Any help would be more than appreciated.
Thanks in advance!
Is there a plan to support RetinaNet? The accuracy of RetinaNet seems to be higher compared to SSD according to the RetinaNet paper.
Thanks,
Hi, I am trying to train the ssds network with multi gpu , but it seems doesn't working. I just use the DataParallel class. Are there any tricks to implent this? Thanks a lot.
May I know which pytorch version you used for running this program? My current version is 0.4.1 but there are some variables initialization are being deprecated. (e.g. images = Variable(preproc(image, anno)[0].unsqueeze(0), volatile=True)).
Thanks
Hi ShuangXieIrene:
Did you use MS COCO for pretraining before you trained the FSSD MobileNetV1 on VOC2007?
When I using VOC2007 and VOC2012 as training data for FSSD MobileNetV1, my performance is 73.8%. It is seems that your result is much better(78.4%).
I have tried to train the ssdlite with Mobilenetv2 as the backbone. As suggested, the pre-trained Mobilenetv2 model is downloaded from another repo. Besides changing the weights' name in pre-trained model to load it, I also change the preprocessing of input images. The input image is normalized to to make the mean 0 and standard deviation 1, as an issue in the repo of the pre-trained model shows. I didn't make other modifications and followed the Readme to train the ssdlite model for 300 epochs. I used the test.py to test and the mAP after 300 epochs is about 65 to 66. I also tested the pre-trained ssdlite model downloaded from the 73.2 link in the Readme file, and the mAP is 73.4 when nms threshold is 0.45.
Could you give some suggestions on how to improve the mAP and re-implement the results? Thanks!
I wanna train and get weight file of rfb mobilenet ssd model end-to-end by myself.
Should I need to load pretrained feature extractors weights? Then how can i get that weight file?
Can i know the training environment like epoch, learning rate, scheduler and learning decaying parameters?
I run this code python train.py --cfg=./experiments/cfgs/ssd_vgg16_train_voc.yml
and this is what i get:
python train.py --cfg=./experiments/cfgs/ssd_vgg16_train_voc.yml
Traceback (most recent call last):
File "train.py", line 20, in <module>
from lib.ssds_train import train_model
File "/home/alireza/Desktop/ssd/B/lib/ssds_train.py", line 23, in <module>
from lib.dataset.dataset_factory import load_data
File "/home/alireza/Desktop/ssd/B/lib/dataset/dataset_factory.py", line 2, in <module>
from lib.dataset import coco
File "/home/alireza/Desktop/ssd/B/lib/dataset/coco.py", line 13, in <module>
from lib.utils.pycocotools.coco import COCO
File "/home/alireza/Desktop/ssd/B/lib/utils/pycocotools/coco.py", line 55, in <module>
from . import mask as maskUtils
File "/home/alireza/Desktop/ssd/B/lib/utils/pycocotools/mask.py", line 3, in <module>
import lib.utils.pycocotools._mask as _mask
ImportError: No module named _mask
Any idea why??
Also What python version are using?
Plut where should i put the dataset (eg coco vgg)
from ._nms import lib as _lib, ffi as _ffi
ModuleNotFoundError: No module named 'lib.utils.nms._ext.nms._nms'
I use python3.6 .
When I try to run the demo, I get the following error:
from ._nms import lib as _lib, ffi as _ffi
ImportError: No module named 'lib.utils.nms._ext.nms._nms'
Ubuntu 16.04.3
GTX 1080Ti
Cuda 8.0 installed
I down load the mobilenet_v1_ssd_voc_72.7, it's test speed faster(0.03s) than my new model(0.3s).
I can't find the reason,the configuration file is same as mobilenet_v1_ssd_voc_72.
I also train new mobilenetv2-ssd in same file, the speed is still very slow.
Please give me some advice. Thank you very much!
Hi, ShuangXieIrene & foreverYoungGitHub:
Can you release the ImageNet pretrained models(like MobileNet V1/V2), so I can test this code.@ShuangXieIrene @foreverYoungGitHub
AttributeError: 'NoneType' object has no attribute 'shape'
I have trained “yolo_v3_mobilenetv2_voc” and “ssd_lite_mobilenetv2_train_voc” successfully.
So I want to train my own data, just 1 class: car, I have prepared “Annotations” and “JPEGImages”.
I have changed NUM_CLASSES to 2 in yml file and VOC_CLASSES (...) to VOC_CLASSES = ( 'car', 'background') in voc.py.
But I have no idea about txt files in ImageSets/Main, now I just have a trainval.txt which just contains the ids of the images.
so I have the error: Dimension out of range (expected to be in range of [-1,0), but got 1)
What additional txt file do I need?What else do I need to modify?
Thank you very much.
like the title, i read the code but i can't find the part of the preprocess of the data, any suggestions would be appreciate!
I want to train ssd_lite with MobileNetv2 as the backbone. The pre-trained MobileNetv2 model should b loaded. Where can I download the pre-trained model? Thanks
Hi, when I run the dark2pth.py, it turns out like this
convert yolov2...
Traceback (most recent call last):
File "dark2pth.py", line 375, in <module>
yolo_v2 = build_yolo_v2(darknet_19, feature_layer_v2, mbox_v2, 81)
File "/home/georgeokelly/ssds.pytorch/lib/modeling/ssds/yolo.py", line 215, in build_yolo_v2
return YOLO(base_, extras_, head_, feature_layer, num_classes)
File "/home/georgeokelly/ssds.pytorch/lib/modeling/ssds/yolo.py", line 31, in __init__
self.softmax = nn.Softmax(dim=-1)
TypeError: __init__() got an unexpected keyword argument 'dim'
and I don't know how to fix it.
Hi, glad to see your amazing work, and I am also interested in reconsidering SSD-stream methods.
Can you have a share of the result of detailed category-wise AP score of VOC07 of RFBNet, which is missing at the author's arxiv paper.
./experiments/cfgs/ssd_lite_mobilenetv2_train_voc.yml
===> Building model
==>Feature map size:
[(19, 19), (10, 10), (5, 5), (3, 3), (2, 2), (1, 1)]
Utilize GPUs for computation
Number of GPU available 1
=> loading checkpoint ./weights/ssd_lite/mobilenet_v2_ssd_lite_voc_73.2.pth
/home/wei_li/anaconda3/lib/python3.6/site-packages/torch/tensor.py:321: UserWarning: self and other not broadcastable, but have the same number of elements. Falling back to deprecated pointwise behavior.
return self.mul(other)
ASSERT: "false" in file qasciikey.cpp, line 501
./time_benchmark.sh: line 9: 16177 Aborted (core dumped) python demo.py --cfg=$file --demo=./experiments/person.jpg
i read the code, but i found that the loss function is ssd's? the multibox loss function is't the function in yolo's paper, right?
Whay the aspect ratios are define like this:
ASPECT_RATIOS: [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2], [1, 2]]
can any body explain it please?
Also i see in another place it also define like:
ASPECT_RATIOS: [[[0.1,0.1], [0.2,0.2], [0.3,0.3], [0.5,0.5], [0.9,0.9]]]
I am not sure why? plus should not aspect ratio be like 1:2 ....
Could you please provide a procedure to initialize SSD + Resnet50 so that it could reach 79.7% mAP? We tried many times but reached 69% only. Please help!
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.