1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 6 # build-system 7 pdm-backend, 8 9 # dependencies 10 ftfy, 11 huggingface-hub, 12 protobuf, 13 regex, 14 safetensors, 15 sentencepiece, 16 timm, 17 torch, 18 torchvision, 19 tqdm, 20 21 # checks 22 pytestCheckHook, 23 braceexpand, 24 pandas, 25 transformers, 26 webdataset, 27}: 28buildPythonPackage rec { 29 pname = "open-clip-torch"; 30 version = "3.2.0"; 31 pyproject = true; 32 33 src = fetchFromGitHub { 34 owner = "mlfoundations"; 35 repo = "open_clip"; 36 tag = "v${version}"; 37 hash = "sha256-k4/u0XtfBmPSVKfEK3wHqJXtKAuUNkUnk1TLG2S6PPs="; 38 }; 39 40 build-system = [ pdm-backend ]; 41 42 dependencies = [ 43 ftfy 44 huggingface-hub 45 protobuf 46 regex 47 safetensors 48 sentencepiece 49 timm 50 torch 51 torchvision 52 tqdm 53 ]; 54 55 nativeCheckInputs = [ 56 pytestCheckHook 57 braceexpand 58 pandas 59 transformers 60 webdataset 61 ]; 62 63 pythonImportsCheck = [ "open_clip" ]; 64 65 # -> On Darwin: 66 # AttributeError: Can't pickle local object 'build_params.<locals>.<lambda>' 67 # -> On Linux: 68 # KeyError: Caught KeyError in DataLoader worker process 0 69 disabledTestPaths = [ "tests/test_wds.py" ]; 70 71 disabledTests = [ 72 # requires network 73 "test_download_pretrained_from_hfh" 74 "test_inference_simple" 75 "test_inference_with_data" 76 "test_pretrained_text_encoder" 77 "test_training_mt5" 78 79 # fails due to type errors 80 "test_num_shards" 81 82 # hangs forever 83 "test_training" 84 ]; 85 86 meta = { 87 description = "Open source implementation of CLIP"; 88 homepage = "https://github.com/mlfoundations/open_clip"; 89 changelog = "https://github.com/mlfoundations/open_clip/releases/tag/${src.tag}"; 90 license = lib.licenses.asl20; 91 maintainers = with lib.maintainers; [ iynaix ]; 92 mainProgram = "open-clip"; 93 }; 94}