class OrderDAO(): def __init__(self): self.db_helper = DBHelper() self.db_helper.open_conn() def __del__(self): self.db_helper.close_conn() def query_all_order(self): ''' 查询所有订单 :return: 所有订单实体组成的列表(list) or None ''' order_list = [] sql = 'SELECT * FROM orders LIMIT 0,10' result = self.db_helper.do_query(sql) if not result: print('查询结果为空') return None for row in result: order_id = row[0] cust_id = row[1] if row[4]: products_num = int(row[4]) else: products_num = 0 if row[5]: amt = float(row[5]) else: amt = 0 order_list.append(Order(order_id, cust_id, products_num, amt)) return order_list def query_by_id(self, id): sql = 'select * from orders WHERE order_id = %s' % (id) result = self.db_helper.do_query(sql)[0] if not result: print('查询结果为空') return None order_id = result[0] cust_id = result[1] if result[4]: products_num = int(result[4]) else: products_num = 0 if result[5]: amt = float(result[5]) else: amt = 0 order = Order(order_id, cust_id, products_num, amt) return order
caffe.set_device(1) # 假如有多块gpu,选择第一块gpu caffe.set_mode_gpu() # 设置用GPU来加载Caffe并且加载网络 labelmap_path = 'data/KITTI/labelmap_kitti.prototxt' labelmap = get_labelmap(labelmap_path) # * Load the net in the test phase for inference, and configure input preprocessing. model_def = 'models/VGGNet/KITTI3/SSD_300x300/deploy.prototxt' model_weights = 'models/VGGNet/KITTI3/SSD_300x300/VGG_KITTI_SSD_300x300_iter_80000.caffemodel' net = caffe.Net(model_def, # defines the structure of the model model_weights, # contains the trained weights caffe.TEST) # use test mode (e.g., don't perform dropout) transformer = input_process(net) images_path = '/mnt/disk_a/beijing/DataSet/augsburg/' im_names = [] for index in range(1000): s = "%06d" % index im_names.append(str(s) + '.png') totaltime = 0 db = DBHelper() db.get_conn() db.create_database() db.create_table() for image_name in im_names: print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' totaltime += im_detect(transformer, labelmap, image_name, images_path, db) db.close_conn() print 'totaltime = ' + str(totaltime) + ' for ' + str(len(im_names)) + ' images' print 'averagetime = ' + str(totaltime / len(im_names))