sigsep / open-unmix-pytorch

Open-Unmix - Music Source Separation for PyTorch
https://sigsep.github.io/open-unmix/
MIT License
1.24k stars 181 forks source link

Cannot download 'umx' or 'umxhq' model #138

Closed frankenjoe closed 5 months ago

frankenjoe commented 6 months ago

🐛 Bug

Downloading 'umx' or 'umxhq' model fails with 403 Forbidden Error.

To Reproduce

Steps to reproduce the behavior:

$ umx --model umx <file>
Downloading: "https://zenodo.org/api/files/1c8f83c5-33a5-4f59-b109-721fdd234875/vocals-b62c91ce.pth"
...
urllib.error.HTTPError: HTTP Error 403: FORBIDDEN

Also fails for 'umxhq' model, but works with 'umxl' and 'umxse'.

Expected behavior

Download the requested model to cache.

Environment

HarryHe11 commented 6 months ago

meet this error too, did you found solution?

frankenjoe commented 6 months ago

nope

jal3inc commented 5 months ago

@frankenjoe I downloaded the files manually with a script. I am using docker so I mount them. - ./checkpoints:/root/.cache/torch/hub/checkpoints/ However I'd imagine you want your's at /root/.cache/torch/hub/checkpoints/. Adjust to your needs but below works for me. Record 3370489 is for UMX-HQ youu can visit in your browser and see whats there. https://zenodo.org/records/3370489. I couldn't get the api access token to work with open-unmix-pytorch so this is my quick and dirty solution. If it works, it can't be wrong... Good Luck

import os
import requests

def create_checkpoints_folder():
    checkpoints_dir = 'checkpoints'
    if not os.path.exists(checkpoints_dir):
        os.makedirs(checkpoints_dir)
    return os.path.abspath(checkpoints_dir)

def download_file(url, filename, checkpoints_folder):
    filepath = os.path.join(checkpoints_folder, filename)
    if os.path.exists(filepath):
        print(f"File '{filename}' already exists. Skipping...")
        return

    response = requests.get(url, stream=True)

    if response.status_code == 200:
        with open(filepath, 'wb') as f:
            for chunk in response.iter_content(chunk_size=128):
                f.write(chunk)
        print(f"Download completed successfully: {filepath}")
    else:
        print(f"Failed to download the file: {filename}. Status code: {response.status_code}")

if __name__ == "__main__":
    checkpoints_folder = create_checkpoints_folder()

    record_id = '3370489'
    record_url = f'https://zenodo.org/api/records/{record_id}'

    # Get all files available for download in the record
    response = requests.get(record_url)
    if response.status_code == 200:
        files_info = response.json().get('files', [])
        for file_info in files_info:
            filename = file_info.get('key')
            download_url = file_info.get('links', {}).get('self')
            if filename and download_url:
                download_file(download_url, filename, checkpoints_folder)
            else:
                print("Invalid file information found.")
    else:
        print(f"Failed to fetch record information. Status code: {response.status_code}")
frankenjoe commented 5 months ago

@jal3inc Thanks a lot for pointing me to the original source of those "missing" models. I manually downloaded them to the cache folder and now it works. Until the authors fix the code this is indeed a workaround.

faroit commented 5 months ago

@frankenjoe @jal3inc thanks for spotting this. It seems that zenodo has changed the access api slightly? Does anyone of you happen to know how to get the static links? if not i guess we would have to move the files to github releases....

frankenjoe commented 5 months ago

As suggested by @jal3inc you could use https://zenodo.org/records/3370489/files/vocals-b62c91ce.pth, etc. Those links should be permanent.