@glodon-aiot/dataset-annotation 3.18.0-alpha.11 → 3.18.0-alpha.13

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.
@@ -1,18 +1,18 @@
1
- import { jsxs as a, jsx as o } from "react/jsx-runtime";
2
- import { useContext as ze, useState as s, useEffect as E, useRef as q } from "react";
3
- import { Button as N, Space as fe, Tooltip as _, Empty as me, message as ge } from "antd";
1
+ import { jsxs as a, jsx as n } from "react/jsx-runtime";
2
+ import { useContext as ze, useState as s, useEffect as k, useRef as q } from "react";
3
+ import { Button as C, Space as fe, Tooltip as _, Empty as me, message as ge } from "antd";
4
4
  import { ZoomInOutlined as He, ZoomOutOutlined as Te, FullscreenExitOutlined as De, FullscreenOutlined as Fe } from "@ant-design/icons";
5
- import { useFullscreen as je } from "ahooks";
6
- import Re from "../../../../DatasetContext/index.mjs";
7
- import { tagColors as $e } from "../../../../utils/index.mjs";
5
+ import { useFullscreen as $e } from "ahooks";
6
+ import je from "../../../../DatasetContext/index.mjs";
7
+ import { tagColors as Re } from "../../../../utils/index.mjs";
8
8
  import Be from "../../icon_linear.svg.mjs";
9
9
  import "./style.less.mjs";
10
10
  import he from "../../../Iconfont/index.mjs";
11
11
  const ot = (pe) => {
12
12
  const {
13
- serviceId: x,
13
+ serviceId: v,
14
14
  confidence: P,
15
- datasetId: U,
15
+ datasetId: E,
16
16
  versionId: z,
17
17
  isVisible: A
18
18
  } = pe, {
@@ -20,77 +20,79 @@ const ot = (pe) => {
20
20
  cvforceDatahub: H,
21
21
  aiShop: T
22
22
  }
23
- } = ze(Re), [f, D] = s(), [I, xe] = s([]), [F, G] = s(!1), [y, J] = s([]), [u, ve] = s([]), [v, Ie] = s([]);
24
- E(() => {
25
- !H || !U || !z || !A || H.getDatasetsIdVersionsVidSamples(U, z, {
23
+ } = ze(je), [u, D] = s(), [h, xe] = s([]), [F, G] = s(!1), [M, J] = s([]), [d, ve] = s([]), [I, Ie] = s([]);
24
+ k(() => {
25
+ !H || !E || !z || !A || H.getDatasetsIdVersionsVidSamples(E, z, {
26
26
  pageNo: 1,
27
27
  pageSize: 10,
28
28
  labels: "nocode",
29
- confirmStatus: 0
29
+ confirmStatus: 0,
30
+ extractPercent: 10,
31
+ extractMax: 10
30
32
  }).then((e) => {
31
- const t = e.recordList || [], n = t == null ? void 0 : t[0];
32
- n != null && n.fileUrl && D(n == null ? void 0 : n.fileUrl), xe(t);
33
+ const t = e.recordList || [], o = t == null ? void 0 : t[0];
34
+ o != null && o.fileUrl && D(o == null ? void 0 : o.fileUrl), xe(t);
33
35
  }).catch(() => !1);
34
- }, [A, U, z, H]), E(() => {
35
- !f || !x || (G(!0), J([]), T == null || T.detectionLayout(x, {
36
+ }, [A, E, z, H]), k(() => {
37
+ !u || !v || (G(!0), J([]), T == null || T.detectionLayout(v, {
36
38
  pages: [{
37
- image: f
39
+ image: u
38
40
  }]
39
41
  }).then((e) => {
40
42
  J(e.prediction);
41
43
  }).finally(() => {
42
44
  G(!1);
43
45
  }));
44
- }, [f, x]), E(() => {
45
- const e = y == null ? void 0 : y.filter((t) => t.score >= (P != null ? P : 0));
46
+ }, [u, v]), k(() => {
47
+ const e = M == null ? void 0 : M.filter((t) => t.score >= (P != null ? P : 0));
46
48
  ve(e);
47
- }, [y, P]), E(() => {
48
- if (!u)
49
+ }, [M, P]), k(() => {
50
+ if (!d)
49
51
  return;
50
- const e = y.map((t) => t.label).reduce((t, n) => t.includes(n) ? t : [...t, n], []);
51
- Ie(e.map((t, n) => ({
52
+ const e = M.map((t) => t.label).reduce((t, o) => t.includes(o) ? t : [...t, o], []);
53
+ Ie(e.map((t, o) => ({
52
54
  label: t,
53
- count: u.filter((i) => i.label === t).length,
54
- color: $e[n],
55
- id: `${n}_${t}`
55
+ count: d.filter((r) => r.label === t).length,
56
+ color: Re[o],
57
+ id: `${o}_${t}`
56
58
  })));
57
- }, [u]);
58
- const ye = () => {
59
- const e = I.findIndex((t) => t.fileUrl === f);
59
+ }, [d]);
60
+ const Me = () => {
61
+ const e = h.findIndex((t) => t.fileUrl === u);
60
62
  if (e <= 0) {
61
63
  ge.warning("已经是第一张了");
62
64
  return;
63
65
  }
64
- D(I[e - 1].fileUrl);
65
- }, Me = () => {
66
- const e = I.findIndex((t) => t.fileUrl === f);
67
- if (e >= I.length - 1) {
66
+ D(h[e - 1].fileUrl);
67
+ }, ye = () => {
68
+ const e = h.findIndex((t) => t.fileUrl === u);
69
+ if (e >= h.length - 1) {
68
70
  ge.warning("已经是最后一张了");
69
71
  return;
70
72
  }
71
- D(I[e + 1].fileUrl);
72
- }, w = q(null), j = q({}), K = q(null), [Q, {
73
- toggleFullscreen: Ce
74
- }] = je(K), [ee, Ne] = s(0), [te, Pe] = s(0), [c, R] = s(1), [m, h] = s(0), [g, p] = s(0), [we, Se] = s(!1), [oe, ne] = s(-1), [r, $] = s(0), [l, B] = s(0), [se, S] = s(!1), [ce, Ye] = s(), [Y, b] = s({
73
+ D(h[e + 1].fileUrl);
74
+ }, w = q(null), $ = q({}), K = q(null), [Q, {
75
+ toggleFullscreen: Ne
76
+ }] = $e(K), [ee, Ce] = s(0), [te, Pe] = s(0), [c, j] = s(1), [m, p] = s(0), [g, x] = s(0), [we, Se] = s(!1), [oe, ne] = s(-1), [i, R] = s(0), [l, B] = s(0), [se, S] = s(!1), [ce, Ye] = s(), [Y, b] = s({
75
77
  x: 0,
76
78
  y: 0
77
- }), ie = 50, re = 50, le = 50, ae = 50, X = 0.05, O = 3, W = 0.2, be = () => {
79
+ }), re = 50, ie = 50, le = 50, ae = 50, X = 0.05, O = 3, W = 0.2, be = () => {
78
80
  if (!w.current)
79
81
  return;
80
- const e = j.current.clientWidth, t = j.current.clientHeight, n = w.current.naturalWidth, i = w.current.naturalHeight, M = e / n, d = t / i, C = M < d ? M : d, Ee = (e - n * C) / 2, Ue = (t - i * C) / 2;
81
- Ne(e), Pe(t), R(C), h(Ee), p(Ue), $(n * C), B(i * C), Se(!0);
82
- }, L = (e) => ne(e), Xe = () => ne(-1), k = () => {
83
- m < -r + ae && h(-r + ae), g < -l + ie && p(-l + ie), m > ee - re && h(ee - re), g > te - le && p(te - le);
82
+ const e = $.current.clientWidth, t = $.current.clientHeight, o = w.current.naturalWidth, r = w.current.naturalHeight, y = e / o, f = t / r, N = y < f ? y : f, ke = (e - o * N) / 2, Ee = (t - r * N) / 2;
83
+ Ce(e), Pe(t), j(N), p(ke), x(Ee), R(o * N), B(r * N), Se(!0);
84
+ }, L = (e) => ne(e), Xe = () => ne(-1), U = () => {
85
+ m < -i + ae && p(-i + ae), g < -l + re && x(-l + re), m > ee - ie && p(ee - ie), g > te - le && x(te - le);
84
86
  }, V = () => {
85
87
  if (c >= O)
86
88
  return;
87
89
  let e = c * (1 + X), t = X;
88
- e >= O && (e = O, t = O / c - 1), h(m - r * (t / 2)), p(g - l * (t / 2)), $(r + r * t), B(l + l * t), R(e), k();
90
+ e >= O && (e = O, t = O / c - 1), p(m - i * (t / 2)), x(g - l * (t / 2)), R(i + i * t), B(l + l * t), j(e), U();
89
91
  }, Z = () => {
90
92
  if (c <= W)
91
93
  return;
92
94
  let e = c * (1 - X), t = X;
93
- e <= W && (e = W, t = 1 - W / c), h(m - r * (-t / 2)), p(g - l * (-t / 2)), $(r + r * -t), B(l + l * -t), R(e), k();
95
+ e <= W && (e = W, t = 1 - W / c), p(m - i * (-t / 2)), x(g - l * (-t / 2)), R(i + i * -t), B(l + l * -t), j(e), U();
94
96
  };
95
97
  window.onmouseup = () => S(!1);
96
98
  const Oe = (e) => (e.deltaY < 0 ? V() : Z(), !1), We = (e) => {
@@ -101,12 +103,12 @@ const ot = (pe) => {
101
103
  }, Le = (e) => {
102
104
  if (!se)
103
105
  return;
104
- const t = e.pageX - Y.x, n = e.pageY - Y.y;
106
+ const t = e.pageX - Y.x, o = e.pageY - Y.y;
105
107
  b({
106
108
  x: e.pageX,
107
109
  y: e.pageY
108
- }), h(m + t), p(g + n), k();
109
- }, ue = () => S(!1), ke = (e) => {
110
+ }), p(m + t), x(g + o), U();
111
+ }, ue = () => S(!1), Ue = (e) => {
110
112
  const {
111
113
  touches: t
112
114
  } = e;
@@ -115,115 +117,115 @@ const ot = (pe) => {
115
117
  y: t[0].clientY
116
118
  }) : Ye(t);
117
119
  }, de = (e, t) => {
118
- const n = t.pageX - e.pageX, i = t.pageY - e.pageY;
119
- return Math.sqrt(n * n + i * i);
120
+ const o = t.pageX - e.pageX, r = t.pageY - e.pageY;
121
+ return Math.sqrt(o * o + r * r);
120
122
  };
121
123
  return /* @__PURE__ */ a("div", {
122
124
  className: "pre-label-content",
123
- children: [x && f && /* @__PURE__ */ a("div", {
125
+ children: [v && u && /* @__PURE__ */ a("div", {
124
126
  className: "pre-label-content-preview",
125
127
  ref: K,
126
- children: [/* @__PURE__ */ o(N, {
128
+ children: [/* @__PURE__ */ n(C, {
127
129
  className: "select-prev",
128
- icon: /* @__PURE__ */ o(he, {
130
+ icon: /* @__PURE__ */ n(he, {
129
131
  type: "icon-zuojiantou"
130
132
  }),
131
133
  disabled: F,
132
134
  type: "text",
133
- onClick: () => ye(),
135
+ onClick: () => Me(),
134
136
  tabIndex: 0
135
137
  }), /* @__PURE__ */ a("div", {
136
138
  className: "select-main",
137
- children: [/* @__PURE__ */ o("div", {
139
+ children: [/* @__PURE__ */ n("div", {
138
140
  className: "marker-action",
139
- children: /* @__PURE__ */ o("div", {
141
+ children: /* @__PURE__ */ n("div", {
140
142
  className: "create-mode-select",
141
143
  children: /* @__PURE__ */ a(fe, {
142
144
  direction: "vertical",
143
145
  size: 16,
144
- children: [/* @__PURE__ */ o(_, {
146
+ children: [/* @__PURE__ */ n(_, {
145
147
  title: "放大-鼠标滚轮前滑",
146
148
  placement: "right",
147
- children: /* @__PURE__ */ o(N, {
148
- icon: /* @__PURE__ */ o(He, {}),
149
+ children: /* @__PURE__ */ n(C, {
150
+ icon: /* @__PURE__ */ n(He, {}),
149
151
  onClick: V
150
152
  })
151
- }), /* @__PURE__ */ o(_, {
153
+ }), /* @__PURE__ */ n(_, {
152
154
  title: "缩小-鼠标滚轮后滑",
153
155
  placement: "right",
154
- children: /* @__PURE__ */ o(N, {
155
- icon: /* @__PURE__ */ o(Te, {}),
156
+ children: /* @__PURE__ */ n(C, {
157
+ icon: /* @__PURE__ */ n(Te, {}),
156
158
  onClick: Z
157
159
  })
158
- }), /* @__PURE__ */ o(_, {
160
+ }), /* @__PURE__ */ n(_, {
159
161
  title: Q ? "退出全屏" : "全屏",
160
162
  placement: "right",
161
- children: /* @__PURE__ */ o(N, {
162
- icon: Q ? /* @__PURE__ */ o(De, {}) : /* @__PURE__ */ o(Fe, {}),
163
- onClick: Ce
163
+ children: /* @__PURE__ */ n(C, {
164
+ icon: Q ? /* @__PURE__ */ n(De, {}) : /* @__PURE__ */ n(Fe, {}),
165
+ onClick: Ne
164
166
  })
165
167
  })]
166
168
  })
167
169
  })
168
- }), /* @__PURE__ */ o("div", {
170
+ }), /* @__PURE__ */ n("div", {
169
171
  className: "right-col-wrapper",
170
172
  children: /* @__PURE__ */ a("div", {
171
173
  className: "right-col-img",
172
- ref: j,
174
+ ref: $,
173
175
  onMouseDown: We,
174
176
  onMouseMove: Le,
175
177
  onMouseUp: ue,
176
178
  onWheel: Oe,
177
- onTouchStart: ke,
179
+ onTouchStart: Ue,
178
180
  onTouchMove: (e) => {
179
181
  if (!(!se || !e.touches))
180
182
  if (e.touches.length < 2) {
181
- const t = e.touches[0].clientX - Y.x, n = e.touches[0].clientY - Y.y;
183
+ const t = e.touches[0].clientX - Y.x, o = e.touches[0].clientY - Y.y;
182
184
  b({
183
185
  x: e.touches[0].clientX,
184
186
  y: e.touches[0].clientY
185
- }), h(m + t), p(g + n), k();
187
+ }), p(m + t), x(g + o), U();
186
188
  } else {
187
- const t = de(e.touches[0], e.touches[1]), n = de(ce[0], ce[1]);
188
- t > n ? V() : Z();
189
+ const t = de(e.touches[0], e.touches[1]), o = de(ce[0], ce[1]);
190
+ t > o ? V() : Z();
189
191
  }
190
192
  },
191
193
  onTouchEnd: ue,
192
- children: [/* @__PURE__ */ o("img", {
193
- src: f,
194
+ children: [/* @__PURE__ */ n("img", {
195
+ src: u,
194
196
  style: {
195
197
  position: "absolute",
196
198
  left: m,
197
199
  top: g,
198
- width: r,
200
+ width: i,
199
201
  height: l
200
202
  },
201
203
  ref: w,
202
204
  onLoad: be,
203
205
  alt: ""
204
- }), we && /* @__PURE__ */ o("svg", {
206
+ }), we && /* @__PURE__ */ n("svg", {
205
207
  style: {
206
208
  position: "absolute",
207
209
  left: m,
208
210
  top: g,
209
- width: r,
211
+ width: i,
210
212
  height: l
211
213
  },
212
- children: (u == null ? void 0 : u.length) && (u == null ? void 0 : u.map((e, t) => {
213
- var n, i, M;
214
+ children: (d == null ? void 0 : d.length) && (d == null ? void 0 : d.map((e, t) => {
215
+ var o, r, y;
214
216
  return /* @__PURE__ */ a("g", {
215
- children: [/* @__PURE__ */ o("g", {
217
+ children: [/* @__PURE__ */ n("g", {
216
218
  style: {
217
219
  cursor: "pointer"
218
220
  },
219
- children: /* @__PURE__ */ o("polygon", {
220
- points: (n = e == null ? void 0 : e.box) == null ? void 0 : n.map((d) => `${d[0] * c} ${d[1] * c}`).join(","),
221
+ children: /* @__PURE__ */ n("polygon", {
222
+ points: (o = e == null ? void 0 : e.box) == null ? void 0 : o.map((f) => `${f[0] * c} ${f[1] * c}`).join(","),
221
223
  onMouseOver: () => L(t),
222
224
  onMouseEnter: () => L(t),
223
225
  onMouseLeave: () => Xe(),
224
226
  style: {
225
- fill: t === oe ? `${(i = v == null ? void 0 : v.find((d) => d.label === e.label)) == null ? void 0 : i.color}59` : "transparent",
226
- stroke: ((M = v == null ? void 0 : v.find((d) => d.label === e.label)) == null ? void 0 : M.color) || "",
227
+ fill: t === oe ? `${(r = I == null ? void 0 : I.find((f) => f.label === e.label)) == null ? void 0 : r.color}59` : "transparent",
228
+ stroke: ((y = I == null ? void 0 : I.find((f) => f.label === e.label)) == null ? void 0 : y.color) || "",
227
229
  strokeWidth: 2,
228
230
  cursor: "pointer"
229
231
  }
@@ -238,7 +240,7 @@ const ot = (pe) => {
238
240
  cursor: "pointer"
239
241
  },
240
242
  fill: "#fff",
241
- children: [/* @__PURE__ */ o("text", {
243
+ children: [/* @__PURE__ */ n("text", {
242
244
  x: e.box[0][0] * c + 4,
243
245
  y: e.box[0][1] * c + 16,
244
246
  children: e.label
@@ -254,36 +256,42 @@ const ot = (pe) => {
254
256
  }, t) || null]
255
257
  }, t);
256
258
  }))
257
- }), F && /* @__PURE__ */ o("img", {
259
+ }), F && /* @__PURE__ */ n("img", {
258
260
  className: "pic-curr-linear",
259
261
  src: Be,
260
262
  alt: ""
261
263
  })]
262
264
  })
265
+ }), /* @__PURE__ */ n("div", {
266
+ className: "page-info",
267
+ children: (() => {
268
+ const e = h.findIndex((o) => o.fileUrl === u);
269
+ return `${e >= 0 ? e + 1 : 0}/${h.length}`;
270
+ })()
263
271
  })]
264
- }), /* @__PURE__ */ o(N, {
272
+ }), /* @__PURE__ */ n(C, {
265
273
  className: "select-next",
266
274
  disabled: F,
267
- icon: /* @__PURE__ */ o(he, {
275
+ icon: /* @__PURE__ */ n(he, {
268
276
  type: "icon-youjiantou"
269
277
  }),
270
278
  type: "text",
271
- onClick: () => Me()
279
+ onClick: () => ye()
272
280
  })]
273
- }), x && !f && /* @__PURE__ */ o("div", {
281
+ }), v && !u && /* @__PURE__ */ n("div", {
274
282
  className: "pre-label-content-nodata",
275
- children: /* @__PURE__ */ o(me, {
283
+ children: /* @__PURE__ */ n(me, {
276
284
  description: "暂无未标注的图片"
277
285
  })
278
- }), !x && /* @__PURE__ */ o("div", {
286
+ }), !v && /* @__PURE__ */ n("div", {
279
287
  className: "pre-label-content-nodata",
280
- children: /* @__PURE__ */ o(me, {
288
+ children: /* @__PURE__ */ n(me, {
281
289
  description: /* @__PURE__ */ a(fe, {
282
290
  direction: "vertical",
283
291
  size: 8,
284
- children: [/* @__PURE__ */ o("div", {
292
+ children: [/* @__PURE__ */ n("div", {
285
293
  children: "选择服务,查看预览测试效果"
286
- }), /* @__PURE__ */ o("div", {
294
+ }), /* @__PURE__ */ n("div", {
287
295
  children: "随机抽取占比不超过未标注总的 10%,最少1张最高不超过 10 张"
288
296
  })]
289
297
  })