Kamlesh21/preprocessing-lab
0
1"""Download model weights once so the demo runs offline: ResNet50 (torchvision, V1 weights) and YOLO11s-seg."""2 3import os4import urllib.request5from pathlib import Path6 7WEIGHTS = Path(__file__).resolve().parents[1] / "weights"8YOLO_URL = "https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s-seg.pt"9 10 11def main() -> None:12 WEIGHTS.mkdir(exist_ok=True)13 os.environ.setdefault("TORCH_HOME", str(WEIGHTS / "torch"))14 from torchvision.models import ResNet50_Weights, resnet5015 16 # V1, not V2: V2 was trained with label smoothing, so even correct answers show only 30-50% confidence.17 resnet50(weights=ResNet50_Weights.IMAGENET1K_V1)18 print("resnet50 ok")19 target = WEIGHTS / "yolo11s-seg.pt"20 if not target.exists():21 urllib.request.urlretrieve(YOLO_URL, target)22 print("yolo11s-seg ok", target.stat().st_size, "bytes")23 24 25if __name__ == "__main__":26 main()27 