2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
2024-09-19 14:19:46 +00:00
|
|
|
fetchFromGitHub,
|
|
|
|
|
|
|
|
# build-system
|
|
|
|
pdm-backend,
|
|
|
|
|
|
|
|
# dependencies
|
2024-06-05 15:53:02 +00:00
|
|
|
ftfy,
|
|
|
|
huggingface-hub,
|
|
|
|
protobuf,
|
|
|
|
regex,
|
|
|
|
sentencepiece,
|
|
|
|
timm,
|
|
|
|
torch,
|
|
|
|
torchvision,
|
|
|
|
tqdm,
|
2024-09-19 14:19:46 +00:00
|
|
|
|
|
|
|
# checks
|
|
|
|
pytestCheckHook,
|
|
|
|
braceexpand,
|
|
|
|
pandas,
|
2024-06-05 15:53:02 +00:00
|
|
|
transformers,
|
|
|
|
webdataset,
|
2024-09-19 14:19:46 +00:00
|
|
|
|
|
|
|
stdenv,
|
2024-01-02 11:29:13 +00:00
|
|
|
}:
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "open-clip-torch";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "2.26.1";
|
2024-01-02 11:29:13 +00:00
|
|
|
pyproject = true;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "mlfoundations";
|
|
|
|
repo = "open_clip";
|
2024-01-13 08:15:51 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-XjPOsGet8VNzwEwzz14f1nF3XOgpkb4OERIc6VrDDZ8=";
|
2024-01-02 11:29:13 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
build-system = [ pdm-backend ];
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
dependencies = [
|
2024-01-02 11:29:13 +00:00
|
|
|
ftfy
|
|
|
|
huggingface-hub
|
|
|
|
protobuf
|
|
|
|
regex
|
|
|
|
sentencepiece
|
|
|
|
timm
|
|
|
|
torch
|
|
|
|
torchvision
|
|
|
|
tqdm
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeCheckInputs = [
|
|
|
|
pytestCheckHook
|
|
|
|
braceexpand
|
|
|
|
pandas
|
|
|
|
transformers
|
|
|
|
webdataset
|
|
|
|
];
|
|
|
|
|
|
|
|
pythonImportsCheck = [ "open_clip" ];
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
# -> On Darwin:
|
|
|
|
# AttributeError: Can't pickle local object 'build_params.<locals>.<lambda>'
|
|
|
|
# -> On Linux:
|
|
|
|
# KeyError: Caught KeyError in DataLoader worker process 0
|
|
|
|
disabledTestPaths = [ "tests/test_wds.py" ];
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
disabledTests =
|
|
|
|
[
|
|
|
|
# requires network
|
|
|
|
"test_download_pretrained_from_hfh"
|
|
|
|
"test_inference_simple"
|
|
|
|
"test_inference_with_data"
|
|
|
|
"test_pretrained_text_encoder"
|
|
|
|
"test_training_mt5"
|
|
|
|
# fails due to type errors
|
|
|
|
"test_num_shards"
|
|
|
|
]
|
|
|
|
++ lib.optionals (stdenv.isAarch64 && stdenv.isLinux) [
|
|
|
|
"test_training"
|
|
|
|
"test_training_coca"
|
|
|
|
"test_training_unfreezing_vit"
|
|
|
|
"test_training_clip_with_jit"
|
|
|
|
];
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
meta = {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Open source implementation of CLIP";
|
2024-01-02 11:29:13 +00:00
|
|
|
homepage = "https://github.com/mlfoundations/open_clip";
|
2024-09-19 14:19:46 +00:00
|
|
|
changelog = "https://github.com/mlfoundations/open_clip/releases/tag/v${version}";
|
|
|
|
license = lib.licenses.asl20;
|
|
|
|
maintainers = with lib.maintainers; [ iynaix ];
|
2024-01-02 11:29:13 +00:00
|
|
|
mainProgram = "open-clip";
|
2024-09-19 14:19:46 +00:00
|
|
|
# Segfaults during pythonImportsCheck phase
|
|
|
|
broken = stdenv.hostPlatform.system == "x86_64-darwin";
|
2024-01-02 11:29:13 +00:00
|
|
|
};
|
|
|
|
}
|