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.
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):
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}'")