def weight(q_video_in, q_video_out): dataclass = cls.getClass() classcolor = cls.getColor() net = get_model('ssd_512_vgg16_atrous_custom', classes=dataclass, transfer='voc', pretrained_base=False, pretrained=False, ctx=mx.gpu()) #modify mx.cpu(), gpu() net.load_parameters('ssd_512_vgg16_atrous_voc_4220_0.8260.params') net.collect_params().reset_ctx([mx.gpu()]) net.hybridize() print('[OK] weight') while not q_video_in.empty(): # waiting while q_video_in.empty(): time.sleep(0.5) # get imgA = q_video_in.get() x = imgA.get_tensors() x = x.as_in_context(mx.gpu()) class_IDs, scores, bounding_boxes = net(x) imgA.set_deteced_value(bounding_boxes[0], class_IDs[0], scores) while q_video_out.full(): time.sleep(0.05) # if q_video_out(funtion : show)is busy wait q_video_out.put(imgA) # else put imgA in Queue
def __init__(self, cap_Num, image, gps_data): if isinstance(image, str): self.tensors, self.image = imgs_fname_transform(image) else: self.tensors, self.image = imgs_transform( image) # define in img_transform self.Bool_For_Detect = False self.CapNumber = cap_Num self.bbox = [] self.class_name = Cs.getClass() self.class_color = Cs.getColor() self.gps = "25.0671544,121.521804" self.location = "KFFF+000" # Hundred-meter pile self.time = time.asctime(time.localtime(time.time()))
def producer(q, q_for_v): dataclass = cls.getClass() classcolor = cls.getColor() net = get_model('ssd_300_vgg16_atrous_custom', classes=dataclass, transfer='voc', pretrained_base=False, pretrained=False, ctx=mx.gpu()) #modify mx.cpu(), gpu() net.load_parameters( r'./weight/ssd_300_ssd_512_vgg16_atrous_voc_1000_0.8837.params') net.collect_params().reset_ctx([mx.gpu()]) net.hybridize() print('[OK] detector is ready.') while q_for_v.empty(): time.sleep(0.01) while not q_for_v.empty(): start = time.time() imgA = q_for_v.get() x = imgA.get_tensors() x = x.as_in_context(mx.gpu()) class_IDs, scores, bounding_boxes = net(x) imgA.set_deteced_value(bounding_boxes[0], class_IDs[0], scores) # if q.empty() : print("q is empty") # if q.full() : print("q is full") imgA.draw_bbox() imgA.draw_shit(1 / (time.time() - start)) while q.full(): time.sleep(0.01) # if q_video_out(funtion : show)is busy wait q.put(imgA) # else put imgA in Queue
print("loading...") import time import cla import bbox import classSet as cls from gluoncv.model_zoo import get_model from gluoncv import model_zoo, utils from ownGluoncv import data from matplotlib import pyplot as plt import mxnet as mx if __name__ == '__main__': print("Done. Start execute!") time.sleep(2) dataclass = cls.getClass() classcolor = cls.getColor() print(dataclass) net = model_zoo.get_model('ssd_512_vgg16_atrous_custom', classes=dataclass, transfer='voc', pretrained_base=False, pretrained=False, ctx=mx.gpu()) #modify mx.cpu(), gpu() print("Loading model ssd_512_vgg16_atrous_voc_0066_0.9462.params....") MODEL_Load_time_Start = time.time() net.load_parameters('ssd_512_vgg16_atrous_voc_0066_0.9462.params') MODEL_Load_time_End = time.time() print("Loading model use {:.3f} sec".format(MODEL_Load_time_End -