Open zik1ng opened 6 years ago
And could you please add a function draw boxes on image then return this image? I found it is difficult for me to use cv2.imshow() show processed images in real time detection. Thank you.
because you are assigning your customized weights to voc models, the shape of class prediction is different. You can load the same net in your training script.
I have added a convenient getter for custom dataset just merged in master
net = gcv.model_zoo.get_model('sad_300_vgg16_atrous_custom', classes=['a','b','c','d'])
You can use it to create a custom network quickly.
Thank you for your useful reply :)
Thank you again for your reply, that really solved my problem. But there is a new question that I wanna use this trained model make a webcam real-time detection. I use opencv to get the images and call cv2.imshow() to plot images with boxes. How can I get the image matrix with boxes in real time? Thanks. @zhreshold
@xDooooot Hi LaoGe, I trained SSD and get some params, when I load it and predict my test image, it is pick a issue, please you upload some code about you?
Here is what I used. `
net = gcv.model_zoo.get_model('yolo3_darknet53_custom', classes=['custom_label1', 'custom_label2', ...], pretrained_base=False)
net.load_parameters('yolo3_darknet53_voc_best.params')
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
# Image pre-processing
frame = mx.nd.array(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)).astype('uint8')
rgb_nd, frame = gcv.data.transforms.presets.ssd.transform_test(frame, short=512, max_size=700)
# Run frame through network
class_IDs, scores, bounding_boxes = net(rgb_nd)
` 希望能帮到你 :)
@ZengyuanYu
@xDooooot Thank you! I got it though others ask. But use camera also funny to try it.
Hello, I'm new in computer vision field. I'm using gluoncv to do instance segmentation with mask-rcnn but i have some problems. I did my own dataset similar to coco format and I trained with this model "mask_rcnn_resnet50_v1b_coco", but my dataset has just 2 classes. After training i got the parameter file and when i loaded the parameters and predict a new image, the classification was wrong and still loaded all classes of the coco dataset (80 classes). So is there any solution to customize the number of classes?
Hi. I am a new one here. It is a awesome lib for CV, thanks for your great work. Now, I am encountering a problem that I trained ssd_300_vgg16_atrous_voc on my own dataset, the dataset has 4 classes. After training, I got a "ssd_300_vgg16_atrous_voc_best.params" file. When I want to load the parmeters and predict on new images, it return an error, logs as it,
AssertionError: Failed loading Parameter 'ssd0_convpredictor4_conv0_weight' from saved params: shape incompatible expected (126, 0, 3, 3) vs saved (30, 512, 3, 3)
The command I used as follow,from gluoncv import model_zoo, data, utils
from matplotlib import pyplot as plt
import mxnet as mx
ctx = [mx.cpu()]
net = model_zoo.get_model('ssd_300_vgg16_atrous_voc', pretrained=False)
net.load_parameters('ssd_300_vgg16_atrous_voc_best.params', ctx = ctx)
Thanks for any help.