sumuzhao / CycleGAN-Music-Style-Transfer

Symbolic Music Genre Transfer with CycleGAN
MIT License
261 stars 66 forks source link

failed to interpret .midi file as a pickle #2

Closed wanshun123 closed 5 years ago

wanshun123 commented 5 years ago

When trying to train like the following:

python main.py --dataset_A_dir='Classic' --dataset_B_dir='Jazz' --type='cyclegan' --model='full' --sigma_d=1 --phase='train'

The code fails where it tries to load a .midi file as a numpy array in the load_npy_data() function (added print statements):

def load_npy_data(npy_data):
    print('printing npy_data for the load_npy_data function...') 
    print(npy_data)
    npy_A = np.load(npy_data[0]) * 1.
    npy_B = np.load(npy_data[1]) * 1.
    npy_AB = np.concatenate((npy_A.reshape(npy_A.shape[0], npy_A.shape[1], 1),
                             npy_B.reshape(npy_B.shape[0], npy_B.shape[1], 1)), axis=2)
    return npy_AB

As follows:

printing npy_data for the load_npy_data function...
('./datasets/Classic/train/WoO051 Sonatina 1-2 movs.mid', './datasets/Jazz/train/arrividerci_darling-1954-kar-1_jpp.mid')
Traceback (most recent call last):
  File "/home/paperspace/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py", line 428, in load
    return pickle.load(fid, **pickle_kwargs)
_pickle.UnpicklingError: could not find MARK

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 72, in <module>
    tf.app.run()
  File "/home/paperspace/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 126, in run
    _sys.exit(main(argv))
  File "main.py", line 64, in main
    model.train(args) if args.phase == 'train' else model.test(args)
  File "/home/paperspace/music/CycleGAN-Music-Style-Transfer/model.py", line 242, in train
    batch_images = [load_npy_data(batch_file) for batch_file in batch_files]
  File "/home/paperspace/music/CycleGAN-Music-Style-Transfer/model.py", line 242, in <listcomp>
    batch_images = [load_npy_data(batch_file) for batch_file in batch_files]
  File "/home/paperspace/music/CycleGAN-Music-Style-Transfer/utils.py", line 101, in load_npy_data
    npy_A = np.load(npy_data[0]) * 1.
  File "/home/paperspace/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py", line 431, in load
    "Failed to interpret file %s as a pickle" % repr(file))
OSError: Failed to interpret file './datasets/Classic/train/WoO051 Sonatina 1-2 movs.mid' as a pickle
sumuzhao commented 5 years ago

I think the problem is the datasets you feed. Please take a look at datasets part in ReadMe.

dedededefo commented 1 year ago

我认为问题在于您提供的数据集。请查看自述文件中的数据集部分。

Hello, I think the convert used in the second step of data preprocessing_ There is a problem with the converter function in clean.py. It cannot implement the function when installing the package you specified