| 25 | |
| 26 | |
| 27 | def download_weights(url: str, dest: str) -> None: |
| 28 | # NOTE WHEN YOU EXTRACT SPECIFY THE PARENT FOLDER |
| 29 | start = time.time() |
| 30 | print("[!] Initiating download from URL: ", url) |
| 31 | print("[~] Destination path: ", dest) |
| 32 | if ".tar" in dest: |
| 33 | dest = os.path.dirname(dest) |
| 34 | command = ["pget", "-vf" + ("x" if ".tar" in url else ""), url, dest] |
| 35 | try: |
| 36 | print(f"[~] Running command: {' '.join(command)}") |
| 37 | subprocess.check_call(command, close_fds=False) |
| 38 | except subprocess.CalledProcessError as e: |
| 39 | print( |
| 40 | f"[ERROR] Failed to download weights. Command '{' '.join(e.cmd)}' returned non-zero exit status {e.returncode}." |
| 41 | ) |
| 42 | raise |
| 43 | print("[+] Download completed in: ", time.time() - start, "seconds") |
| 44 | |
| 45 | |
| 46 | class Predictor(BasePredictor): |