File size: 1,293 Bytes
ea35075 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import pathlib
import requests
try:
root_path = pathlib.Path(__file__).resolve().parents[0]
except NameError:
import inspect
root_path = pathlib.Path(inspect.getfile(lambda: None)).resolve().parents[0]
def download(url: str, dest: pathlib.Path):
try:
with requests.get(url, stream=True) as r:
with open(dest, "wb") as f:
for chunk in r.iter_content(chunk_size=1024):
f.write(chunk)
except requests.exceptions.RequestException as e:
print(e)
def main():
MEDIAPIPE_POSE_VERSION = "0.5.1675469404"
mediapipe_dir = root_path / "downloads" / "pose" / MEDIAPIPE_POSE_VERSION
mediapipe_dir.mkdir(mode=0o755, parents=True, exist_ok=True)
for file_name in [
"pose_landmark_full.tflite",
"pose_web.binarypb",
"pose_solution_packed_assets.data",
"pose_solution_simd_wasm_bin.wasm",
"pose_solution_packed_assets_loader.js",
"pose_solution_simd_wasm_bin.js",
]:
file_path = mediapipe_dir / file_name
if file_path.exists():
continue
url = f"https://cdn.jsdelivr.net/npm/@mediapipe/pose@{MEDIAPIPE_POSE_VERSION}/{file_name}"
print(f"Downloading {file_name}...")
download(url, file_path)
main()
|