Python 用于分类的图像转换器
我正在尝试转换图像进行分类,但找不到解决方案 实际代码转换一张图片,而不是整个文件夹。是否有任何解决方案可以读取文件夹“images”中的所有图像,并将其转换为具有骨架结构的文件夹“output” 非常感谢 亚历山大Python 用于分类的图像转换器,python,tensorflow,opencv,computer-vision,Python,Tensorflow,Opencv,Computer Vision,我正在尝试转换图像进行分类,但找不到解决方案 实际代码转换一张图片,而不是整个文件夹。是否有任何解决方案可以读取文件夹“images”中的所有图像,并将其转换为具有骨架结构的文件夹“output” 非常感谢 亚历山大 import logging import time import os import cv2 import numpy as np from tf_pose.estimator import TfPoseEstimator from tf_pose.networks impor
import logging
import time
import os
import cv2
import numpy as np
from tf_pose.estimator import TfPoseEstimator
from tf_pose.networks import get_graph_path, model_wh
import scripts.label_image as label_img
import scripts.label_image_scene as label_img_scene
logger = logging.getLogger('Pose_Action_and_Scene_Understanding')
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('[%(asctime)s] [%(name)s] [%(levelname)s] %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
fps_time = 0
address = os.getcwd()
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='tf-classification')
parser.add_argument('--image', type=str, required=True)
parser.add_argument('--show-process', type=bool, default=False,
help='for debug purpose, if enabled, speed for inference is dropped.')
args = parser.parse_args()
logger.debug('initialization %s : %s' % ('mobilenet_thin', get_graph_path('mobilenet_thin')))
e = TfPoseEstimator(get_graph_path('mobilenet_thin'), target_size=(432, 368))
image = cv2.imread(args.image)
logger.info('cam image=%dx%d' % (image.shape[1], image.shape[0]))
logger.debug('+image processing+')
logger.debug('+postprocessing+')
start_time = time.time()
humans = e.inference(image, upsample_size=4.0)
img = TfPoseEstimator.draw_humans(image, humans, imgcopy=False)
logger.debug('+classification+')
# Getting only the skeletal structure (with white background) of the actual image
image = np.zeros(image.shape,dtype=np.uint8)
image.fill(255)
image = TfPoseEstimator.draw_humans(image, humans, imgcopy=False)
cv2.imwrite('show1.png',image)
cv2.imshow('tf-classification', image)
cv2.waitKey(0)
logger.debug('+finished+')
cv2.destroyAllWindows()
根据数据的组织方式,可以使用ImageDataGenerator来增强图像。然后使用目录中的.flow或.flow\u将转换后的图像保存到指定的目录中。文件是