@glodon-aiot/dataset-annotation 3.19.1 → 3.19.2-alpha.0

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,294 +1,309 @@
1
- var N = (c, r, f) => new Promise((n, p) => {
2
- var C = (a) => {
1
+ var g = (c, h, n) => new Promise((C, l) => {
2
+ var y = (a) => {
3
3
  try {
4
- t(f.next(a));
5
- } catch (v) {
6
- p(v);
4
+ u(n.next(a));
5
+ } catch (t) {
6
+ l(t);
7
7
  }
8
- }, y = (a) => {
8
+ }, w = (a) => {
9
9
  try {
10
- t(f.throw(a));
11
- } catch (v) {
12
- p(v);
10
+ u(n.throw(a));
11
+ } catch (t) {
12
+ l(t);
13
13
  }
14
- }, t = (a) => a.done ? n(a.value) : Promise.resolve(a.value).then(C, y);
15
- t((f = f.apply(c, r)).next());
14
+ }, u = (a) => a.done ? C(a.value) : Promise.resolve(a.value).then(y, w);
15
+ u((n = n.apply(c, h)).next());
16
16
  });
17
- import { jsx as e, jsxs as s, Fragment as b } from "react/jsx-runtime";
18
- import { useRef as T, useState as o, useContext as ce, useEffect as I, useCallback as me } from "react";
19
- import { Modal as B, Button as h, Space as G, Spin as fe, Tabs as ue, message as U } from "antd";
17
+ import { jsx as e, jsxs as s, Fragment as N } from "react/jsx-runtime";
18
+ import { useRef as X, useState as d, useContext as ye, useEffect as I, useCallback as we } from "react";
19
+ import { Modal as Y, Button as f, Space as Z, Spin as Me, Tabs as ke, message as _ } from "antd";
20
20
  import "./style.less.mjs";
21
- import { useKeyPress as $ } from "ahooks";
22
- import { LoadingOutlined as he, MenuUnfoldOutlined as ve, MenuFoldOutlined as pe } from "@ant-design/icons";
23
- import ge from "../../../DatasetContext/index.mjs";
24
- import Ne from "../../VLMAnnotation/index.mjs";
25
- import H from "../../Iconfont/index.mjs";
26
- import Ce from "../VLMDetail/index.mjs";
27
- const Oe = (c) => {
21
+ import { useKeyPress as ee } from "ahooks";
22
+ import { LoadingOutlined as xe, MenuUnfoldOutlined as be, MenuFoldOutlined as Ie } from "@ant-design/icons";
23
+ import qe from "../../../DatasetContext/index.mjs";
24
+ import Ve from "../../VLMAnnotation/index.mjs";
25
+ import Qe from "../../VQAAnnotation/VQAAnnotationPanel.mjs";
26
+ import ie from "../../Iconfont/index.mjs";
27
+ import Le from "../VLMDetail/index.mjs";
28
+ const Se = (c) => {
29
+ var z, E, K, B, G, S, U, $;
28
30
  const {
29
- isVlmModalVisible: r,
30
- setIsVlmModalVisible: f,
31
- record: n,
32
- onNextClick: p,
33
- onPrevClick: C,
34
- listLoading: y = !1,
35
- datasetId: t,
36
- versionId: a,
37
- handleMarkClick: v,
38
- updateSampleList: J,
39
- filterMode: W = "",
40
- onFilterModeChange: X,
41
- samples: Y,
31
+ vlmMarkTmpl: h,
32
+ isVlmModalVisible: n,
33
+ setIsVlmModalVisible: C,
34
+ record: l,
35
+ onNextClick: y,
36
+ onPrevClick: w,
37
+ listLoading: u = !1,
38
+ datasetId: a,
39
+ versionId: t,
40
+ handleMarkClick: ae,
41
+ updateSampleList: ne,
42
+ filterMode: te = "",
43
+ onFilterModeChange: le,
44
+ samples: se,
42
45
  onSave: q,
43
- selectSampleId: Z,
44
- onClose: Q,
45
- pagination: _,
46
- currentIndex: ee
47
- } = c, ie = T({}), M = T(null), [i, ae] = o(), [te, V] = o(!1), [u, w] = o(c.initialMode || "preview"), [ne, k] = o([]), [L, R] = o(0), [le, O] = o(!1), [S, x] = o(!0), [j, A] = o(!1), {
46
+ selectSampleId: re,
47
+ onClose: V,
48
+ pagination: oe,
49
+ currentIndex: de
50
+ } = c, ce = X({}), M = X(null), [i, me] = d(), [ve, Q] = d(!1), [v, k] = d(c.initialMode || "preview"), [fe, x] = d([]), [L, A] = d(0), [ue, O] = d(!1), [R, b] = d(!0), [P, j] = d(!1), {
48
51
  services: {
49
- cvforceDatahub: d
52
+ cvforceDatahub: o
50
53
  },
51
54
  featuresConfig: {
52
55
  datasetManager: D
53
56
  } = {
54
57
  datasetManager: !1
55
58
  }
56
- } = ce(ge), g = !(te || y), F = () => {
57
- g && C();
58
- }, P = () => {
59
- g && p();
59
+ } = ye(qe), p = !(ve || u), F = () => {
60
+ p && w();
61
+ }, T = () => {
62
+ p && y();
60
63
  };
61
- $("rightarrow", () => {
62
- P();
63
- }), $("leftarrow", () => {
64
+ ee("rightarrow", () => {
65
+ T();
66
+ }), ee("leftarrow", () => {
64
67
  F();
65
- }), I(() => {
66
- r ? c.initialMode && w(c.initialMode) : w("preview");
67
- }, [r, c.initialMode]), I(() => {
68
- if (r && t && a && u === "preview") {
69
- if (V(!0), !(n != null && n.id))
68
+ });
69
+ const he = h === "VQA";
70
+ I(() => {
71
+ n ? c.initialMode && k(c.initialMode) : k("preview");
72
+ }, [n, c.initialMode]), I(() => {
73
+ if (n && a && t && v === "preview") {
74
+ if (Q(!0), !(l != null && l.id))
70
75
  return;
71
- d == null || d.getDatasetsIdVersionsVidSsamplesSid(t, a, n.id).then((l) => {
72
- ae(l);
73
- }).finally(() => V(!1));
76
+ o == null || o.getDatasetsIdVersionsVidSsamplesSid(a, t, l.id).then((r) => {
77
+ me(r);
78
+ }).finally(() => Q(!1));
74
79
  }
75
- }, [r, n, u]);
76
- const se = me(() => N(void 0, null, function* () {
77
- if (!(!t || !a || !(i != null && i.id))) {
80
+ }, [n, l, v]);
81
+ const pe = we(() => g(void 0, null, function* () {
82
+ if (!(!a || !t || !(i != null && i.id))) {
78
83
  O(!0);
79
84
  try {
80
- const l = yield d == null ? void 0 : d.postGenerateVlmKieQa(t, a, {
85
+ const r = yield o == null ? void 0 : o.postGenerateVlmKieQa(a, t, {
81
86
  sampleIds: [i.id]
82
87
  });
83
- k(l || []), R(0);
84
- } catch (l) {
85
- console.error("QA生成失败", l), k([]);
88
+ x(r || []), A(0);
89
+ } catch (r) {
90
+ console.error("QA生成失败", r), x([]);
86
91
  } finally {
87
92
  O(!1);
88
93
  }
89
94
  }
90
- }), [t, a, i]);
95
+ }), [a, t, i]);
91
96
  I(() => {
92
- if (!r || u !== "preview" || !(i != null && i.id))
97
+ if (!n || v !== "preview" || !(i != null && i.id))
93
98
  return;
94
99
  if (((i == null ? void 0 : i.labels) || []).length)
95
- A(!1), se();
100
+ j(!1), pe();
96
101
  else {
97
- k([]), x(!1), A(!0);
102
+ x([]), b(!1), j(!0);
98
103
  return;
99
104
  }
100
105
  }, [i]);
101
- const re = () => N(void 0, null, function* () {
102
- if (u === "annotation" && M.current) {
106
+ const ge = () => g(void 0, null, function* () {
107
+ if (v === "annotation" && M.current) {
103
108
  yield M.current.handleModalCancel();
104
109
  return;
105
110
  } else
106
- Q();
107
- }), de = () => {
108
- w("annotation"), v((i == null ? void 0 : i.id) || (n == null ? void 0 : n.id));
109
- }, oe = () => {
110
- B.confirm({
111
+ V();
112
+ }), Ne = () => {
113
+ k("annotation"), ae((i == null ? void 0 : i.id) || (l == null ? void 0 : l.id));
114
+ }, Ce = () => {
115
+ Y.confirm({
111
116
  title: "确认要删除此数据吗?",
112
117
  content: "删除后不可恢复,请慎重操作",
113
118
  onOk: () => {
114
- !t || !a || !(i != null && i.id) || d == null || d.delDatasetsIdVersionsVidSamplesId(t, a, i.id).then(() => {
115
- U.success("删除成功"), f(!1), J();
116
- }).catch(() => U.error("删除失败"));
119
+ !a || !t || !(i != null && i.id) || o == null || o.delDatasetsIdVersionsVidSamplesId(a, t, i.id).then(() => {
120
+ _.success("删除成功"), C(!1), ne();
121
+ }).catch(() => _.error("删除失败"));
117
122
  }
118
123
  });
119
124
  };
120
- return /* @__PURE__ */ e(B, {
125
+ return /* @__PURE__ */ e(Y, {
121
126
  title: /* @__PURE__ */ e("div", {
122
127
  className: "vlm-sample-detail-title",
123
128
  children: /* @__PURE__ */ e("span", {
124
- children: u === "preview" ? "详情" : "标注"
129
+ children: v === "preview" ? "详情" : "标注"
125
130
  })
126
131
  }),
127
132
  width: "100%",
128
133
  wrapClassName: "vlm-modal-wrap",
129
134
  className: "vlm-modal",
130
- open: r,
135
+ open: n,
131
136
  destroyOnClose: !0,
132
- onCancel: () => re(),
137
+ onCancel: () => ge(),
133
138
  maskClosable: !1,
134
139
  centered: !0,
135
140
  footer: null,
136
- children: u === "preview" ? /* @__PURE__ */ s(b, {
141
+ children: v === "preview" ? /* @__PURE__ */ s(N, {
137
142
  children: [/* @__PURE__ */ e("div", {
138
143
  className: "vlm-detail",
139
144
  children: /* @__PURE__ */ s("div", {
140
145
  className: "detail-content",
141
- children: [/* @__PURE__ */ e(h, {
146
+ children: [/* @__PURE__ */ e(f, {
142
147
  className: "select-prev",
143
- icon: /* @__PURE__ */ e(H, {
148
+ icon: /* @__PURE__ */ e(ie, {
144
149
  type: "icon-zuojiantou"
145
150
  }),
146
151
  type: "text",
147
- disabled: !g,
152
+ disabled: !p,
148
153
  onClick: () => F()
149
154
  }), /* @__PURE__ */ e("div", {
150
155
  className: "select-main",
151
- ref: ie,
152
- children: i && /* @__PURE__ */ e(Ne, {
156
+ ref: ce,
157
+ children: i && /* @__PURE__ */ e(Ve, {
153
158
  sample: i,
154
159
  labelDefinitions: [],
155
160
  hideRightSide: !0,
156
161
  readOnly: !0,
157
- ocrRecognize: () => N(void 0, null, function* () {
162
+ ocrRecognize: () => g(void 0, null, function* () {
158
163
  return [];
159
164
  })
160
165
  })
161
- }), S && /* @__PURE__ */ s(b, {
162
- children: [/* @__PURE__ */ s("div", {
163
- className: "qa-preview-container",
166
+ }), he ? /* @__PURE__ */ e("div", {
167
+ className: "vqa-preview-panel",
168
+ children: /* @__PURE__ */ e(Qe, {
169
+ question: (B = (K = (E = (z = i == null ? void 0 : i.content) == null ? void 0 : z.conversations) == null ? void 0 : E[0]) == null ? void 0 : K.value) != null ? B : "",
170
+ answer: ($ = (U = (S = (G = i == null ? void 0 : i.content) == null ? void 0 : G.conversations) == null ? void 0 : S[1]) == null ? void 0 : U.value) != null ? $ : "",
171
+ readOnly: !0
172
+ })
173
+ }) : /* @__PURE__ */ s(N, {
174
+ children: [R && /* @__PURE__ */ s(N, {
164
175
  children: [/* @__PURE__ */ s("div", {
165
- className: "qa-preview-header",
166
- children: [/* @__PURE__ */ e("div", {
167
- className: "qa-preview-title",
168
- children: "QA预览"
169
- }), /* @__PURE__ */ e(G, {
170
- children: le && /* @__PURE__ */ e(fe, {
171
- indicator: /* @__PURE__ */ e(he, {
172
- spin: !0,
173
- style: {
174
- fontSize: 16
175
- }
176
+ className: "qa-preview-container",
177
+ children: [/* @__PURE__ */ s("div", {
178
+ className: "qa-preview-header",
179
+ children: [/* @__PURE__ */ e("div", {
180
+ className: "qa-preview-title",
181
+ children: "QA预览"
182
+ }), /* @__PURE__ */ e(Z, {
183
+ children: ue && /* @__PURE__ */ e(Me, {
184
+ indicator: /* @__PURE__ */ e(xe, {
185
+ spin: !0,
186
+ style: {
187
+ fontSize: 16
188
+ }
189
+ })
176
190
  })
177
- })
191
+ })]
192
+ }), /* @__PURE__ */ e("div", {
193
+ className: "qa-preview-content",
194
+ children: (() => {
195
+ var H, J;
196
+ const r = ((H = fe[0]) == null ? void 0 : H.qas) || [];
197
+ return !(((J = i == null ? void 0 : i.labels) == null ? void 0 : J.length) > 0) || r.length === 0 ? /* @__PURE__ */ e("div", {
198
+ className: "result-empty",
199
+ children: "暂无结果"
200
+ }) : /* @__PURE__ */ s(N, {
201
+ children: [/* @__PURE__ */ e(ke, {
202
+ activeKey: String(L),
203
+ onChange: (m) => A(Number(m)),
204
+ items: r.map((m, W) => ({
205
+ key: String(W),
206
+ label: m.name || `模版${W + 1}`
207
+ }))
208
+ }), /* @__PURE__ */ e("div", {
209
+ className: "qa-preview-result",
210
+ children: (() => {
211
+ const m = r[L];
212
+ return m ? /* @__PURE__ */ s("div", {
213
+ className: "result-item-container",
214
+ children: [/* @__PURE__ */ s("div", {
215
+ className: "result-item-content",
216
+ children: [/* @__PURE__ */ e("div", {
217
+ className: "label",
218
+ children: "问题"
219
+ }), /* @__PURE__ */ e("div", {
220
+ className: "value question",
221
+ children: m.q
222
+ })]
223
+ }), /* @__PURE__ */ s("div", {
224
+ className: "result-item-content",
225
+ children: [/* @__PURE__ */ e("div", {
226
+ className: "label",
227
+ children: "回答"
228
+ }), /* @__PURE__ */ e("div", {
229
+ className: "value answer",
230
+ children: m.a
231
+ })]
232
+ })]
233
+ }) : /* @__PURE__ */ e("div", {
234
+ className: "result-empty",
235
+ children: "暂无结果"
236
+ });
237
+ })()
238
+ })]
239
+ });
240
+ })()
178
241
  })]
179
242
  }), /* @__PURE__ */ e("div", {
180
- className: "qa-preview-content",
181
- children: (() => {
182
- var z, E;
183
- const l = ((z = ne[0]) == null ? void 0 : z.qas) || [];
184
- return !(((E = i == null ? void 0 : i.labels) == null ? void 0 : E.length) > 0) || l.length === 0 ? /* @__PURE__ */ e("div", {
185
- className: "result-empty",
186
- children: "暂无结果"
187
- }) : /* @__PURE__ */ s(b, {
188
- children: [/* @__PURE__ */ e(ue, {
189
- activeKey: String(L),
190
- onChange: (m) => R(Number(m)),
191
- items: l.map((m, K) => ({
192
- key: String(K),
193
- label: m.name || `模版${K + 1}`
194
- }))
195
- }), /* @__PURE__ */ e("div", {
196
- className: "qa-preview-result",
197
- children: (() => {
198
- const m = l[L];
199
- return m ? /* @__PURE__ */ s("div", {
200
- className: "result-item-container",
201
- children: [/* @__PURE__ */ s("div", {
202
- className: "result-item-content",
203
- children: [/* @__PURE__ */ e("div", {
204
- className: "label",
205
- children: "问题"
206
- }), /* @__PURE__ */ e("div", {
207
- className: "value question",
208
- children: m.q
209
- })]
210
- }), /* @__PURE__ */ s("div", {
211
- className: "result-item-content",
212
- children: [/* @__PURE__ */ e("div", {
213
- className: "label",
214
- children: "回答"
215
- }), /* @__PURE__ */ e("div", {
216
- className: "value answer",
217
- children: m.a
218
- })]
219
- })]
220
- }) : /* @__PURE__ */ e("div", {
221
- className: "result-empty",
222
- children: "暂无结果"
223
- });
224
- })()
225
- })]
226
- });
227
- })()
243
+ className: "qa-preview-collapsed",
244
+ children: /* @__PURE__ */ e(f, {
245
+ type: "link",
246
+ icon: /* @__PURE__ */ e(be, {}),
247
+ disabled: P,
248
+ onClick: () => b(!1)
249
+ })
228
250
  })]
229
- }), /* @__PURE__ */ e("div", {
251
+ }), !R && /* @__PURE__ */ e("div", {
230
252
  className: "qa-preview-collapsed",
231
- children: /* @__PURE__ */ e(h, {
253
+ children: /* @__PURE__ */ e(f, {
232
254
  type: "link",
233
- icon: /* @__PURE__ */ e(ve, {}),
234
- disabled: j,
235
- onClick: () => x(!1)
255
+ icon: /* @__PURE__ */ e(Ie, {}),
256
+ disabled: P,
257
+ onClick: () => b(!0)
236
258
  })
237
259
  })]
238
- }), !S && /* @__PURE__ */ e("div", {
239
- className: "qa-preview-collapsed",
240
- children: /* @__PURE__ */ e(h, {
241
- type: "link",
242
- icon: /* @__PURE__ */ e(pe, {}),
243
- disabled: j,
244
- onClick: () => x(!0)
245
- })
246
- }), /* @__PURE__ */ e(h, {
260
+ }), /* @__PURE__ */ e(f, {
247
261
  className: "select-next",
248
- icon: /* @__PURE__ */ e(H, {
262
+ icon: /* @__PURE__ */ e(ie, {
249
263
  type: "icon-youjiantou"
250
264
  }),
251
265
  type: "text",
252
- disabled: !g,
253
- onClick: () => P()
266
+ disabled: !p,
267
+ onClick: () => T()
254
268
  })]
255
269
  })
256
270
  }), /* @__PURE__ */ e("div", {
257
271
  className: "vlm-mark-action",
258
- children: /* @__PURE__ */ s(G, {
259
- children: [/* @__PURE__ */ e(h, {
272
+ children: /* @__PURE__ */ s(Z, {
273
+ children: [/* @__PURE__ */ e(f, {
260
274
  type: "primary",
261
- onClick: de,
275
+ onClick: Ne,
262
276
  children: "标注"
263
- }), D && D.delete && /* @__PURE__ */ e(h, {
277
+ }), D && D.delete && /* @__PURE__ */ e(f, {
264
278
  danger: !0,
265
279
  type: "ghost",
266
- onClick: oe,
280
+ onClick: Ce,
267
281
  children: "删除数据"
268
282
  })]
269
283
  })
270
284
  })]
271
285
  }) : (
272
286
  // 标注模式:使用VLMDetail组件
273
- q && /* @__PURE__ */ e(Ce, {
287
+ q && /* @__PURE__ */ e(Le, {
274
288
  ref: M,
275
- visible: r,
276
- selectSampleId: Z,
277
- datasetId: t,
278
- versionId: a,
289
+ visible: n,
290
+ selectSampleId: re,
291
+ datasetId: a,
292
+ versionId: t,
293
+ vlmMarkTmpl: h,
279
294
  onClose: () => {
280
- Q();
295
+ V();
281
296
  },
282
297
  onSave: q,
283
- externalFilterMode: W,
284
- onFilterModeChange: X,
285
- externalSamples: Y,
286
- externalPagination: _,
287
- externalCurrentIndex: ee
298
+ externalFilterMode: te,
299
+ onFilterModeChange: le,
300
+ externalSamples: se,
301
+ externalPagination: oe,
302
+ externalCurrentIndex: de
288
303
  })
289
304
  )
290
305
  });
291
306
  };
292
307
  export {
293
- Oe as default
308
+ Se as default
294
309
  };