Condtional_download how to for huggingface resources
GitHubGitHub - s0md3v/roop: one-click face swapone-click face swap. Contribute to s0md3v/roop development by creating an account on GitHub.How do I supply the credential for conditional_download  for one of the asset in huggingface.I am using google colabsIt seems it is trying to get this resource:https://huggingface.co/deepinsight/inswapper/resolve/main/inswapper_128.onnxBelow is the error and the code snap:Traceback (most recent call last):
  File "/content/roop/run.py", line 6, in <module>
    core.run()
['https://huggingface.co/deepinsight/inswapper/resolve/main/inswapper_128.onnx'])

urllib.error.HTTPError: HTTP Error 401: Unauthorizeddef pre_check() -> bool:
    download_directory_path = resolve_relative_path('../models')
    conditional_download(download_directory_path, ['https://huggingface.co/deepinsight/inswapper/resolve/main/inswapper_128.onnx'])
    return True
2023-08-23T22:11:35Z
Seems to me like they’ve blocked api access through colab, perhaps it’s temporary. More information required to give a definitive answer
2023-08-29T10:13:28Z
Did you find any solution to this error@ecstaticbliss? i am also facing the same error.
2023-08-29T11:39:57Z
Same error. I am using windows.
2023-09-01T07:59:24Z
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.
2023-09-02T08:20:08Z
can you please tell which file and wich cell.
2023-09-19T07:40:44Z
I’ve modified the function below, and download the file from this websitedef conditional_download(download_directory_path: str, urls: List[str]) -> None:
    if not os.path.exists(download_directory_path):
        os.makedirs(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}'")
            else:
                # 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}'")