feat(annotator): match task-specific Figma screens
BIN
public/assets/annotators/classification/nh-2.jpg
Normal file
|
After Width: | Height: | Size: 227 KiB |
BIN
public/assets/annotators/classification/nh-3.jpg
Normal file
|
After Width: | Height: | Size: 274 KiB |
BIN
public/assets/annotators/classification/nh-d-li-u.jpg
Normal file
|
After Width: | Height: | Size: 167 KiB |
BIN
public/assets/annotators/classification/nh.jpg
Normal file
|
After Width: | Height: | Size: 319 KiB |
BIN
public/assets/annotators/object-detection/nh-2.jpg
Normal file
|
After Width: | Height: | Size: 167 KiB |
BIN
public/assets/annotators/object-detection/nh-3.jpg
Normal file
|
After Width: | Height: | Size: 227 KiB |
BIN
public/assets/annotators/object-detection/nh-d-li-u.jpg
Normal file
|
After Width: | Height: | Size: 274 KiB |
BIN
public/assets/annotators/object-detection/nh.jpg
Normal file
|
After Width: | Height: | Size: 319 KiB |
BIN
public/assets/annotators/segmentation/nh-2.jpg
Normal file
|
After Width: | Height: | Size: 167 KiB |
BIN
public/assets/annotators/segmentation/nh-3.jpg
Normal file
|
After Width: | Height: | Size: 227 KiB |
BIN
public/assets/annotators/segmentation/nh-d-li-u.jpg
Normal file
|
After Width: | Height: | Size: 274 KiB |
BIN
public/assets/annotators/segmentation/nh.jpg
Normal file
|
After Width: | Height: | Size: 319 KiB |
|
|
@ -2,16 +2,17 @@ import React from 'react'
|
||||||
import { Outlet } from 'react-router-dom'
|
import { Outlet } from 'react-router-dom'
|
||||||
import { Sidebar } from './components/Sidebar/Sidebar'
|
import { Sidebar } from './components/Sidebar/Sidebar'
|
||||||
import { Header } from './components/Header/Header'
|
import { Header } from './components/Header/Header'
|
||||||
|
import { ANNOTATOR_COLORS } from '@/pages/annotator/annotatorTheme'
|
||||||
|
|
||||||
export const AnnotatorLayout: React.FC<{ children?: React.ReactNode }> = ({
|
export const AnnotatorLayout: React.FC<{ children?: React.ReactNode }> = ({
|
||||||
children,
|
children,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen w-screen overflow-hidden bg-[#F8FAFC] text-slate-900">
|
<div className="flex h-screen min-h-0 w-screen overflow-hidden text-slate-900" style={{ backgroundColor: ANNOTATOR_COLORS.canvas }}>
|
||||||
<Sidebar />
|
<Sidebar isProjectWorkspace />
|
||||||
<div className="flex-1 flex flex-col min-w-0 h-full overflow-hidden">
|
<div className="flex min-h-0 min-w-0 flex-1 flex-col">
|
||||||
<Header />
|
<Header isProjectWorkspace />
|
||||||
<main className="flex-1 overflow-hidden">{children || <Outlet />}</main>
|
<main className="min-h-0 flex-1 overflow-y-auto">{children || <Outlet />}</main>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ export interface BreadcrumbProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const PROJECT_NAMES: Record<string, string> = {
|
const PROJECT_NAMES: Record<string, string> = {
|
||||||
|
urban_vehicles_v2: 'Phương tiện đô thị',
|
||||||
|
traffic_camera_v2: 'Giao thông đô thị',
|
||||||
|
street_masks_v1: 'Phân vùng đường phố',
|
||||||
'proj-1': 'Phương tiện đô thị',
|
'proj-1': 'Phương tiện đô thị',
|
||||||
'proj-2': 'Giao thông đô thị',
|
'proj-2': 'Giao thông đô thị',
|
||||||
'proj-3': 'Phân vùng đường phố',
|
'proj-3': 'Phân vùng đường phố',
|
||||||
|
|
@ -18,6 +21,7 @@ const PROJECT_NAMES: Record<string, string> = {
|
||||||
|
|
||||||
export const Breadcrumb: React.FC<BreadcrumbProps> = ({ items }) => {
|
export const Breadcrumb: React.FC<BreadcrumbProps> = ({ items }) => {
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
|
const isProjectWorkspaceScreen = /^\/projects(?:\/[^/]+)?$/.test(location.pathname)
|
||||||
|
|
||||||
const resolvedItems: BreadcrumbItem[] = React.useMemo(() => {
|
const resolvedItems: BreadcrumbItem[] = React.useMemo(() => {
|
||||||
if (items && items.length > 0) return items
|
if (items && items.length > 0) return items
|
||||||
|
|
@ -38,7 +42,7 @@ export const Breadcrumb: React.FC<BreadcrumbProps> = ({ items }) => {
|
||||||
const projName = PROJECT_NAMES[parts[1]] || 'Giao thông đô thị'
|
const projName = PROJECT_NAMES[parts[1]] || 'Giao thông đô thị'
|
||||||
list.push({ label: projName, to: `/projects/${parts[1]}` })
|
list.push({ label: projName, to: `/projects/${parts[1]}` })
|
||||||
if (parts[2] === 'annotate') {
|
if (parts[2] === 'annotate') {
|
||||||
list.push({ label: 'Gán nhãn' })
|
list.push({ label: 'Người gán nhãn' })
|
||||||
} else {
|
} else {
|
||||||
list.push({ label: 'Tổng quan' })
|
list.push({ label: 'Tổng quan' })
|
||||||
}
|
}
|
||||||
|
|
@ -53,10 +57,10 @@ export const Breadcrumb: React.FC<BreadcrumbProps> = ({ items }) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="flex items-center gap-2 text-xs text-slate-500">
|
<nav className="flex items-center gap-2 text-xs text-slate-500">
|
||||||
{location.pathname === '/projects' ? (
|
{isProjectWorkspaceScreen ? (
|
||||||
<img className="h-4 w-4 shrink-0" src="/assets/projects-ui/folder-open.svg" alt="" />
|
<img className="h-4 w-4 shrink-0" src="/assets/projects-ui/folder-open.svg" alt="" />
|
||||||
) : <svg
|
) : <svg
|
||||||
className={`h-4 w-4 shrink-0 ${location.pathname === '/projects' ? 'text-[#697386]' : 'text-slate-400'}`}
|
className="h-4 w-4 shrink-0 text-slate-400"
|
||||||
fill="none"
|
fill="none"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import React, { useEffect } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import { useParams, useSearchParams } from 'react-router-dom'
|
import { useParams } from 'react-router-dom'
|
||||||
import toast from 'react-hot-toast'
|
import toast from 'react-hot-toast'
|
||||||
import { TaskType } from '@/types'
|
|
||||||
import { useAnnotatorStore } from './annotatorStore'
|
import { useAnnotatorStore } from './annotatorStore'
|
||||||
import { AnnotatorHeader } from './components/header/AnnotatorHeader'
|
import { AnnotatorHeader } from './components/header/AnnotatorHeader'
|
||||||
import { ImageInfo } from './components/header/ImageInfo'
|
import { ImageInfo } from './components/header/ImageInfo'
|
||||||
|
|
@ -15,15 +14,13 @@ import { SegmentationPanel } from './components/sidebar-right/SegmentationPanel'
|
||||||
|
|
||||||
export const AnnotatorPage: React.FC = () => {
|
export const AnnotatorPage: React.FC = () => {
|
||||||
const { id } = useParams<{ id: string }>()
|
const { id } = useParams<{ id: string }>()
|
||||||
const [searchParams] = useSearchParams()
|
|
||||||
const taskParam = searchParams.get('task') as TaskType | null
|
|
||||||
|
|
||||||
const project = useAnnotatorStore((s) => s.project)
|
const project = useAnnotatorStore((s) => s.project)
|
||||||
const initProject = useAnnotatorStore((s) => s.initProject)
|
const initProject = useAnnotatorStore((s) => s.initProject)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initProject(id ?? 'proj-1', taskParam ?? undefined)
|
initProject(id ?? 'urban_vehicles_v2')
|
||||||
}, [id, taskParam, initProject])
|
}, [id, initProject])
|
||||||
|
|
||||||
// Global keyboard shortcuts for fast annotation
|
// Global keyboard shortcuts for fast annotation
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -131,16 +128,16 @@ export const AnnotatorPage: React.FC = () => {
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-2">
|
<div className="min-h-full space-y-4 p-6">
|
||||||
{/* Top Project Title & Action Buttons */}
|
{/* Top Project Title & Action Buttons */}
|
||||||
<AnnotatorHeader />
|
<AnnotatorHeader />
|
||||||
|
|
||||||
{/* Main 2-Column Workspace */}
|
{/* Main 2-Column Workspace */}
|
||||||
<div className="grid grid-cols-1 gap-4 lg:grid-cols-12 items-start">
|
<div className="grid grid-cols-1 items-start gap-4 xl:grid-cols-[minmax(0,2.92fr)_minmax(280px,1fr)]">
|
||||||
{/* Left Column: Image Info + Toolbar + Canvas + Navigator */}
|
{/* Left Column: Image Info + Toolbar + Canvas + Navigator */}
|
||||||
<div className="overflow-hidden rounded-2xl border border-slate-200/80 bg-white shadow-2xs lg:col-span-8 xl:col-span-9">
|
<div className="min-w-0 overflow-hidden rounded-xl border border-[#e4e7ef] bg-white shadow-none">
|
||||||
{/* File Name, Resolution & Image Counter Bar */}
|
{/* File Name, Resolution & Image Counter Bar */}
|
||||||
<div className="flex items-center justify-between border-b border-slate-100 px-4 py-2.5">
|
<div className="flex h-[46px] items-center justify-between border-b border-[#e4e7ef] px-4">
|
||||||
<ImageInfo />
|
<ImageInfo />
|
||||||
<ImageCounter />
|
<ImageCounter />
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -156,7 +153,7 @@ export const AnnotatorPage: React.FC = () => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right Column: Task-Specific Panel */}
|
{/* Right Column: Task-Specific Panel */}
|
||||||
<div className="lg:col-span-4 xl:col-span-3">
|
<div className="min-w-0">
|
||||||
{project.taskType === 'classification' && <ClassificationPanel />}
|
{project.taskType === 'classification' && <ClassificationPanel />}
|
||||||
{project.taskType === 'object_detection' && <ObjectListPanel />}
|
{project.taskType === 'object_detection' && <ObjectListPanel />}
|
||||||
{project.taskType === 'segmentation' && <SegmentationPanel />}
|
{project.taskType === 'segmentation' && <SegmentationPanel />}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import {
|
||||||
Project,
|
Project,
|
||||||
TaskType,
|
TaskType,
|
||||||
} from '@/types'
|
} from '@/types'
|
||||||
|
import { getAnnotatorImageUrl } from './annotatorTheme'
|
||||||
import { normalizeBBox } from '@/utils/canvas'
|
import { normalizeBBox } from '@/utils/canvas'
|
||||||
|
|
||||||
// Generate crisp SVG data URLs so the street scenes and objects align pixel-for-pixel with annotations
|
// Generate crisp SVG data URLs so the street scenes and objects align pixel-for-pixel with annotations
|
||||||
|
|
@ -195,9 +196,9 @@ export const DEFAULT_CLASSES: LabelClass[] = [
|
||||||
{ id: 'cls-truck', name: 'Xe tải', color: '#3B82F6', count: 0, shortcutKey: '4' },
|
{ id: 'cls-truck', name: 'Xe tải', color: '#3B82F6', count: 0, shortcutKey: '4' },
|
||||||
]
|
]
|
||||||
|
|
||||||
export const ANNOTATOR_PROJECTS: Record<string, Project> = {
|
export const ANNOTATOR_PROJECTS_BY_ID: Record<string, Project> = {
|
||||||
'proj-1': {
|
urban_vehicles_v2: {
|
||||||
id: 'proj-1',
|
id: 'urban_vehicles_v2',
|
||||||
name: 'Phương tiện đô thị',
|
name: 'Phương tiện đô thị',
|
||||||
slug: 'urban_vehicles_v2',
|
slug: 'urban_vehicles_v2',
|
||||||
description: 'Phân loại phương tiện giao thông đô thị trên đường phố Việt Nam.',
|
description: 'Phân loại phương tiện giao thông đô thị trên đường phố Việt Nam.',
|
||||||
|
|
@ -218,8 +219,8 @@ export const ANNOTATOR_PROJECTS: Record<string, Project> = {
|
||||||
{ id: 'u-2', name: 'Thu Hà', initials: 'TH', color: '#6366F1', role: 'reviewer', assignedCount: 1200 },
|
{ id: 'u-2', name: 'Thu Hà', initials: 'TH', color: '#6366F1', role: 'reviewer', assignedCount: 1200 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'proj-2': {
|
traffic_camera_v2: {
|
||||||
id: 'proj-2',
|
id: 'traffic_camera_v2',
|
||||||
name: 'Giao thông đô thị',
|
name: 'Giao thông đô thị',
|
||||||
slug: 'traffic_camera_v2',
|
slug: 'traffic_camera_v2',
|
||||||
description: 'Khoanh vùng hộp giới hạn các phương tiện giao thông từ camera giám sát.',
|
description: 'Khoanh vùng hộp giới hạn các phương tiện giao thông từ camera giám sát.',
|
||||||
|
|
@ -241,8 +242,8 @@ export const ANNOTATOR_PROJECTS: Record<string, Project> = {
|
||||||
{ id: 'u-2', name: 'Thu Hà', initials: 'TH', color: '#6366F1', role: 'reviewer', assignedCount: 640 },
|
{ id: 'u-2', name: 'Thu Hà', initials: 'TH', color: '#6366F1', role: 'reviewer', assignedCount: 640 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'proj-3': {
|
street_masks_v1: {
|
||||||
id: 'proj-3',
|
id: 'street_masks_v1',
|
||||||
name: 'Phân vùng đường phố',
|
name: 'Phân vùng đường phố',
|
||||||
slug: 'street_masks_v1',
|
slug: 'street_masks_v1',
|
||||||
description: 'Phân vùng đa giác chi tiết phương tiện giao thông phục vụ xe tự hành.',
|
description: 'Phân vùng đa giác chi tiết phương tiện giao thông phục vụ xe tự hành.',
|
||||||
|
|
@ -410,21 +411,18 @@ function getInitialSegmentationShapes(): AnnotationShape[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getImagesForProject(projectId: string, taskType: TaskType): ImageItem[] {
|
export function getImagesForProject(projectId: string, taskType: TaskType): ImageItem[] {
|
||||||
const sedanSvg = createClassificationSedanSvg('29A-888.88')
|
const designImageNames = ['nh-d-li-u.jpg', 'nh.jpg', 'nh-2.jpg', 'nh.jpg', 'nh-3.jpg', 'nh-d-li-u.jpg']
|
||||||
const trafficSvg1 = createTrafficBoulevardSvg(1)
|
const imageUrls = designImageNames.map((fileName) => getAnnotatorImageUrl(taskType, fileName))
|
||||||
const trafficSvg2 = createTrafficBoulevardSvg(2)
|
|
||||||
const truckSvg = createTruckStreetSvg()
|
|
||||||
|
|
||||||
if (taskType === 'classification') {
|
if (taskType === 'classification') {
|
||||||
const baseNums = [124, 125, 126, 127, 128, 129]
|
const baseNums = [124, 125, 126, 127, 128, 129]
|
||||||
const urls = [sedanSvg, trafficSvg1, sedanSvg, trafficSvg2, truckSvg, trafficSvg1]
|
|
||||||
const defaultLabels = ['cls-car', 'cls-bus', 'cls-car', 'cls-motorbike', 'cls-truck', 'cls-bus']
|
const defaultLabels = ['cls-car', 'cls-bus', 'cls-car', 'cls-motorbike', 'cls-truck', 'cls-bus']
|
||||||
return baseNums.map((num, idx) => ({
|
return baseNums.map((num, idx) => ({
|
||||||
id: `${projectId}-img-${num}`,
|
id: `${projectId}-img-${num}`,
|
||||||
projectId,
|
projectId,
|
||||||
fileName: `urban_00${num}.jpg`,
|
fileName: `urban_00${num}.jpg`,
|
||||||
url: urls[idx] ?? sedanSvg,
|
url: imageUrls[idx]!,
|
||||||
thumbnailUrl: urls[idx] ?? sedanSvg,
|
thumbnailUrl: imageUrls[idx]!,
|
||||||
width: 1920,
|
width: 1920,
|
||||||
height: 1080,
|
height: 1080,
|
||||||
status: 'pending_review',
|
status: 'pending_review',
|
||||||
|
|
@ -444,7 +442,6 @@ export function getImagesForProject(projectId: string, taskType: TaskType): Imag
|
||||||
|
|
||||||
const prefix = taskType === 'object_detection' ? 'traffic' : 'street'
|
const prefix = taskType === 'object_detection' ? 'traffic' : 'street'
|
||||||
const baseNums = [321, 322, 323, 324, 325, 326]
|
const baseNums = [321, 322, 323, 324, 325, 326]
|
||||||
const urls = [trafficSvg1, trafficSvg2, sedanSvg, trafficSvg1, truckSvg, trafficSvg2]
|
|
||||||
const defaultStatus: ImageAnnotationStatus =
|
const defaultStatus: ImageAnnotationStatus =
|
||||||
taskType === 'object_detection' ? 'pending_review' : 'in_progress'
|
taskType === 'object_detection' ? 'pending_review' : 'in_progress'
|
||||||
|
|
||||||
|
|
@ -452,8 +449,8 @@ export function getImagesForProject(projectId: string, taskType: TaskType): Imag
|
||||||
id: `${projectId}-img-${num}`,
|
id: `${projectId}-img-${num}`,
|
||||||
projectId,
|
projectId,
|
||||||
fileName: `${prefix}_00${num}.jpg`,
|
fileName: `${prefix}_00${num}.jpg`,
|
||||||
url: urls[idx] ?? trafficSvg1,
|
url: imageUrls[idx]!,
|
||||||
thumbnailUrl: urls[idx] ?? trafficSvg1,
|
thumbnailUrl: imageUrls[idx]!,
|
||||||
width: 1920,
|
width: 1920,
|
||||||
height: 1080,
|
height: 1080,
|
||||||
status: defaultStatus,
|
status: defaultStatus,
|
||||||
|
|
@ -499,8 +496,7 @@ export interface AnnotatorState {
|
||||||
historyFuture: HistorySnapshot[]
|
historyFuture: HistorySnapshot[]
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
initProject: (projectIdOrTask: string, taskOverride?: TaskType) => void
|
initProject: (projectId: string) => void
|
||||||
switchTaskMode: (taskType: TaskType) => void
|
|
||||||
selectImageByIndex: (index: number) => void
|
selectImageByIndex: (index: number) => void
|
||||||
nextImage: () => void
|
nextImage: () => void
|
||||||
prevImage: () => void
|
prevImage: () => void
|
||||||
|
|
@ -547,7 +543,7 @@ function getCurrentTimeHHMM(): string {
|
||||||
return `${hh}:${mm}`
|
return `${hh}:${mm}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildInitialStoreData(project: Project) {
|
function createInitialAnnotationState(project: Project) {
|
||||||
const images = getImagesForProject(project.id, project.taskType)
|
const images = getImagesForProject(project.id, project.taskType)
|
||||||
const shapesByImageId: Record<string, AnnotationShape[]> = {}
|
const shapesByImageId: Record<string, AnnotationShape[]> = {}
|
||||||
const classificationByImageId: Record<string, string> = {}
|
const classificationByImageId: Record<string, string> = {}
|
||||||
|
|
@ -615,38 +611,12 @@ function buildInitialStoreData(project: Project) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useAnnotatorStore = create<AnnotatorState>((set, get) => ({
|
export const useAnnotatorStore = create<AnnotatorState>((set, get) => ({
|
||||||
...buildInitialStoreData(ANNOTATOR_PROJECTS['proj-1']!),
|
...createInitialAnnotationState(ANNOTATOR_PROJECTS_BY_ID.urban_vehicles_v2!),
|
||||||
|
|
||||||
initProject: (projectIdOrTask, taskOverride) => {
|
initProject: (projectId) => {
|
||||||
let matchedProject = ANNOTATOR_PROJECTS[projectIdOrTask]
|
const selectedProject =
|
||||||
|
ANNOTATOR_PROJECTS_BY_ID[projectId] ?? ANNOTATOR_PROJECTS_BY_ID.urban_vehicles_v2!
|
||||||
if (!matchedProject) {
|
set(createInitialAnnotationState(selectedProject))
|
||||||
if (projectIdOrTask.includes('2') || taskOverride === 'object_detection') {
|
|
||||||
matchedProject = ANNOTATOR_PROJECTS['proj-2']
|
|
||||||
} else if (projectIdOrTask.includes('3') || taskOverride === 'segmentation') {
|
|
||||||
matchedProject = ANNOTATOR_PROJECTS['proj-3']
|
|
||||||
} else {
|
|
||||||
matchedProject = ANNOTATOR_PROJECTS['proj-1']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taskOverride && matchedProject && matchedProject.taskType !== taskOverride) {
|
|
||||||
if (taskOverride === 'classification') matchedProject = ANNOTATOR_PROJECTS['proj-1']
|
|
||||||
if (taskOverride === 'object_detection') matchedProject = ANNOTATOR_PROJECTS['proj-2']
|
|
||||||
if (taskOverride === 'segmentation') matchedProject = ANNOTATOR_PROJECTS['proj-3']
|
|
||||||
}
|
|
||||||
|
|
||||||
set(buildInitialStoreData(matchedProject ?? ANNOTATOR_PROJECTS['proj-1']!))
|
|
||||||
},
|
|
||||||
|
|
||||||
switchTaskMode: (taskType) => {
|
|
||||||
const targetProject =
|
|
||||||
taskType === 'classification'
|
|
||||||
? ANNOTATOR_PROJECTS['proj-1']!
|
|
||||||
: taskType === 'object_detection'
|
|
||||||
? ANNOTATOR_PROJECTS['proj-2']!
|
|
||||||
: ANNOTATOR_PROJECTS['proj-3']!
|
|
||||||
set(buildInitialStoreData(targetProject))
|
|
||||||
},
|
},
|
||||||
|
|
||||||
selectImageByIndex: (index) => {
|
selectImageByIndex: (index) => {
|
||||||
|
|
|
||||||
22
src/pages/annotator/annotatorTheme.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { TaskType } from '@/types'
|
||||||
|
|
||||||
|
/** Colors used by the annotation workspace and its active controls. */
|
||||||
|
export const ANNOTATOR_COLORS = {
|
||||||
|
brand: '#c75c4a',
|
||||||
|
brandHover: '#b94f3e',
|
||||||
|
selection: '#5451d6',
|
||||||
|
selectionSoft: '#f5ded6',
|
||||||
|
border: '#e4e7ef',
|
||||||
|
canvas: '#f5f6fa',
|
||||||
|
} as const
|
||||||
|
|
||||||
|
/** Image folders copied from each matching Figma annotation screen. */
|
||||||
|
export const ANNOTATOR_IMAGE_DIRECTORIES: Record<TaskType, string> = {
|
||||||
|
classification: '/assets/annotators/classification',
|
||||||
|
object_detection: '/assets/annotators/object-detection',
|
||||||
|
segmentation: '/assets/annotators/segmentation',
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAnnotatorImageUrl(taskType: TaskType, fileName: string): string {
|
||||||
|
return `${ANNOTATOR_IMAGE_DIRECTORIES[taskType]}/${fileName}`
|
||||||
|
}
|
||||||
|
|
@ -211,7 +211,7 @@ export const AnnotationCanvas: React.FC = () => {
|
||||||
<svg
|
<svg
|
||||||
ref={svgRef}
|
ref={svgRef}
|
||||||
viewBox={`0 0 ${currentImage.width} ${currentImage.height}`}
|
viewBox={`0 0 ${currentImage.width} ${currentImage.height}`}
|
||||||
className="block aspect-video w-full select-none"
|
className="block aspect-[1.925] w-full select-none"
|
||||||
style={{
|
style={{
|
||||||
cursor:
|
cursor:
|
||||||
activeTool === 'bbox' || activeTool === 'polygon' || activeTool === 'point'
|
activeTool === 'bbox' || activeTool === 'polygon' || activeTool === 'point'
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { AnnotationTool } from '@/types'
|
||||||
import { useAnnotatorStore } from '../../annotatorStore'
|
import { useAnnotatorStore } from '../../annotatorStore'
|
||||||
import { UndoRedoButtons } from '../header/UndoRedoButtons'
|
import { UndoRedoButtons } from '../header/UndoRedoButtons'
|
||||||
import { ZoomControls } from './ZoomControls'
|
import { ZoomControls } from './ZoomControls'
|
||||||
|
import { ANNOTATOR_COLORS } from '../../annotatorTheme'
|
||||||
|
|
||||||
export const ToolBar: React.FC = () => {
|
export const ToolBar: React.FC = () => {
|
||||||
const taskType = useAnnotatorStore((s) => s.project.taskType)
|
const taskType = useAnnotatorStore((s) => s.project.taskType)
|
||||||
|
|
@ -66,7 +67,7 @@ export const ToolBar: React.FC = () => {
|
||||||
]
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-between border-b border-slate-100 px-4 py-2">
|
<div className="flex h-11 items-center justify-between border-b border-[#e4e7ef] bg-[#fafbfd] px-3">
|
||||||
<div className="flex items-center gap-1.5">
|
<div className="flex items-center gap-1.5">
|
||||||
{tools.map((tool) => {
|
{tools.map((tool) => {
|
||||||
const isActive = activeTool === tool.id
|
const isActive = activeTool === tool.id
|
||||||
|
|
@ -80,11 +81,12 @@ export const ToolBar: React.FC = () => {
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors',
|
'inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors',
|
||||||
isActive
|
isActive
|
||||||
? 'bg-[#FDECE7] text-[#4F46E5] font-semibold'
|
? 'font-semibold'
|
||||||
: tool.enabled
|
: tool.enabled
|
||||||
? 'text-slate-600 hover:bg-slate-100 hover:text-slate-900'
|
? 'text-slate-600 hover:bg-slate-100 hover:text-slate-900'
|
||||||
: 'cursor-not-allowed text-slate-300'
|
: 'cursor-not-allowed text-slate-300'
|
||||||
)}
|
)}
|
||||||
|
style={isActive ? { backgroundColor: ANNOTATOR_COLORS.selectionSoft, color: ANNOTATOR_COLORS.selection } : undefined}
|
||||||
>
|
>
|
||||||
{tool.icon}
|
{tool.icon}
|
||||||
<span>{tool.label}</span>
|
<span>{tool.label}</span>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
import clsx from 'clsx'
|
|
||||||
import { TaskType } from '@/types'
|
|
||||||
import { TASK_TYPE_LABELS } from '@/app/constants'
|
import { TASK_TYPE_LABELS } from '@/app/constants'
|
||||||
import { formatNumber } from '@/utils/format'
|
import { formatNumber } from '@/utils/format'
|
||||||
import { useAnnotatorStore } from '../../annotatorStore'
|
import { useAnnotatorStore } from '../../annotatorStore'
|
||||||
|
|
@ -10,62 +8,32 @@ import { SaveAndNextButton } from './SaveAndNextButton'
|
||||||
|
|
||||||
export const AnnotatorHeader: React.FC = () => {
|
export const AnnotatorHeader: React.FC = () => {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const project = useAnnotatorStore((s) => s.project)
|
const project = useAnnotatorStore((state) => state.project)
|
||||||
const switchTaskMode = useAnnotatorStore((s) => s.switchTaskMode)
|
|
||||||
|
|
||||||
const taskOptions: { type: TaskType; label: string }[] = [
|
|
||||||
{ type: 'classification', label: 'Classification' },
|
|
||||||
{ type: 'object_detection', label: 'Object Detection' },
|
|
||||||
{ type: 'segmentation', label: 'Segmentation' },
|
|
||||||
]
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-wrap items-center justify-between gap-4 pb-3">
|
<section className="flex flex-wrap items-center justify-between gap-4 pb-1">
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-center gap-3">
|
<h1 className="text-[27px] font-medium tracking-[-1px] text-[#172033]">
|
||||||
<h1 className="text-2xl font-bold tracking-tight text-slate-900">
|
{project.name}
|
||||||
{project.name}
|
</h1>
|
||||||
</h1>
|
<p className="mt-1 text-xs text-[#697386]">
|
||||||
{/* Quick Task Switcher Pill Bar so user can test all 3 Annotator modes effortlessly */}
|
|
||||||
<div className="hidden items-center gap-1 rounded-xl border border-slate-200 bg-white p-0.5 shadow-2xs sm:inline-flex">
|
|
||||||
{taskOptions.map((opt) => {
|
|
||||||
const active = project.taskType === opt.type
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={opt.type}
|
|
||||||
type="button"
|
|
||||||
onClick={() => switchTaskMode(opt.type)}
|
|
||||||
className={clsx(
|
|
||||||
'rounded-lg px-2.5 py-1 text-xs font-medium transition-colors',
|
|
||||||
active
|
|
||||||
? 'bg-[#FDF4F1] text-[#C95C3C] font-semibold'
|
|
||||||
: 'text-slate-500 hover:text-slate-800'
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{opt.label}
|
|
||||||
</button>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p className="mt-0.5 text-xs text-slate-500">
|
|
||||||
{TASK_TYPE_LABELS[project.taskType]} · {project.slug} ·{' '}
|
{TASK_TYPE_LABELS[project.taskType]} · {project.slug} ·{' '}
|
||||||
{formatNumber(project.stats.totalImages)} ảnh
|
{formatNumber(project.stats.totalImages)} ảnh
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-2.5">
|
<div className="flex items-center gap-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => navigate(`/projects/${project.id}`)}
|
onClick={() => navigate(`/projects/${project.id}`)}
|
||||||
className="inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-white px-4 py-2 text-sm font-medium text-slate-700 shadow-2xs transition-colors hover:bg-slate-50"
|
className="inline-flex h-10 items-center gap-2 rounded-lg border border-[#e4e7ef] bg-white px-4 text-[13px] font-semibold text-[#172033] transition-colors hover:bg-slate-50"
|
||||||
>
|
>
|
||||||
<span>←</span>
|
<span aria-hidden="true">←</span>
|
||||||
<span>Về tổng quan</span>
|
<span>Về tổng quan</span>
|
||||||
</button>
|
</button>
|
||||||
<SaveButton />
|
<SaveButton />
|
||||||
<SaveAndNextButton />
|
<SaveAndNextButton />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import toast from 'react-hot-toast'
|
import toast from 'react-hot-toast'
|
||||||
import { useAnnotatorStore } from '../../annotatorStore'
|
import { useAnnotatorStore } from '../../annotatorStore'
|
||||||
|
import { ANNOTATOR_COLORS } from '../../annotatorTheme'
|
||||||
|
|
||||||
export const SaveAndNextButton: React.FC = () => {
|
export const SaveAndNextButton: React.FC = () => {
|
||||||
const saveAndNext = useAnnotatorStore((s) => s.saveAndNext)
|
const saveAndNext = useAnnotatorStore((s) => s.saveAndNext)
|
||||||
|
|
@ -16,7 +17,10 @@ export const SaveAndNextButton: React.FC = () => {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={handleSaveAndNext}
|
onClick={handleSaveAndNext}
|
||||||
className="inline-flex items-center gap-2 rounded-xl bg-[#C95C3C] px-4 py-2 text-sm font-medium text-white shadow-sm transition-colors hover:bg-[#B5492B] focus:outline-none focus:ring-2 focus:ring-[#C95C3C]/30"
|
className="inline-flex h-10 items-center gap-2 rounded-lg bg-[#c75c4a] px-4 text-[13px] font-semibold text-white transition-colors hover:bg-[#b94f3e] focus:outline-none focus:ring-2 focus:ring-[#c75c4a]/30"
|
||||||
|
style={{ backgroundColor: ANNOTATOR_COLORS.brand }}
|
||||||
|
onMouseEnter={(event) => { event.currentTarget.style.backgroundColor = ANNOTATOR_COLORS.brandHover }}
|
||||||
|
onMouseLeave={(event) => { event.currentTarget.style.backgroundColor = ANNOTATOR_COLORS.brand }}
|
||||||
>
|
>
|
||||||
<span>→</span>
|
<span>→</span>
|
||||||
<span>Lưu & ảnh tiếp</span>
|
<span>Lưu & ảnh tiếp</span>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import toast from 'react-hot-toast'
|
import toast from 'react-hot-toast'
|
||||||
import { useAnnotatorStore } from '../../annotatorStore'
|
import { useAnnotatorStore } from '../../annotatorStore'
|
||||||
|
import { ANNOTATOR_COLORS } from '../../annotatorTheme'
|
||||||
|
|
||||||
export const SaveButton: React.FC = () => {
|
export const SaveButton: React.FC = () => {
|
||||||
const saveCurrentAnnotation = useAnnotatorStore((s) => s.saveCurrentAnnotation)
|
const saveCurrentAnnotation = useAnnotatorStore((s) => s.saveCurrentAnnotation)
|
||||||
|
|
@ -15,7 +16,10 @@ export const SaveButton: React.FC = () => {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={handleSave}
|
onClick={handleSave}
|
||||||
className="inline-flex items-center gap-2 rounded-xl bg-[#C95C3C] px-4 py-2 text-sm font-medium text-white shadow-sm transition-colors hover:bg-[#B5492B] focus:outline-none focus:ring-2 focus:ring-[#C95C3C]/30"
|
className="inline-flex h-10 items-center gap-2 rounded-lg bg-[#c75c4a] px-4 text-[13px] font-semibold text-white transition-colors hover:bg-[#b94f3e] focus:outline-none focus:ring-2 focus:ring-[#c75c4a]/30"
|
||||||
|
style={{ backgroundColor: ANNOTATOR_COLORS.brand }}
|
||||||
|
onMouseEnter={(event) => { event.currentTarget.style.backgroundColor = ANNOTATOR_COLORS.brandHover }}
|
||||||
|
onMouseLeave={(event) => { event.currentTarget.style.backgroundColor = ANNOTATOR_COLORS.brand }}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
className="h-4 w-4 text-white/90"
|
className="h-4 w-4 text-white/90"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { useAnnotatorStore } from '../../annotatorStore'
|
import { useAnnotatorStore } from '../../annotatorStore'
|
||||||
|
import { ANNOTATOR_COLORS } from '../../annotatorTheme'
|
||||||
|
|
||||||
export const ThumbnailStrip: React.FC = () => {
|
export const ThumbnailStrip: React.FC = () => {
|
||||||
const images = useAnnotatorStore((s) => s.images)
|
const images = useAnnotatorStore((s) => s.images)
|
||||||
|
|
@ -25,9 +26,10 @@ export const ThumbnailStrip: React.FC = () => {
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'relative aspect-video w-full overflow-hidden rounded-lg border-2 transition-all',
|
'relative aspect-video w-full overflow-hidden rounded-lg border-2 transition-all',
|
||||||
isActive
|
isActive
|
||||||
? 'border-[#4F46E5] shadow-xs'
|
? 'shadow-xs'
|
||||||
: 'border-transparent opacity-85 hover:opacity-100'
|
: 'border-transparent opacity-85 hover:opacity-100'
|
||||||
)}
|
)}
|
||||||
|
style={isActive ? { borderColor: ANNOTATOR_COLORS.selection } : undefined}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src={img.thumbnailUrl}
|
src={img.thumbnailUrl}
|
||||||
|
|
@ -40,9 +42,10 @@ export const ThumbnailStrip: React.FC = () => {
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'font-mono text-[10px] transition-colors',
|
'font-mono text-[10px] transition-colors',
|
||||||
isActive
|
isActive
|
||||||
? 'font-semibold text-[#4F46E5]'
|
? 'font-semibold'
|
||||||
: 'text-slate-400 group-hover:text-slate-600'
|
: 'text-slate-400 group-hover:text-slate-600'
|
||||||
)}
|
)}
|
||||||
|
style={isActive ? { color: ANNOTATOR_COLORS.selection } : undefined}
|
||||||
>
|
>
|
||||||
{shortName}
|
{shortName}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||