INNER CODE UNIT · Python
download
fofr/cog-face-to-sticker · weights_downloader.py:42
def download(self, weight_str, url, dest):
if "/" in weight_str:
subfolder = weight_str.rsplit("/", 1)[0]
dest = os.path.join(dest, subfolder)
os.makedirs(dest, exist_ok=True)
print(f"⏳ Downloading {weight_str} to {dest}")
start = time.time()
subprocess.check_call(
["pget", "--log-level", "warn", "-xf", url, dest], close_fds=False
)
elapsed_time = time.time() - start
try:
file_size_bytes = os.path.getsize(
os.path.join(dest, os.path.basename(weight_str))
)
file_size_megabytes = file_size_bytes / (1024 * 1024)
print(