about summary refs log tree commit diff
path: root/pkgs/development/python-modules/open-clip-torch/default.nix
blob: 6de2c610fbf63f73424e7f3093cb794fe62c978f (plain) (blame)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{ lib
, stdenv
, buildPythonPackage
, braceexpand
, ftfy
, huggingface-hub
, pandas
, protobuf
, pytestCheckHook
, regex
, sentencepiece
, timm
, torch
, torchvision
, tqdm
, transformers
, setuptools
, webdataset
, wheel
, fetchFromGitHub
}:
buildPythonPackage rec {
  pname = "open-clip-torch";
  version = "2.24.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "mlfoundations";
    repo = "open_clip";
    rev = "refs/tags/v${version}";
    hash = "sha256-ugbXnXiOY9FrNvr8ZxnAgZO/SLCVoXbRgupi8cUwflU=";
  };

  nativeBuildInputs = [
    setuptools
    wheel
  ];

  propagatedBuildInputs = [
    ftfy
    huggingface-hub
    protobuf
    regex
    sentencepiece
    timm
    torch
    torchvision
    tqdm
  ];

  nativeCheckInputs = [
    pytestCheckHook
    braceexpand
    pandas
    transformers
    webdataset
  ];

  pythonImportsCheck = [ "open_clip" ];

  disabledTestPaths = lib.optionals (stdenv.isAarch64 || stdenv.isDarwin) [
    "tests/test_wds.py"
  ];

  disabledTests = [
    # requires network
    "test_download_pretrained_from_hfh"
    "test_inference_simple"
    "test_inference_with_data"
    "test_pretrained_text_encoder"
    "test_training_mt5"
  ] ++ lib.optionals (stdenv.isAarch64 && stdenv.isLinux) [
    "test_training"
    "test_training_coca"
    "test_training_unfreezing_vit"
    "test_training_clip_with_jit"
  ];

  meta = with lib; {
    description = "An open source implementation of CLIP";
    homepage = "https://github.com/mlfoundations/open_clip";
    license = licenses.asl20;
    maintainers = with maintainers; [ iynaix ];
    mainProgram = "open-clip";
  };
}