Skip to content

Commit

Permalink
Merge pull request #150 from IDEA-Research/dev
Browse files Browse the repository at this point in the history
Release: v0.12.0
  • Loading branch information
cefeng06 committed Apr 9, 2024
2 parents 0a1b61f + 90a2c81 commit 9210ee5
Show file tree
Hide file tree
Showing 18 changed files with 323 additions and 155 deletions.
4 changes: 2 additions & 2 deletions deepdataspace/server/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<meta name="description" content="cvr">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="shortcut icon" href="/static/favicon.png">
<link rel="stylesheet" href="/static/umi.99ffc894.css">
<link rel="stylesheet" href="/static/umi.e762716e.css">
</head>
<body>
<div id="root"></div>
<script src="/static/umi.d5355c89.js"></script>
<script src="/static/umi.d97b8209.js"></script>

</body></html>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions deepdataspace/server/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<meta name="description" content="cvr">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="shortcut icon" href="/static/favicon.png">
<link rel="stylesheet" href="/static/umi.99ffc894.css">
<link rel="stylesheet" href="/static/umi.e762716e.css">
</head>
<body>
<div id="root"></div>
<script src="/static/umi.d5355c89.js"></script>
<script src="/static/umi.d97b8209.js"></script>

</body></html>
2 changes: 2 additions & 0 deletions packages/app/src/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const localeTexts = {
'dataset.detail.pagination': 'Pagination',
'dataset.detail.random': 'Random',
'dataset.detail.randomQuery': 'Random',
'dataset.detail.showGrounding': 'Show Grounding',
'dataset.detail.hideGrounding': 'Hide Grounding',

'dataset.toAnalysis.unSupportWarn':
'You should have a prediction label set with detection annotaion first',
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ const localeTexts = {
'dataset.toAnalysis.unSelectWarn': '请选择一个预标注集',
'dataset.onClickCopyLink.success': '复制链接成功!',
'dataset.detail.overlay': '覆盖',
'dataset.detail.showGrounding': '展示 Grounding',
'dataset.detail.hideGrounding': '隐藏 Grounding',

'dataset.filter.newDataset': '新建数据集',
'dataset.filter.public': '公共',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.dds-annotator-highlight-text .ant-tag {
margin-inline-end: 0px !important;
font-size: 14px;
cursor: pointer;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, { useMemo } from 'react';
import { escapeRegExp } from 'lodash';
import { Tag } from 'antd';

import './index.less';

interface IHighlight {
text: string;
color: string;
}

interface IProps {
text: string;
highlights: IHighlight[];
onHoverHighlightWord: (text: string) => void;
onLeaveHighlightWord: () => void;
}

const HighlightText: React.FC<IProps> = ({
text,
highlights,
onHoverHighlightWord,
onLeaveHighlightWord,
}) => {

const segments = useMemo(() => {
const computedSegments: React.ReactNode[] = [];
const pattern = new RegExp(
highlights.map(h => `\\b(${escapeRegExp(h.text)})\\b`).join('|'),
'g'
);

const matches = Array.from(text.matchAll(pattern));
let lastIndex = 0;

matches.forEach(match => {
const matchText = match[0];
const index = match.index ?? 0;

if (index > lastIndex) {
computedSegments.push(text.substring(lastIndex, index));
}

const highlightConfig = highlights.find(h => h.text === matchText);

if (highlightConfig) {
computedSegments.push(
<Tag
key={`${index}-${matchText}`}
color={highlightConfig.color}
bordered={false}
onMouseEnter={() => onHoverHighlightWord(matchText)}
onMouseLeave={onLeaveHighlightWord}
>
{matchText}
</Tag>
);
}

lastIndex = index + matchText.length;
});

if (lastIndex < text.length) {
computedSegments.push(text.substring(lastIndex));
}

return computedSegments;
}, [text, highlights, onHoverHighlightWord, onLeaveHighlightWord]);

return <div className={'dds-annotator-highlight-text'}>{segments}</div>;
};

export default HighlightText;
22 changes: 18 additions & 4 deletions packages/components/src/Annotator/hooks/useCanvasRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const useCanvasRender = ({
} else if (
theDrawData.selectedTool === EBasicToolItem.Rectangle &&
theDrawData.selectedModel[theDrawData.selectedTool] ===
EnumModelType.IVP
EnumModelType.IVP
) {
objectHooksMap[EObjectType.Rectangle].renderPrompt({
prompt,
Expand Down Expand Up @@ -213,8 +213,8 @@ const useCanvasRender = ({
const status = isFocus
? 'focus'
: isJustCreated
? 'justCreated'
: undefined;
? 'justCreated'
: undefined;
const styles = getObjectStyles(object, object.color, status);

// Change globalAlpha when creating / editing object
Expand Down Expand Up @@ -315,6 +315,20 @@ const useCanvasRender = ({
false,
);
}

// render highlight object when hover caption
if (!!drawData.highlightCategory) {
const highlights = theDrawData.objectList
.filter(obj => obj.labelId === drawData.highlightCategory!.id);

highlights.forEach((obj) => {
renderObject(
obj,
true,
false
);
});
}
};

const renderPopoverMenu = () => {
Expand All @@ -327,7 +341,7 @@ const useCanvasRender = ({
) {
const target =
drawData.objectList[editState.focusObjectIndex].keypoints?.points?.[
editState.focusEleIndex
editState.focusEleIndex
];
if (target) {
return (
Expand Down
14 changes: 13 additions & 1 deletion packages/components/src/Annotator/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@

.switch {
position: absolute;
bottom: 40px;
top: 25px;
display: flex;
align-items: center;
justify-content: center;
Expand Down Expand Up @@ -331,6 +331,18 @@
transform: rotate(180deg);
}
}

.dds-annotator-grounding-preview {
position: absolute;
bottom: 20px;
left: 50%;
transform: translate(-50%, 0);
background: rgba(0, 0, 0, 0.45);
color: #fff;
width: 70%;
padding: 10px;
border-radius: 10px;
}
}

.dds-annotator-view {
Expand Down

0 comments on commit 9210ee5

Please sign in to comment.