easyannotate 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data_factory/__init__.py +82 -0
- data_factory/__main__.py +6 -0
- data_factory/annotate/__init__.py +15 -0
- data_factory/annotate/attach.py +398 -0
- data_factory/annotate/demo.py +161 -0
- data_factory/annotate/images.py +443 -0
- data_factory/annotate/labels.py +399 -0
- data_factory/annotate/loop.py +359 -0
- data_factory/annotate/projects.py +207 -0
- data_factory/annotate/review.py +471 -0
- data_factory/annotate/schema.sql +171 -0
- data_factory/annotate/shapes.py +488 -0
- data_factory/annotate/store.py +292 -0
- data_factory/annotate/tools/__init__.py +39 -0
- data_factory/annotate/tools/fake.py +170 -0
- data_factory/annotate/tools/install.py +254 -0
- data_factory/annotate/tools/local.py +389 -0
- data_factory/annotate/tools/postprocess.py +175 -0
- data_factory/annotate/tools/protocol.py +238 -0
- data_factory/annotate/tools/registry.py +196 -0
- data_factory/annotate/tools/results.py +83 -0
- data_factory/annotate/tools/serve.py +106 -0
- data_factory/cli/__init__.py +21 -0
- data_factory/cli/main.py +837 -0
- data_factory/cli/menu.py +173 -0
- data_factory/cli/render.py +158 -0
- data_factory/core/__init__.py +11 -0
- data_factory/core/annotations/__init__.py +5 -0
- data_factory/core/annotations/coco.py +394 -0
- data_factory/core/annotations/csvfmt.py +174 -0
- data_factory/core/annotations/dota.py +98 -0
- data_factory/core/annotations/formats.py +626 -0
- data_factory/core/annotations/labelme.py +153 -0
- data_factory/core/annotations/model.py +334 -0
- data_factory/core/annotations/voc.py +231 -0
- data_factory/core/annotations/yolo.py +283 -0
- data_factory/core/bktree.py +89 -0
- data_factory/core/fs.py +245 -0
- data_factory/core/imaging.py +626 -0
- data_factory/core/ops/__init__.py +44 -0
- data_factory/core/ops/analyze.py +383 -0
- data_factory/core/ops/annotate_export.py +326 -0
- data_factory/core/ops/audit.py +274 -0
- data_factory/core/ops/augment.py +454 -0
- data_factory/core/ops/collect.py +241 -0
- data_factory/core/ops/combine.py +582 -0
- data_factory/core/ops/convert.py +212 -0
- data_factory/core/ops/dataset.py +246 -0
- data_factory/core/ops/dedup.py +235 -0
- data_factory/core/ops/export.py +168 -0
- data_factory/core/ops/image.py +407 -0
- data_factory/core/ops/labels.py +215 -0
- data_factory/core/ops/pairing.py +133 -0
- data_factory/core/ops/rename.py +154 -0
- data_factory/core/ops/report.py +323 -0
- data_factory/core/ops/visualize.py +164 -0
- data_factory/core/pairs.py +144 -0
- data_factory/core/parallel.py +191 -0
- data_factory/core/provenance.py +136 -0
- data_factory/core/registry.py +339 -0
- data_factory/core/stats.py +403 -0
- data_factory/core/types.py +148 -0
- data_factory/core/writer.py +194 -0
- data_factory/desktop.py +207 -0
- data_factory/hardware.py +243 -0
- data_factory/pipeline.py +192 -0
- data_factory/py.typed +0 -0
- data_factory/service/__init__.py +26 -0
- data_factory/service/app.py +483 -0
- data_factory/service/binding.py +174 -0
- data_factory/service/deps.py +133 -0
- data_factory/service/jobs.py +177 -0
- data_factory/service/limits.py +71 -0
- data_factory/service/routers/__init__.py +11 -0
- data_factory/service/routers/annotate.py +582 -0
- data_factory/service/routers/local.py +464 -0
- data_factory/service/routers/media.py +154 -0
- data_factory/service/routers/predictions.py +116 -0
- data_factory/service/routers/promote.py +182 -0
- data_factory/service/routers/tools.py +308 -0
- data_factory/service/static/annotate/api.js +246 -0
- data_factory/service/static/annotate/app.js +1696 -0
- data_factory/service/static/annotate/assist.js +106 -0
- data_factory/service/static/annotate/filmstrip.js +286 -0
- data_factory/service/static/annotate/hit.js +146 -0
- data_factory/service/static/annotate/labels.js +197 -0
- data_factory/service/static/annotate/render.js +286 -0
- data_factory/service/static/annotate/scene.js +277 -0
- data_factory/service/static/annotate/shapelist.js +72 -0
- data_factory/service/static/annotate/tools/box.js +96 -0
- data_factory/service/static/annotate/tools/line.js +96 -0
- data_factory/service/static/annotate/tools/obb.js +88 -0
- data_factory/service/static/annotate/tools/point.js +49 -0
- data_factory/service/static/annotate/tools/polygon.js +110 -0
- data_factory/service/static/annotate/tools/select.js +227 -0
- data_factory/service/static/annotate/undo.js +176 -0
- data_factory/service/static/annotate/viewport.js +156 -0
- data_factory/service/static/annotate.html +390 -0
- data_factory/service/static/index.html +632 -0
- data_factory/service/workspace.py +244 -0
- easyannotate/__init__.py +64 -0
- easyannotate/__main__.py +5 -0
- easyannotate/project.py +181 -0
- easyannotate/py.typed +0 -0
- easyannotate-0.4.0.dist-info/METADATA +767 -0
- easyannotate-0.4.0.dist-info/RECORD +109 -0
- easyannotate-0.4.0.dist-info/WHEEL +4 -0
- easyannotate-0.4.0.dist-info/entry_points.txt +4 -0
- easyannotate-0.4.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
// Talking to the service. Thin, and honest about failure.
|
|
2
|
+
//
|
|
3
|
+
// The one piece of real logic is the 409 path: a save rejected because someone
|
|
4
|
+
// else moved the image comes back with the server's current state attached, so
|
|
5
|
+
// the caller can reconcile instead of telling a person their work is gone.
|
|
6
|
+
|
|
7
|
+
const KEY_HEADER = "X-API-Key";
|
|
8
|
+
|
|
9
|
+
export class ApiError extends Error {
|
|
10
|
+
constructor(status, message, payload) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.payload = payload;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class Conflict extends ApiError {
|
|
18
|
+
constructor(message, current) {
|
|
19
|
+
super(409, message, current);
|
|
20
|
+
this.current = current;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class Api {
|
|
25
|
+
constructor(base = "") {
|
|
26
|
+
this.base = base;
|
|
27
|
+
// Only ever set on a deployment that runs with a key; a local install
|
|
28
|
+
// never sees this and never prompts for one.
|
|
29
|
+
this.key = new URLSearchParams(location.search).get("key") || "";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
headers(extra = {}) {
|
|
33
|
+
const headers = { ...extra };
|
|
34
|
+
if (this.key) headers[KEY_HEADER] = this.key;
|
|
35
|
+
return headers;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async request(method, path, body, extraHeaders = {}) {
|
|
39
|
+
const options = { method, headers: { ...this.headers(), ...extraHeaders } };
|
|
40
|
+
if (body !== undefined) {
|
|
41
|
+
options.headers["Content-Type"] = "application/json";
|
|
42
|
+
options.body = JSON.stringify(body);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let response;
|
|
46
|
+
try {
|
|
47
|
+
response = await fetch(this.base + path, options);
|
|
48
|
+
} catch (cause) {
|
|
49
|
+
// A dropped connection is not a bug in the request; say so, because the
|
|
50
|
+
// difference decides whether the user should retry or reload.
|
|
51
|
+
throw new ApiError(0, "cannot reach the server", { cause: String(cause) });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (response.status === 204) return null;
|
|
55
|
+
|
|
56
|
+
let payload = null;
|
|
57
|
+
const text = await response.text();
|
|
58
|
+
if (text) {
|
|
59
|
+
try {
|
|
60
|
+
payload = JSON.parse(text);
|
|
61
|
+
} catch {
|
|
62
|
+
payload = { detail: text };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (response.ok) return payload;
|
|
67
|
+
|
|
68
|
+
const detail = payload && payload.detail;
|
|
69
|
+
if (response.status === 409 && detail && detail.current) {
|
|
70
|
+
throw new Conflict(detail.message || "this image changed", detail.current);
|
|
71
|
+
}
|
|
72
|
+
throw new ApiError(
|
|
73
|
+
response.status,
|
|
74
|
+
typeof detail === "string" ? detail : `request failed (${response.status})`,
|
|
75
|
+
payload
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get(path) {
|
|
80
|
+
return this.request("GET", path);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
post(path, body) {
|
|
84
|
+
return this.request("POST", path, body ?? {});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
patch(path, body) {
|
|
88
|
+
return this.request("PATCH", path, body);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
put(path, body) {
|
|
92
|
+
return this.request("PUT", path, body);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
delete(path) {
|
|
96
|
+
return this.request("DELETE", path);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// -- the calls the editor makes ------------------------------------------
|
|
100
|
+
|
|
101
|
+
project(id) {
|
|
102
|
+
return this.get(`/api/projects/${id}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
projects() {
|
|
106
|
+
return this.get("/api/projects");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
createProject(name) {
|
|
110
|
+
return this.post("/api/projects", { name });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
images(id, { state = "", order = "", limit = 500, offset = 0, locate = "" } = {}) {
|
|
114
|
+
const query = new URLSearchParams({ state, limit, offset });
|
|
115
|
+
if (order) query.set("order", order);
|
|
116
|
+
if (locate) query.set("locate", locate);
|
|
117
|
+
return this.get(`/api/projects/${id}/images?${query}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
image(projectId, imageId) {
|
|
121
|
+
return this.get(`/api/projects/${projectId}/images/${imageId}`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
resume(projectId) {
|
|
125
|
+
return this.get(`/api/projects/${projectId}/resume`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
saveShapes(projectId, imageId, version, shapes) {
|
|
129
|
+
return this.put(`/api/projects/${projectId}/images/${imageId}/shapes`, {
|
|
130
|
+
version,
|
|
131
|
+
shapes,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
setState(projectId, imageId, state) {
|
|
136
|
+
return this.patch(`/api/projects/${projectId}/images/${imageId}`, { state });
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
labels(projectId) {
|
|
140
|
+
return this.get(`/api/projects/${projectId}/labels`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
createLabel(projectId, name) {
|
|
144
|
+
return this.post(`/api/projects/${projectId}/labels`, { name });
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
renameLabel(projectId, idx, name) {
|
|
148
|
+
return this.patch(`/api/projects/${projectId}/labels/${idx}`, { name });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
retireLabel(projectId, idx) {
|
|
152
|
+
return this.delete(`/api/projects/${projectId}/labels/${idx}`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
mergeLabel(projectId, idx, into) {
|
|
156
|
+
return this.post(`/api/projects/${projectId}/labels/${idx}/merge`, { into });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
summary(projectId) {
|
|
160
|
+
return this.get(`/api/projects/${projectId}/summary`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// The token a launcher opened this tab with; empty in any other tab.
|
|
164
|
+
localToken() {
|
|
165
|
+
try {
|
|
166
|
+
return sessionStorage.getItem("easyannotate:local-token") || "";
|
|
167
|
+
} catch {
|
|
168
|
+
return "";
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// The local link's routes, with that token as a header.
|
|
173
|
+
local(path, body) {
|
|
174
|
+
return this.request(body === undefined ? "GET" : "POST", `/api/local${path}`, body, {
|
|
175
|
+
"X-Local-Token": this.localToken(),
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
prepareTool(projectId, name, imageId) {
|
|
180
|
+
return this.post(`/api/projects/${projectId}/tools/${name}/prepare`, { image_id: imageId });
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
runToolBatch(projectId, name, options) {
|
|
184
|
+
return this.post(`/api/projects/${projectId}/tools/${name}/batch`, options);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
exportProject(projectId, options) {
|
|
188
|
+
return this.post(`/api/projects/${projectId}/export`, options);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
job(jobId) {
|
|
192
|
+
return this.get(`/api/jobs/${jobId}`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
accept(projectId, imageId) {
|
|
196
|
+
return this.post(`/api/projects/${projectId}/images/${imageId}/accept`);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
runs(projectId) {
|
|
200
|
+
return this.get(`/api/projects/${projectId}/runs`);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
tools() {
|
|
204
|
+
return this.get("/api/tools");
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
runTool(projectId, name, { imageId, params, label }) {
|
|
208
|
+
return this.post(`/api/projects/${projectId}/tools/${name}`, {
|
|
209
|
+
image_id: imageId,
|
|
210
|
+
params,
|
|
211
|
+
label,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Predictions arrive as a file, so this is multipart rather than JSON --
|
|
216
|
+
// the client still never names a path.
|
|
217
|
+
async importPredictions(projectId, file, { minConfidence = 0 } = {}) {
|
|
218
|
+
const form = new FormData();
|
|
219
|
+
form.append("file", file);
|
|
220
|
+
form.append("min_confidence", String(minConfidence));
|
|
221
|
+
const response = await fetch(
|
|
222
|
+
`${this.base}/api/projects/${projectId}/predictions`,
|
|
223
|
+
{ method: "POST", headers: this.headers(), body: form }
|
|
224
|
+
);
|
|
225
|
+
const payload = await response.json().catch(() => null);
|
|
226
|
+
if (!response.ok) {
|
|
227
|
+
const detail = payload && payload.detail;
|
|
228
|
+
throw new ApiError(
|
|
229
|
+
response.status,
|
|
230
|
+
typeof detail === "string" ? detail : "could not import those predictions",
|
|
231
|
+
payload
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
return payload;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
imageUrl(projectId, imageId) {
|
|
238
|
+
const key = this.key ? `?key=${encodeURIComponent(this.key)}` : "";
|
|
239
|
+
return `${this.base}/api/projects/${projectId}/images/${imageId}/file${key}`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
thumbUrl(projectId, imageId) {
|
|
243
|
+
const key = this.key ? `?key=${encodeURIComponent(this.key)}` : "";
|
|
244
|
+
return `${this.base}/api/projects/${projectId}/images/${imageId}/thumb${key}`;
|
|
245
|
+
}
|
|
246
|
+
}
|