-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
163 lines (154 loc) · 6.52 KB
/
flake.nix
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
{
description = "Datasets";
nixConfig = {
# This is for getting pretrained models.
# sandbox = false;
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
nixpkgs-locked.url = "github:nixos/nixpkgs?rev=12e7af1cfb3ab5bbbbd1d213a0b17c11ce9d3f2f";
flake-utils.url = "github:numtide/flake-utils";
yolov5s_bdd100k = {
url = "github:williamhyin/yolov5s_bdd100k";
flake = false;
};
yolov5 = {
url = "github:ultralytics/yolov5?rev=4695ca8314269c9a9f4b8cf89c7962205f27fdad";
flake = false;
};
torchvision-fasterrcnn.url = "github:junjihashimoto/torchvision-fasterrcnn";
};
outputs = { self,
nixpkgs,
nixpkgs-locked,
flake-utils,
yolov5s_bdd100k,
yolov5,
torchvision-fasterrcnn
}:
flake-utils.lib.eachDefaultSystem (system:
let nixflow = import ./nix/nixflow.nix {pkgs=pkgs-locked;};
pkgs = import nixpkgs {inherit system;};
pkgs-locked = import nixpkgs-locked {inherit system;};
# cml = import ./utils/cml/default.nix {inherit pkgs;};
cml = import ./utils/cml/non-sandbox.nix {inherit pkgs;};
huggingface = import ./models/huggingface/default.nix {inherit pkgs;};
torchvision = import ./models/torchvision/default.nix {inherit pkgs;};
fasterrcnn = torchvision-fasterrcnn.lib.${system};
src2drv = import datasets/bdd100k-mini/default.nix {pkgs = pkgs-locked;};
bdd100k-mini = src2drv {};
bdd100k-mini-coco = import datasets/yolo2coco/default.nix {pkgs = pkgs-locked; dataset = bdd100k-mini; };
yolo2coco = args@{...}: import datasets/yolo2coco/default.nix ({pkgs = pkgs-locked;} // args);
img2coco = args@{...}: import datasets/img2coco/default.nix ({
pkgs = pkgs-locked;
inherit nixflow;
datasetForLabels = bdd100k-mini-coco;
} // args);
yolov5 = import ./models/yolov5/default.nix {inherit pkgs;};
yolov5-bdd100k = import ./models/yolov5/inferences/bdd100k.nix {inherit pkgs; inherit yolov5s_bdd100k;};
yolov5-bdd100k-test = yolov5-bdd100k.test;
yolov5-bdd100k-tests = nixflow.mapDatasets "test-" datasets.bdd100k-subset
(dataset:
yolov5-bdd100k-test {
inherit dataset;
useDefaultWeights = true;
}
);
fasterrcnn-bdd100k-tests = nixflow.mapDatasets "test-" datasets.bdd100k-subset
(dataset:
fasterrcnn.test {
datasets = yolo2coco {
inherit dataset;
};
}
);
datasets = rec{
mnist = import datasets/mnist.nix {pkgs = pkgs-locked;};
coco2014 = import datasets/coco/default.nix {pkgs = pkgs-locked;};
bdd100k = import datasets/bdd100k/default.nix {pkgs = pkgs-locked;};
bdd100k-coco = import datasets/yolo2coco/default.nix {pkgs = pkgs-locked; dataset = bdd100k; };
bdd100k-mini = src2drv {};
bdd100k-mini-coco = import datasets/yolo2coco/default.nix {pkgs = pkgs-locked; dataset = bdd100k-mini; };
bdd100k-subset = import datasets/bdd100k-subset/subsets.nix {
pkgs = pkgs-locked;
inherit bdd100k;
};
sample-images = src2drv {
srcs = builtins.map builtins.fetchurl (builtins.attrValues {
data1 = {
url = "https://github.com/hasktorch/hasktorch-datasets/releases/download/sample/sample-images.zip";
sha256 = "1n065xabx4rv85b2nyvpj510yr3fvri1h828y77a1vr5g6mhrv7q";
};
});
};
sample-coco-images = img2coco {
dataset = sample-images;
};
common-voice = import datasets/common-voice/default.nix {pkgs = pkgs-locked; };
};
analysis = rec {
bdd100k-subset-yolov5 = import analysis/calc-map.nix {
pkgs = pkgs-locked;
datasets =
(nixflow.flattenDerivations {
drvs = yolov5-bdd100k-tests;
prefix = "test-yolov5-bdd100k";
}) // {
yolov5-bdd100k-all = yolov5-bdd100k-test {
dataset = datasets.bdd100k;
useDefaultWeights = true;
};
};
};
bdd100k-subset-fasterrcnn = import analysis/calc-map-simple.nix {
pkgs = pkgs-locked;
datasets =
(nixflow.flattenDerivations {
drvs = fasterrcnn-bdd100k-tests;
prefix = "test-fasterrcnn-bdd100k";
}) // {
fasterrcnn-bdd100k-all = fasterrcnn.test {
datasets = yolo2coco {
dataset = datasets.bdd100k;
};
};
};
};
fasterrcnn-bdd100k-detect = fasterrcnn.detect {
datasets = datasets.bdd100k-coco;
};
};
in {
# Exported functions.
# ToDo: Generate documents for each function.
lib = {
datasets = {
inherit yolo2coco;
inherit img2coco;
inherit src2drv;
mix = args@{...}: import utils/mix.nix ({pkgs = pkgs-locked;} // args);
bdd100k-filter = args@{...}: import datasets/bdd100k-subset/default.nix ({pkgs = pkgs-locked;} // args);
bdd100k-subsets = args@{...}: {bdd100k = datasets.bdd100k;} // datasets.bdd100k-subset // args;
};
models = {
yolov5-bdd100k = {
test = args@{...}: yolov5-bdd100k.test ({
useDefaultWeights = true;
} // args);
};
};
utils = nixflow;
};
# Exported packages.
packages =
with nixflow;
(flattenDerivations {drvs = datasets; prefix = "datasets";})
// (flattenDerivations {drvs = huggingface; prefix = "models-huggingface";})
// (flattenDerivations {drvs = torchvision; prefix = "models-torchvision";})
// (flattenDerivations {drvs = {yolov5 = yolov5;}; prefix = "models-yolov5";})
// (flattenDerivations {drvs = yolov5-bdd100k-tests; prefix = "test-yolov5-bdd100k";})
// (flattenDerivations {drvs = analysis; prefix = "analysis";})
// {inherit cml;};
}
);
}