mirror of
https://github.com/NanjingForestryUniversity/supermachine--tomato-passion_fruit.git
synced 2025-11-09 06:44:02 +00:00
fix:修复在20240627test4中的classifier.py的analyze_tomato函数中white_defect的函数忘记传递两个阈值量的错误;修复analyze_tomato函数中的叶片实例分割存在的问题,解决由于变量污染引起的分割错误;
28 lines
1015 B
Python
28 lines
1015 B
Python
# -*- coding: utf-8 -*-
|
|
# @Time : 2024/7/14 下午5:11
|
|
# @Author : TG
|
|
# @File : imgcopy.py
|
|
# @Software: PyCharm
|
|
import os
|
|
import shutil
|
|
|
|
def copy_images_recursively(source_folder, target_folder):
|
|
# 遍历源文件夹中的所有内容
|
|
for item in os.listdir(source_folder):
|
|
item_path = os.path.join(source_folder, item)
|
|
if os.path.isdir(item_path):
|
|
# 如果是文件夹,递归调用当前函数
|
|
copy_images_recursively(item_path, target_folder)
|
|
elif item.lower().endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif')):
|
|
# 如果是图片文件,则复制到目标文件夹
|
|
shutil.copy(item_path, target_folder)
|
|
print(f"Copied {item_path} to {target_folder}")
|
|
|
|
# 源文件夹路径
|
|
source_folder = r'D:\project\20240714Actual_deployed\20240718test\T'
|
|
# 目标文件夹路径
|
|
target_folder = r'D:\project\20240714Actual_deployed\20240718test\01img'
|
|
|
|
# 调用函数
|
|
copy_images_recursively(source_folder, target_folder)
|