英文:
Can't figure out the error "Exception: Please create folder structure: dataset"
问题
I've translated the content you provided:
"我最近在寻找一些资源来进行我的团队项目时,偶然发现了这个Musical-Notes-Recognition-CNN的GitHub仓库(https://github.com/alexbajzat/Musical-Notes-Recognition-CNN)。
我尝试在我的VSCode上运行它,但遇到了一个错误,错误信息为“异常:请创建文件夹结构:dataset”。
我尝试在命令提示符上使用'mkdir'命令创建一个名为'dataset'的文件夹,考虑了每种可能的情况,但仍然出现了相同的错误。
我附上了main.py和错误信息的图片。
import os
from src.data.constants import LayerType
# ...(以下省略,代码部分不进行翻译)
checkSystem()
train()
1: https://i.stack.imgur.com/9sfNb.png"
This is the translated content without the code.
英文:
I've recently come across this Musical-Notes-Recognition-CNN github repository(https://github.com/alexbajzat/Musical-Notes-Recognition-CNN) while I was searching for some resources for my team project.
I tried to run it on my VSCode but I encountered an error saying "Exception: Please create folder structure: dataset"
I've tried 'mkdir' command on my command prompt to make a folder named 'dataset' considering every single scenario but it is making the same error.
I've attached the main.py and image of what the error looks like.
import os
from src.data.constants import LayerType
from src.data.setup import initDataset, batch, Constants
from src.model.classifiers import SoftMax
from src.model.hyper_params import HyperParams
from src.model.layers_builder import LayersBuilder
from src.neural_model import Model
from src.utils.processing import parseJSON
MANDATORY_FOLDERS = ['dataset', 'requests']
GENERABLE_FOLDES = ['history', 'model-data', 'features']
def constructModel(requestJSON, data):
request = parseJSON(requestJSON)
layersBuilder = LayersBuilder()
trainingDataset, validatingDataset, inputDims, batchSize = batch(data, request.model.training_params.batch_size)
hyperParams = HyperParams(request.model.training_params.step_size, request.model.training_params.filter_step_size,
request.model.training_params.regularization)
iterations = request.model.training_params.iterations
number_of_classes = request.model.training_params.number_of_classes
for layer in request.model.layers:
layersBuilder.addLayer((LayerType[layer.layer_type], layer.params))
# build layers and model
constructed = layersBuilder.build(hyperParams, inputDims, request.model.training_params.hidden_layer_size, number_of_classes)
return Model(constructed, SoftMax(hyperParams), batchSize, iterations=iterations,
modelConfig=requestJSON), trainingDataset, validatingDataset
def doTheStuff(data, requestJSON):
model, trainingData, validationData = constructModel(requestJSON, data)
print("\n --- START TRAINING --- \n")
# model getting trained
model.train(trainingData, validationData)
return model
def train():
displayAvailableRequests()
req = input('\nRequest name: ')
file = open(Constants.REQUESTS_ROOT + '/' + req)
data = initDataset()
doTheStuff(data, file.read())
def displayAvailableRequests():
print('\nRequests: ')
for filename in os.listdir(Constants.REQUESTS_ROOT):
print(filename, '\n')
def checkSystem():
print('Checking system...')
for folder in MANDATORY_FOLDERS:
if (not os.path.exists(Constants.ROOT + '/' + folder)):
raise Exception('Please create folder structure: ' + folder)
for folder in GENERABLE_FOLDES:
url = Constants.ROOT + '/' + folder
if (not os.path.exists(url)):
os.mkdir(url)
print('System check done successfully')
checkSystem()
train()
答案1
得分: 1
- 我不确定
Constants.Root
是什么。我认为它是你在某个配置文件中存储的路径。 - 我已将当前工作目录用作路径,我只是按照
GENERABLE_FOLDERS
相同的方法,即如果不存在则创建目录。您可以查看下面的代码。 - 代码
import os
root_path = os.getcwd()
def checkSystem():
print('Checking system...')
for folder in MANDATORY_FOLDERS:
mandatory_folder_path = root_path + os.sep + folder
if not os.path.exists(mandatory_folder_path):
os.makedirs(mandatory_folder_path)
for folder in GENERABLE_FOLDERS:
general_folder_path = root_path + os.sep + folder
if not os.path.exists(general_folder_path):
os.mkdir(general_folder_path)
print('System check done successfully')
英文:
- I am not sure about the
Constants.Root
. I think it is some kind of path that you have stored in some configuration or file. - I have used the current working directory as path, i have just followed the same approach as
GENERABLE_FOLDES
i.e. creating the directory if not present. You can check the code below. - Code
import os
root_path = os.getcwd()
def checkSystem():
print('Checking system...')
for folder in MANDATORY_FOLDERS:
mandatory_folder_path = root_path + os.sep + folder
if (not os.path.exists(mandatory_folder_path)):
os.makedirs(mandatory_folder_path)
for folder in GENERABLE_FOLDES:
general_folder_path = root_path + os.sep + folder
if (not os.path.exists(general_folder_path)):
os.mkdir(general_folder_path)
print('System check done successfully')
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论