| |
| import argparse |
| import subprocess |
| import sys |
|
|
|
|
| def run_command(command, dry_run=False): |
| print("+ " + " ".join(command), flush=True) |
| if dry_run: |
| return |
| subprocess.run(command, check=True) |
|
|
|
|
| def install_torch(dry_run=False): |
| run_command( |
| [ |
| sys.executable, |
| "-m", |
| "pip", |
| "install", |
| "torch==2.11.0", |
| "torchvision==0.26.0", |
| "torchaudio==2.11.0", |
| "--index-url", |
| "https://download.pytorch.org/whl/cu130", |
| ], |
| dry_run=dry_run, |
| ) |
|
|
|
|
| def install_natten(dry_run=False): |
| run_command( |
| [ |
| sys.executable, |
| "-m", |
| "pip", |
| "install", |
| "natten==0.21.6+torch2110cu130", |
| "-f", |
| "https://whl.natten.org", |
| ], |
| dry_run=dry_run, |
| ) |
|
|
|
|
| def install_common_packages(dry_run=False): |
| run_command( |
| [ |
| sys.executable, |
| "-m", |
| "pip", |
| "install", |
| "albumentations", |
| "kornia", |
| "timm", |
| "google-api-python-client", |
| "google-api-core", |
| ], |
| dry_run=dry_run, |
| ) |
|
|
|
|
| def parse_args(): |
| parser = argparse.ArgumentParser(description="Install packages needed for Varroa LMNet detection experiments.") |
| parser.add_argument("--skip-torch", action="store_true", help="Skip torch/torchvision/torchaudio install.") |
| parser.add_argument("--skip-natten", action="store_true", help="Skip NATTEN wheel install.") |
| parser.add_argument("--skip-common", action="store_true", help="Skip albumentations/kornia/timm install.") |
| parser.add_argument("--dry-run", action="store_true", help="Print pip commands without running them.") |
| return parser.parse_args() |
|
|
|
|
| def main(): |
| args = parse_args() |
| if not args.skip_torch: |
| install_torch(dry_run=args.dry_run) |
| if not args.skip_natten: |
| install_natten(dry_run=args.dry_run) |
| if not args.skip_common: |
| install_common_packages(dry_run=args.dry_run) |
| print("Done. Restart the notebook/kernel after installing binary packages such as NATTEN.", flush=True) |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|