import os from os.path import join, abspath from glob import glob import subprocess import argparse config_mapping = { "new-metrics-exp-23" : "./config/tf_effnet_v2_s_in21k.yaml", } import shutil def copytree(src, dst, symlinks=False, ignore=None):
时间: 2024-04-09 09:27:08 浏览: 103
def copytree(src, dst, symlinks=False, ignore=None):
"""
Recursively copy a directory tree.
Args:
src (str): Source directory path.
dst (str): Destination directory path.
symlinks (bool, optional): If True, copy symbolic links as symbolic links.
ignore (callable, optional): A function that takes a directory name and filenames as arguments
and returns a list of filenames to ignore.
"""
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)
相关问题
import cv2 from PIL import Image from Nets.mobileNet import MobileNetV1 as Net from torch.utils.data import DataLoader from torchvision import transforms from torchvision.datasets import ImageFolder import os import torch PROJECT_PATH = os.path.abspath( os.path.join(os.path.abspath(os.path.dirname(__file__)), os.pardir)) # 训练数据集 DATA_TRAIN = os.path.join(PROJECT_PATH, "MechineLearning/trainSet") # 模型保存地址 DATA_MODEL = os.path.join(PROJECT_PATH, "MechineLearning/model/alexNet.pth") DEVICE = torch.device("cuda") 将这段代码改成只用使用cpu的代码
import cv2
from PIL import Image
from Nets.mobileNet import MobileNetV1 as Net
from torch.utils.data import DataLoader
from torchvision import transforms
from torchvision.datasets import ImageFolder
import os
import torch
PROJECT_PATH = os.path.abspath(
os.path.join(os.path.abspath(os.path.dirname(__file__)), os.pardir))
# 训练数据集
DATA_TRAIN = os.path.join(PROJECT_PATH, "MechineLearning/trainSet")
# 模型保存地址
DATA_MODEL = os.path.join(PROJECT_PATH, "MechineLearning/model/alexNet.pth")
DEVICE = torch.device("cpu") # 将设备改为cpu
注意,这只是将设备更改为CPU,可能需要根据你的代码的具体情况进行其他更改。
curr_dir = os.path.dirname(os.path.abspath(__file__)) import_path = os.path.join(curr_dir, '..', '..', '..') sys.path.insert(0, import_path) import racing_utils
这段代码的作用是将所在文件夹的路径以及其上两级目录的路径添加到系统路径中,并且导入名为`racing_utils`的模块。具体来说,`os.path.dirname(os.path.abspath(__file__))`可以获取当前文件所在文件夹的绝对路径,`os.path.join(curr_dir, '..', '..', '..')`将其上两级目录的路径与当前路径拼接起来,`sys.path.insert(0, import_path)`将拼接后的路径添加到系统路径中,使得Python可以在这些路径下搜索到需要导入的模块。最后,`import racing_utils`导入了名为`racing_utils`的模块,该模块包含一些用于处理赛车游戏数据的工具函数。
阅读全文