Condtional_download how to for huggingface resources

How do I supply the credential for conditional_download for one of the asset in huggingface.

I am using google colabs

It seems it is trying to get this resource:

Below is the error and the code snap:

Traceback (most recent call last):
  File "/content/roop/", line 6, in <module>

urllib.error.HTTPError: HTTP Error 401: Unauthorized
def pre_check() -> bool:
    download_directory_path = resolve_relative_path('../models')
    conditional_download(download_directory_path, [''])
    return True

Seems to me like they’ve blocked api access through colab, perhaps it’s temporary. More information required to give a definitive answer

Did you find any solution to this error @ecstaticbliss ? i am also facing the same error.

Same error. I am using windows.

I realize it actually download the file from this website in one of the cell. And I just have to copy the cell into the folder which the code is looking for it and it works.

can you please tell which file and wich cell.

I’ve modified the function below, and download the file from this website

def conditional_download(download_directory_path: str, urls: List[str]) -> None:
    if not os.path.exists(download_directory_path):
    for url in urls:
        download_file_path = os.path.join(download_directory_path, os.path.basename(url))
        if not os.path.exists(download_file_path):
            # Check if the file exists at the specified source path
            source_path = '/onnx'
            if os.path.isfile(source_path):
                # If it exists, copy it to the download directory
                shutil.copy(source_path, download_file_path)
                print(f"Manually downloaded file copied to '{download_file_path}'")
                # If it doesn't exist, download it from the URL
                request = urllib.request.urlopen(url)
                total = int(request.headers.get('Content-Length', 0))
                with tqdm(total=total, desc='Downloading', unit='B', unit_scale=True, unit_divisor=1024) as progress:
                    urllib.request.urlretrieve(url, download_file_path, reporthook=lambda count, block_size, total_size: progress.update(block_size))
                print(f"File downloaded to '{download_file_path}'")