def main(): config = Config() # 关系图中包括(include)哪些函数名。 #如果是某一类的函数,例如类gobang,则可以直接写'gobang.*',表示以gobang.开头的所有函数。(利用正则表达式)。 config.trace_filter = GlobbingFilter(include=[ 'main', 'pycallgraph.*', '*.secret_function', ]) graphviz = GraphvizOutput() graphviz.output_file = 'basic.png' #图片名称 with PyCallGraph(output=graphviz): # coco modelpath = "model/" start = time.time() pose_model = general_coco_model(modelpath) # 1.加载模型 print("[INFO]Pose Model loads time: ", time.time() - start) # yolo start = time.time() _yolo = YOLO() # 1.加载模型 print("[INFO]yolo Model loads time: ", time.time() - start) img_path = 'D:/myworkspace/dataset/My_test/img/a_img/airplane_30.jpg' getImgInfo(img_path, pose_model, _yolo)
def _learning_hand(self, event): start = time.time() info, lineimage = getImgInfo(self.orgin_img_show, self.pose_model, self._yolo, '') self.XX_test.append(info) self.tips.AppendText(u"特征提取耗时:{:.2f} s".format(time.time() - start) + "\n") lineimage = cv2.resize( lineimage, (600, 500), ) height, width = lineimage.shape[:2] image1 = cv2.cvtColor( lineimage, cv2.COLOR_BGR2RGB ) # opencv中imread的图片内部是BGR排序,wxPython的StaticBitmap需要的图片是RGB排序,不转换会出现颜色变换 pic = wx.Bitmap.FromBuffer(width, height, image1) # 显示图片在panel上: self.result_img.SetBitmap(pic) self.tips.AppendText(u"数字特征:" + str(info) + "\n")
# ---------------------------------------------------------------------------------- # 第二步 识别infolist # ---------------------------------------------------------------------------------- # coco modelpath = "model/" start = time.time() pose_model = general_coco_model(modelpath) # 1.加载模型 print("[INFO]Pose Model loads time: ", time.time() - start) # yolo start = time.time() _yolo = YOLO() # 1.加载模型 print("[INFO]yolo Model loads time: ", time.time() - start) infolist = [] for i in X: hist = getImgInfo(i, pose_model, _yolo) # 识别 infolist.append(hist) # ---------------------------------------------------------------------------------- # 第三步 存储信息docs/feature/features_all.csv # ---------------------------------------------------------------------------------- # 路径存储到txt orb = open('D:/myworkspace/dataset/My_test/bagofwords/y_train.txt', 'w') for i, img_path in enumerate(X): orb.write(img_path) #orb.write('\n'+str(info)+str(infolist[i])) orb.close() # 特征存储到 csv with open("docs/feature/features_all.csv", "w", newline="") as csvfile: writer = csv.writer(csvfile)
from pose.coco import general_coco_model # coco modelpath = "model/" start = time.time() pose_model = general_coco_model(modelpath) # 1.加载模型 print("[INFO]Pose Model loads time: ", time.time() - start) # yolo start = time.time() _yolo = YOLO() # 1.加载模型 print("[INFO]yolo Model loads time: ", time.time() - start) path = "D:/myworkspace/JupyterNotebook/hand-keras-yolo3-recognize/docs/wangyu_hand_img/" X_test = [path + "movehouse_37.jpg", path + "movehouse_65.jpg"] # 测试集 XX_test = [] for i in X_test: image = cv2.imread(i) hist, _ = getImgInfo(image, pose_model, _yolo) XX_test.append(hist) clf = joblib.load("model/train_model.pkl") predictions_labels = clf.predict(XX_test) # 使用测试集预测结果 print(u'预测结果:') print(predictions_labels)