Skip to content

Commit 9210ee5

Browse files
authored
Merge pull request #150 from IDEA-Research/dev
Release: v0.12.0
2 parents 0a1b61f + 90a2c81 commit 9210ee5

18 files changed

+323
-155
lines changed

deepdataspace/server/static/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<meta name="description" content="cvr">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
77
<link rel="shortcut icon" href="/static/favicon.png">
8-
<link rel="stylesheet" href="/static/umi.99ffc894.css">
8+
<link rel="stylesheet" href="/static/umi.e762716e.css">
99
</head>
1010
<body>
1111
<div id="root"></div>
12-
<script src="/static/umi.d5355c89.js"></script>
12+
<script src="/static/umi.d97b8209.js"></script>
1313

1414
</body></html>

deepdataspace/server/static/p__Annotator__index.1fc40bde.async.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deepdataspace/server/static/p__Annotator__index.8750e2fd.async.js

-1
This file was deleted.

deepdataspace/server/static/p__Dataset__index.a1265ad5.async.js deepdataspace/server/static/p__Dataset__index.419888be.async.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deepdataspace/server/static/p__Lab__FlagTool__index.91ecbc6f.async.js deepdataspace/server/static/p__Lab__FlagTool__index.c0cac9b9.async.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deepdataspace/server/static/p__Project__Workspace__index.afc69f7b.async.js deepdataspace/server/static/p__Project__Workspace__index.2c2baf46.async.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deepdataspace/server/static/umi.d5355c89.js deepdataspace/server/static/umi.d97b8209.js

+135-135
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deepdataspace/server/static/umi.99ffc894.css deepdataspace/server/static/umi.e762716e.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deepdataspace/server/templates/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<meta name="description" content="cvr">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
77
<link rel="shortcut icon" href="/static/favicon.png">
8-
<link rel="stylesheet" href="/static/umi.99ffc894.css">
8+
<link rel="stylesheet" href="/static/umi.e762716e.css">
99
</head>
1010
<body>
1111
<div id="root"></div>
12-
<script src="/static/umi.d5355c89.js"></script>
12+
<script src="/static/umi.d97b8209.js"></script>
1313

1414
</body></html>

packages/app/src/locales/en-US.ts

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ const localeTexts = {
102102
'dataset.detail.pagination': 'Pagination',
103103
'dataset.detail.random': 'Random',
104104
'dataset.detail.randomQuery': 'Random',
105+
'dataset.detail.showGrounding': 'Show Grounding',
106+
'dataset.detail.hideGrounding': 'Hide Grounding',
105107

106108
'dataset.toAnalysis.unSupportWarn':
107109
'You should have a prediction label set with detection annotaion first',

packages/app/src/locales/zh-CN.ts

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ const localeTexts = {
100100
'dataset.toAnalysis.unSelectWarn': '请选择一个预标注集',
101101
'dataset.onClickCopyLink.success': '复制链接成功!',
102102
'dataset.detail.overlay': '覆盖',
103+
'dataset.detail.showGrounding': '展示 Grounding',
104+
'dataset.detail.hideGrounding': '隐藏 Grounding',
103105

104106
'dataset.filter.newDataset': '新建数据集',
105107
'dataset.filter.public': '公共',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.dds-annotator-highlight-text .ant-tag {
2+
margin-inline-end: 0px !important;
3+
font-size: 14px;
4+
cursor: pointer;
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import React, { useMemo } from 'react';
2+
import { escapeRegExp } from 'lodash';
3+
import { Tag } from 'antd';
4+
5+
import './index.less';
6+
7+
interface IHighlight {
8+
text: string;
9+
color: string;
10+
}
11+
12+
interface IProps {
13+
text: string;
14+
highlights: IHighlight[];
15+
onHoverHighlightWord: (text: string) => void;
16+
onLeaveHighlightWord: () => void;
17+
}
18+
19+
const HighlightText: React.FC<IProps> = ({
20+
text,
21+
highlights,
22+
onHoverHighlightWord,
23+
onLeaveHighlightWord,
24+
}) => {
25+
26+
const segments = useMemo(() => {
27+
const computedSegments: React.ReactNode[] = [];
28+
const pattern = new RegExp(
29+
highlights.map(h => `\\b(${escapeRegExp(h.text)})\\b`).join('|'),
30+
'g'
31+
);
32+
33+
const matches = Array.from(text.matchAll(pattern));
34+
let lastIndex = 0;
35+
36+
matches.forEach(match => {
37+
const matchText = match[0];
38+
const index = match.index ?? 0;
39+
40+
if (index > lastIndex) {
41+
computedSegments.push(text.substring(lastIndex, index));
42+
}
43+
44+
const highlightConfig = highlights.find(h => h.text === matchText);
45+
46+
if (highlightConfig) {
47+
computedSegments.push(
48+
<Tag
49+
key={`${index}-${matchText}`}
50+
color={highlightConfig.color}
51+
bordered={false}
52+
onMouseEnter={() => onHoverHighlightWord(matchText)}
53+
onMouseLeave={onLeaveHighlightWord}
54+
>
55+
{matchText}
56+
</Tag>
57+
);
58+
}
59+
60+
lastIndex = index + matchText.length;
61+
});
62+
63+
if (lastIndex < text.length) {
64+
computedSegments.push(text.substring(lastIndex));
65+
}
66+
67+
return computedSegments;
68+
}, [text, highlights, onHoverHighlightWord, onLeaveHighlightWord]);
69+
70+
return <div className={'dds-annotator-highlight-text'}>{segments}</div>;
71+
};
72+
73+
export default HighlightText;

packages/components/src/Annotator/hooks/useCanvasRender.tsx

+18-4
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ const useCanvasRender = ({
167167
} else if (
168168
theDrawData.selectedTool === EBasicToolItem.Rectangle &&
169169
theDrawData.selectedModel[theDrawData.selectedTool] ===
170-
EnumModelType.IVP
170+
EnumModelType.IVP
171171
) {
172172
objectHooksMap[EObjectType.Rectangle].renderPrompt({
173173
prompt,
@@ -213,8 +213,8 @@ const useCanvasRender = ({
213213
const status = isFocus
214214
? 'focus'
215215
: isJustCreated
216-
? 'justCreated'
217-
: undefined;
216+
? 'justCreated'
217+
: undefined;
218218
const styles = getObjectStyles(object, object.color, status);
219219

220220
// Change globalAlpha when creating / editing object
@@ -315,6 +315,20 @@ const useCanvasRender = ({
315315
false,
316316
);
317317
}
318+
319+
// render highlight object when hover caption
320+
if (!!drawData.highlightCategory) {
321+
const highlights = theDrawData.objectList
322+
.filter(obj => obj.labelId === drawData.highlightCategory!.id);
323+
324+
highlights.forEach((obj) => {
325+
renderObject(
326+
obj,
327+
true,
328+
false
329+
);
330+
});
331+
}
318332
};
319333

320334
const renderPopoverMenu = () => {
@@ -327,7 +341,7 @@ const useCanvasRender = ({
327341
) {
328342
const target =
329343
drawData.objectList[editState.focusObjectIndex].keypoints?.points?.[
330-
editState.focusEleIndex
344+
editState.focusEleIndex
331345
];
332346
if (target) {
333347
return (

packages/components/src/Annotator/index.less

+13-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@
204204

205205
.switch {
206206
position: absolute;
207-
bottom: 40px;
207+
top: 25px;
208208
display: flex;
209209
align-items: center;
210210
justify-content: center;
@@ -331,6 +331,18 @@
331331
transform: rotate(180deg);
332332
}
333333
}
334+
335+
.dds-annotator-grounding-preview {
336+
position: absolute;
337+
bottom: 20px;
338+
left: 50%;
339+
transform: translate(-50%, 0);
340+
background: rgba(0, 0, 0, 0.45);
341+
color: #fff;
342+
width: 70%;
343+
padding: 10px;
344+
border-radius: 10px;
345+
}
334346
}
335347

336348
.dds-annotator-view {

0 commit comments

Comments
 (0)