@glodon-aiot/dataset-annotation 3.14.0-alpha.33 → 3.14.0-alpha.34

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