我正在尝试将PATH_DATASET替换为提取的数据集的根文件夹,该根文件夹为C / Users / swarn / hand-on-music-generation-with-magenta / lmd_full / a。但它显示错误为:
chapter_06_example_00.py:错误:需要以下参数:--path_dataset_dir = C / Users / swarn /带洋红色的音乐生成/ lmd_full / a,-path_output_dir / C / Users / swarn /带有洋红色的音乐生成手--bass_drums_on_beat_threshold = 0.75 发生异常,请使用%tb查看完整的追溯。
我对输入数据根文件夹的位置有错吗?
我来自github的部分代码:
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