1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchFromGitHub,
6 pdm-backend,
7 huggingface-hub,
8 pyyaml,
9 safetensors,
10 torch,
11 torchvision,
12 expecttest,
13 pytestCheckHook,
14 pytest-timeout,
15}:
16
17buildPythonPackage rec {
18 pname = "timm";
19 version = "1.0.3";
20 pyproject = true;
21
22 disabled = pythonOlder "3.7";
23
24 src = fetchFromGitHub {
25 owner = "huggingface";
26 repo = "pytorch-image-models";
27 rev = "refs/tags/v${version}";
28 hash = "sha256-h2J1v2zXUMGRKBBqq+RnxrXKOzlD5RRrVoODWSuj9Ms=";
29 };
30
31 build-system = [ pdm-backend ];
32
33 dependencies = [
34 huggingface-hub
35 pyyaml
36 safetensors
37 torch
38 torchvision
39 ];
40
41 nativeCheckInputs = [
42 expecttest
43 pytestCheckHook
44 pytest-timeout
45 ];
46
47 pytestFlagsArray = [ "tests" ];
48
49 disabledTestPaths = [
50 # Takes too long and also tries to download models
51 "tests/test_models.py"
52 ];
53
54 disabledTests = [
55 # AttributeError: 'Lookahead' object has no attribute '_optimizer_step_pre...
56 "test_lookahead"
57 ];
58
59 pythonImportsCheck = [
60 "timm"
61 "timm.data"
62 ];
63
64 meta = {
65 description = "PyTorch image models, scripts, and pretrained weights";
66 homepage = "https://huggingface.co/docs/timm/index";
67 changelog = "https://github.com/huggingface/pytorch-image-models/blob/v${version}/README.md#whats-new";
68 license = lib.licenses.asl20;
69 maintainers = with lib.maintainers; [ bcdarwin ];
70 };
71}