Python 3.x “错误”;以下参数是必需的--路径数据集目录=
我试图用提取的数据集的根文件夹替换PATH_数据集,该数据集是C/Users/swarn/hands-on-music generation with-magenta/lmd_-full/a。但它将错误显示为: 第06章示例:错误:需要以下参数:--path\u dataset\u dir=C/Users/swarn/hands-on-music generation with洋红/lmd\u full/a,-path\u output\u dir/C/Users/swarn/hands-on-on-music generation with洋红,-低音鼓\u-on-beat\u threshold=0.75 发生异常,请使用%tb查看完整回溯 关于输入数据根文件夹位置,我是否做错了什么 我的github部分代码:Python 3.x “错误”;以下参数是必需的--路径数据集目录=,python-3.x,magenta,Python 3.x,Magenta,我试图用提取的数据集的根文件夹替换PATH_数据集,该数据集是C/Users/swarn/hands-on-music generation with-magenta/lmd_-full/a。但它将错误显示为: 第06章示例:错误:需要以下参数:--path\u dataset\u dir=C/Users/swarn/hands-on-music generation with洋红/lmd\u full/a,-path\u output\u dir/C/Users/swarn/hands-on-
enter code here
parser = argparse.ArgumentParser()
parser.add_argument("--sample_size", type=int, default=1000)
parser.add_argument("--pool_size", type=int, default=4)
parser.add_argument("--path_dataset_dir = C/Users/swarn/ hands-on-music-generation-with-magenta/lmd_full/a", type=str, required=True)
parser.add_argument("--path_output_dir /C/Users/swarn/hands-on-music-generation-with-magenta", type=str, required=True)
parser.add_argument("--bass_drums_on_beat_threshold = 0.75",
type=float, required=True, default=0)
args = parser.parse_args()
# The list of all MIDI paths on disk (we might process only a sample)
MIDI_PATHS = glob.glob(os.path.join(args.path_dataset_dir, "**", "*.mid"),
recursive=True)
def process(midi_path: str, counter: AtomicCounter) -> Optional[dict]:
try:
pm_drums = extract_drums(midi_path)
bass_drums_on_beat = get_bass_drums_on_beat(pm_drums)
if bass_drums_on_beat >= args.bass_drums_on_beat_threshold:
midi_filename = os.path.basename(midi_path)
pm_drums.write(os.path.join(args.path_output_dir, f"{midi_filename}.mid"))
else:
raise Exception(f"Not on beat {midi_path}: {bass_drums_on_beat}")
return {"midi_path": midi_path,
"pm_drums": pm_drums,
"bass_drums_on_beat": bass_drums_on_beat}
except Exception as e:
if "Not on beat" not in str(e):
print(f"Exception during processing of {midi_path}: {e}")
finally:
counter.increment()
def app(midi_paths: List[str]):
start = timeit.default_timer()
if __name__ == "__main__":
if args.sample_size:
# Process a sample of it
MIDI_PATHS_SAMPLE = random.sample(list(MIDI_PATHS), args.sample_size)
else:
# Process all the dataset
MIDI_PATHS_SAMPLE = list(MIDI_PATHS)
app(MIDI_PATHS_SAMPLE)
enter code here