Skip to content

Commit

Permalink
Merge pull request #1154 from AI4Bharat/ocr-new1
Browse files Browse the repository at this point in the history
  • Loading branch information
ishvindersethi22 authored Feb 12, 2025
2 parents b769def + 15b30ae commit 27394e5
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 7 deletions.
10 changes: 10 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"react-date-range": "^1.4.0",
"react-dom": "^18.1.0",
"react-drag-drop-files": "^2.3.7",
"react-json-to-html": "^0.0.6",
"react-json-tree": "^0.18.0",
"react-quill": "^2.0.0",
"react-quilljs": "^1.3.3",
Expand Down
51 changes: 48 additions & 3 deletions src/ui/pages/container/Label-Studio/AllTaskLSF.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import conversationVerificationLabelConfig from "../../../../utils/LabelConfig/C
import LightTooltip from "../../component/common/Tooltip";
import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
import getTaskAssignedUsers from '../../../../utils/getTaskAssignedUsers';

import {JsonTable} from 'react-json-to-html';
import {
getProjectsandTasks,
postAnnotation,
Expand All @@ -33,7 +33,7 @@ import "./lsf.css"
import { useDispatch, useSelector } from 'react-redux';
import { translate } from '../../../../config/localisation';
import { labelConfigJS } from './labelConfigJSX';

import DatasetSearchPopupAPI from "../../../../redux/actions/api/Dataset/DatasetSearchPopup";
//used just in postAnnotation to support draft status update.

const LabelStudioWrapper = ({annotationNotesRef, loader, showLoader, hideLoader, resetNotes}) => {
Expand All @@ -59,7 +59,11 @@ const LabelStudioWrapper = ({annotationNotesRef, loader, showLoader, hideLoader,
const [predictions, setPredictions] = useState([]);
const [taskData, setTaskData] = useState(undefined);
const { projectId, taskId } = useParams();
const userData = useSelector(state=>state.fetchLoggedInUserData.data)
const userData = useSelector(state=>state.fetchLoggedInUserData.data);
const filterdataitemsList = useSelector(
(state) => state.datasetSearchPopup.data
);
const [parentMetadata, setParentMetadata] = useState(undefined);
const [assignedUsers, setAssignedUsers] = useState(null);
let loaded = useRef();

Expand All @@ -70,9 +74,19 @@ const LabelStudioWrapper = ({annotationNotesRef, loader, showLoader, hideLoader,
console.log("projectId, taskId", projectId, taskId);
// debugger

useEffect(() => {
if(filterdataitemsList.results !== undefined){
if("image_url" in filterdataitemsList.results[0].metadata_json[0]){
setParentMetadata(filterdataitemsList.results[0].metadata_json[0]);
}
}
}, [filterdataitemsList.results]);

useEffect(() => {
getProjectsandTasks(projectId, taskId).then(
([labelConfig, taskData, annotations, predictions]) => {
const inputData = new DatasetSearchPopupAPI({"instance_ids":labelConfig.datasets[0].instance_id,"dataset_type":"OCRDocument","search_keys":{"id":taskData.input_data}});
dispatch(APITransport(inputData));
let sidePanel = labelConfig?.project_type?.includes("OCRSegmentCategorization") || labelConfig?.project_type?.includes("OCRTranscriptionEditing");
let showLabelsOnly = labelConfig?.project_type?.includes("OCRSegmentCategorization");
let selectAfterCreateOnly = labelConfig?.project_type?.includes("OCRSegmentCategorization");
Expand Down Expand Up @@ -537,6 +551,27 @@ useEffect(() => {
Next
</Button>
</Tooltip>
{parentMetadata !== undefined &&
<>
<Tooltip title="Show Parent Image">
<Button
type="default"
onClick={() => {window.open(parentMetadata.image_url, "_blank")}}
style={{
minWidth: "160px",
border: "1px solid #e6e6e6",
color: "#09f",
pt: 3,
pb: 3,
borderBottom: "None",
}}
className="lsf-button"
>
Parent Image
</Button>
</Tooltip>
</>
}

</>

Expand All @@ -553,6 +588,16 @@ useEffect(() => {
>
<div className="label-studio-root" ref={rootRef}></div>
</Box>
{parentMetadata !== undefined &&
<>
<div style={{textAlign:"center", display:"flex", justifyContent:"center"}}>
<div>
<h3>Parent MetaData</h3>
<JsonTable json={parentMetadata}/>
</div>
</div>
</>
}
{!loader && ProjectDetails?.project_type?.includes("OCRSegmentCategorization") &&
<>
<div style={{borderStyle:"solid", borderWidth:"1px", borderColor:"#E0E0E0", paddingBottom:"1%", display:"flex", justifyContent:"space-around"}}>
Expand Down
48 changes: 47 additions & 1 deletion src/ui/pages/container/Label-Studio/LSF.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import generateLabelConfig from "../../../../utils/LabelConfig/ConversationTrans
import conversationVerificationLabelConfig from "../../../../utils/LabelConfig/ConversationVerification";
// import keymap from "@label-studio/keymap";
import keymap from "./keymap";

import {JsonTable} from 'react-json-to-html';
import {
getProjectsandTasks,
postAnnotation,
Expand All @@ -52,6 +52,7 @@ import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
import getTaskAssignedUsers from "../../../../utils/getTaskAssignedUsers";
import LightTooltip from "../../component/common/Tooltip";
import { addLabelsToBboxes, labelConfigJS } from "./labelConfigJSX";
import DatasetSearchPopupAPI from "../../../../redux/actions/api/Dataset/DatasetSearchPopup";

const filterAnnotations = (
annotations,
Expand Down Expand Up @@ -170,6 +171,9 @@ const LabelStudioWrapper = ({
const rootRef = useRef();
const dispatch = useDispatch();
const ProjectDetails = useSelector((state) => state.getProjectDetails.data);
const filterdataitemsList = useSelector(
(state) => state.datasetSearchPopup.data
);
const annotation_status = useRef(
ProjectDetails.project_stage == 2 ? "labeled" : "labeled"
);
Expand All @@ -190,6 +194,7 @@ const LabelStudioWrapper = ({
const [taskData, setTaskData] = useState(undefined);
const [predictions, setPredictions] = useState([]);
const [annotations, setAnnotations] = useState([]);
const [parentMetadata, setParentMetadata] = useState(undefined);
const load_time = useRef();
const [autoSave, setAutoSave] = useState(true);
let isAudioProject = useRef();
Expand All @@ -201,6 +206,14 @@ const LabelStudioWrapper = ({
setPredictions(taskData?.data?.ocr_prediction_json);
}, [taskData]);

useEffect(() => {
if(filterdataitemsList.results !== undefined){
if("image_url" in filterdataitemsList.results[0].metadata_json[0]){
setParentMetadata(filterdataitemsList.results[0].metadata_json[0]);
}
}
}, [filterdataitemsList.results]);

const [showTagSuggestionsAnchorEl, setShowTagSuggestionsAnchorEl] =
useState(null);
const [tagSuggestionList, setTagSuggestionList] = useState();
Expand All @@ -222,6 +235,8 @@ const LabelStudioWrapper = ({
useEffect(() => {
getProjectsandTasks(projectId, taskId).then(
([labelConfig, taskData, annotations, predictions]) => {
const inputData = new DatasetSearchPopupAPI({"instance_ids":labelConfig.datasets[0].instance_id,"dataset_type":"OCRDocument","search_keys":{"id":taskData.input_data}});
dispatch(APITransport(inputData));
let sidePanel = labelConfig?.project_type?.includes("OCRSegmentCategorization") || labelConfig?.project_type?.includes("OCRTranscriptionEditing");
let showLabelsOnly = labelConfig?.project_type?.includes("OCRSegmentCategorization");
let selectAfterCreateOnly = labelConfig?.project_type?.includes("OCRSegmentCategorization");
Expand Down Expand Up @@ -1126,6 +1141,27 @@ const LabelStudioWrapper = ({
</Tooltip>
</>
}
{parentMetadata !== undefined &&
<>
<Tooltip title="Show Parent Image">
<Button
type="default"
onClick={() => {window.open(parentMetadata.image_url, "_blank")}}
style={{
minWidth: "160px",
border: "1px solid #e6e6e6",
color: "#09f",
pt: 3,
pb: 3,
borderBottom: "None",
}}
className="lsf-button"
>
Parent Image
</Button>
</Tooltip>
</>
}
</Grid>
</Grid>
</div>
Expand All @@ -1148,6 +1184,16 @@ const LabelStudioWrapper = ({
{tagSuggestionList}
</Popover>
</Box>
{parentMetadata !== undefined &&
<>
<div style={{textAlign:"center", display:"flex", justifyContent:"center"}}>
<div>
<h3>Parent MetaData</h3>
<JsonTable json={parentMetadata}/>
</div>
</div>
</>
}
{!loader && ProjectDetails?.project_type?.includes("OCRSegmentCategorization") &&
<>
<div style={{borderStyle:"solid", borderWidth:"1px", borderColor:"#E0E0E0", paddingBottom:"1%", display:"flex", justifyContent:"space-around"}}>
Expand Down
49 changes: 47 additions & 2 deletions src/ui/pages/container/Label-Studio/ReviewLSF.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
import getTaskAssignedUsers from '../../../../utils/getTaskAssignedUsers';
import LightTooltip from "../../component/common/Tooltip";
import keymap from "./keymap";

import {JsonTable} from 'react-json-to-html';
import {
getProjectsandTasks,
getNextProject,
Expand All @@ -54,7 +54,7 @@ import "./lsf.css";
import { useSelector, useDispatch } from "react-redux";
import { translate } from "../../../../config/localisation";
import { addLabelsToBboxes, labelConfigJS } from "./labelConfigJSX";

import DatasetSearchPopupAPI from "../../../../redux/actions/api/Dataset/DatasetSearchPopup";

const StyledMenu = styled((props) => (
<Menu
Expand Down Expand Up @@ -255,6 +255,10 @@ const LabelStudioWrapper = ({
const { projectId, taskId } = useParams();
const userData = useSelector((state) => state.fetchLoggedInUserData.data);
const ProjectDetails = useSelector((state) => state.getProjectDetails.data);
const filterdataitemsList = useSelector(
(state) => state.datasetSearchPopup.data
);
const [parentMetadata, setParentMetadata] = useState(undefined);
let loaded = useRef();
const [showTagSuggestionsAnchorEl, setShowTagSuggestionsAnchorEl] =
useState(null);
Expand All @@ -277,10 +281,20 @@ const LabelStudioWrapper = ({
navigate(`/projects/${projectId}/ReviewAudioTranscriptionLandingPage/${taskId}`);
}
}, [userData]); */

useEffect(() => {
if(filterdataitemsList.results !== undefined){
if("image_url" in filterdataitemsList.results[0].metadata_json[0]){
setParentMetadata(filterdataitemsList.results[0].metadata_json[0]);
}
}
}, [filterdataitemsList.results]);

useEffect(() => {
getProjectsandTasks(projectId, taskId).then(
([labelConfig, taskData, annotations, predictions]) => {
const inputData = new DatasetSearchPopupAPI({"instance_ids":labelConfig.datasets[0].instance_id,"dataset_type":"OCRDocument","search_keys":{"id":taskData.input_data}});
dispatch(APITransport(inputData));
let sidePanel = labelConfig?.project_type?.includes("OCRSegmentCategorization") || labelConfig?.project_type?.includes("OCRTranscriptionEditing");
let showLabelsOnly = labelConfig?.project_type?.includes("OCRSegmentCategorization");
let selectAfterCreateOnly = labelConfig?.project_type?.includes("OCRSegmentCategorization");
Expand Down Expand Up @@ -1360,6 +1374,27 @@ useEffect(() => {
</Button>
</Tooltip>
}
{parentMetadata !== undefined &&
<>
<Tooltip title="Show Parent Image">
<Button
type="default"
onClick={() => {window.open(parentMetadata.image_url, "_blank")}}
style={{
minWidth: "160px",
border: "1px solid #e6e6e6",
color: "#09f",
pt: 3,
pb: 3,
borderBottom: "None",
}}
className="lsf-button"
>
Parent Image
</Button>
</Tooltip>
</>
}
<StyledMenu
id="accept-menu"
MenuListProps={{
Expand Down Expand Up @@ -1409,6 +1444,16 @@ useEffect(() => {
{tagSuggestionList}
</Popover>
</Box>
{parentMetadata !== undefined &&
<>
<div style={{textAlign:"center", display:"flex", justifyContent:"center"}}>
<div>
<h3>Parent MetaData</h3>
<JsonTable json={parentMetadata}/>
</div>
</div>
</>
}
{!loader && ProjectDetails?.project_type?.includes("OCRSegmentCategorization") &&
<>
<div style={{borderStyle:"solid", borderWidth:"1px", borderColor:"#E0E0E0", paddingBottom:"1%", display:"flex", justifyContent:"space-around"}}>
Expand Down
Loading

0 comments on commit 27394e5

Please sign in to comment.