zoukankan      html  css  js  c++  java
  • tensorflow根据pb多bitch size去推导物体

            with self.detection_graph.as_default():
                with tf.Session(graph=self.detection_graph) as sess:
                    # Expand dimensions since the model expects images to have shape: [1, None, None, 3]
                    image_np_expanded = np.expand_dims(imageSerialized, axis=0)
                    image_tensor = self.detection_graph.get_tensor_by_name('image_tensor:0')
                    # Each box represents a part of the image where a particular object was detected.
                    boxes = self.detection_graph.get_tensor_by_name('detection_boxes:0')
                    # Each score represent how level of confidence for each of the objects.
                    # Score is shown on the result image, together with the class label.
                    scores = self.detection_graph.get_tensor_by_name('detection_scores:0')
                    classes = self.detection_graph.get_tensor_by_name('detection_classes:0')
                    num_detections = self.detection_graph.get_tensor_by_name('num_detections:0')
                    # Actual detection.
                    (boxes, scores, classes, num_detections) = sess.run(
                        [boxes, scores, classes, num_detections],
                        feed_dict={image_tensor: image_np_expanded})
                    boxesList.append([boxes,xmin,ymin])
                    scoresList.append(scores)
                    classesList.append(classes)
                    # extractBox.extractBoxMessage(
                    #     RecognizeInfoList,
                    #     boxMessageList,
                    #     classNameList,
                    #     RecognizeInfo,
                    #     incisePictureWidth,
                    #     incisePictureHeight,
                    #     inciseXmin,
                    #     inciseYmin,
                    #     np.squeeze(boxes),
                    #     np.squeeze(classes).astype(np.int32),
                    #     np.squeeze(scores),
                    #     min_score_thresh=0.5
                    # )
    

      以及高效率不多次生成和关闭sess:

        def _detector(self,imageSerializedList,boxesList,scoresList,classesList):
            incisePictureWidth=self.beCheckedImageWidth
            incisePictureHeight=self.beCheckedImageHeight
            with self.detection_graph.as_default():
                with tf.Session(graph=self.detection_graph) as sess:
                    # Expand dimensions since the model expects images to have shape: [1, None, None, 3]
    
                    image_tensor = self.detection_graph.get_tensor_by_name('image_tensor:0')
                    # Each box represents a part of the image where a particular object was detected.
                    boxes = self.detection_graph.get_tensor_by_name('detection_boxes:0')
                    # Each score represent how level of confidence for each of the objects.
                    # Score is shown on the result image, together with the class label.
                    scores = self.detection_graph.get_tensor_by_name('detection_scores:0')
                    classes = self.detection_graph.get_tensor_by_name('detection_classes:0')
                    num_detections = self.detection_graph.get_tensor_by_name('num_detections:0')
                    # Actual detection.
                    for imageSerialized in imageSerializedList:
                        image_np_expanded = np.expand_dims(imageSerialized[0], axis=0)
                        (box, score, cla, num_detection) = sess.run(
                            [boxes, scores, classes, num_detections],
                             feed_dict={image_tensor: image_np_expanded})
                        boxesList.append([box,imageSerialized[1],imageSerialized[2]])
                        scoresList.append(score)
                        classesList.append(cla)
    

      

  • 相关阅读:
    Codeforces Round #678 (Div. 2)
    #Dijkstra#洛谷 4943 密室
    #线性基,点分治#洛谷 3292 [SCOI2016]幸运数字
    #线性基#LOJ 114 k大异或和
    #2-SAT,Tarjan,前缀优化建边#洛谷 6378 [PA2010]Riddle
    #树形dp,二次扫描换根法#洛谷 4284 [SHOI2014]概率充电器
    #dp#洛谷 5774 [JSOI2016]病毒感染
    #Tarjan,拓扑排序#洛谷 3436 [POI2006]PRO-Professor Szu
    #差分约束,Floyd#洛谷 2474 [SCOI2008]天平
    #Tarjan,SPFA,差分约束系统#BZOJ 2330 AcWing 368 银河
  • 原文地址:https://www.cnblogs.com/tangmiao/p/9111434.html
Copyright © 2011-2022 走看看