标题:win10下运行目录名称无效
取消只看楼主
情义控灬浮云
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2017-8-3
结帖率:80.95%
 问题点数:0 回复次数:2 
win10下运行目录名称无效
机器学习&python小白,想问下这里的目录问题怎么解决,目录看着是对的啊,到底是哪错了呢?

程序代码:
#! /usr/bin/python
import os
from PIL import Image

def crop_img_by_half_center(src_file_path, dest_file_path):
    im = Image.open(src_file_path)
    x_size, y_size = im.size
    start_point_xy = x_size / 4
    end_point_xy   = x_size / 4 + x_size / 2
    box = (start_point_xy, start_point_xy, end_point_xy, end_point_xy)
    new_im = im.crop(box)
    new_new_im = new_im.resize((47,55))
    new_new_im.save(dest_file_path)

def walk_through_the_folder_for_crop(aligned_db_folder, result_folder):
    if not os.path.exists(result_folder):
        os.mkdir(result_folder)
    
    i = 0
    img_count = 0
    for people_folder in os.listdir(aligned_db_folder):
        src_people_path = aligned_db_folder + people_folder + '/'
        dest_people_path = result_folder + people_folder + '/'
        if not os.path.exists(dest_people_path):
            os.mkdir(dest_people_path)
        for video_folder in os.listdir(src_people_path):
            src_video_path = src_people_path + video_folder + '/'
            dest_video_path = dest_people_path + video_folder + '/'
            if not os.path.exists(dest_video_path):
                os.mkdir(dest_video_path)
            for img_file in os.listdir(src_video_path):
                src_img_path = src_video_path + img_file
                dest_img_path = dest_video_path + img_file
                crop_img_by_half_center(src_img_path, dest_img_path)
            i += 1
            img_count += len(os.listdir(src_video_path))
        
if __name__ == '__main__':
    aligned_db_folder = r"D:\master\DeepID1-master\data\Facedata"
    result_folder = r"data/crop_Facedata"
    if not aligned_db_folder.endswith('/'):
        aligned_db_folder += '/'      
    if not result_folder.endswith('/'):
        result_folder += '/'
    walk_through_the_folder_for_crop(aligned_db_folder, result_folder)
    
搜索更多相关主题的帖子: not win10 if for path 
2020-08-14 21:39
情义控灬浮云
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2017-8-3
得分:0 
回复 2楼 古123
不好意思 现在才看到 请问这个要怎么加呢  python我刚开始学 不太懂..
2020-08-23 15:21
情义控灬浮云
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2017-8-3
得分:0 
回复 4楼 古123
好的 谢谢
2020-08-28 10:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-502861-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.172583 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved