lost-sia 3.1.2 → 3.2.0-alpha0

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.
Files changed (50) hide show
  1. package/dist/Annotation/ui/tools/Line.js +1 -1
  2. package/dist/Annotation/ui/tools/Polygon.js +1 -1
  3. package/dist/Canvas/Canvas.js +1 -1
  4. package/dist/Sia.js +1 -1
  5. package/dist/SiaViewer.d.ts +19 -0
  6. package/dist/SiaViewer.js +1 -0
  7. package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.d.ts +1 -1
  8. package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.js +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +1 -1
  11. package/dist/stories/Canvas/Canvas.stories.d.ts +3 -3
  12. package/dist/stories/Canvas/CanvasWithOffset.stories.d.ts +6 -6
  13. package/dist/stories/SIA/SiaViewer.stories.d.ts +52 -0
  14. package/dist/types.d.ts +1 -0
  15. package/package.json +3 -4
  16. package/src/Annotation/ui/tools/Line.tsx +8 -0
  17. package/src/Annotation/ui/tools/Polygon.tsx +11 -0
  18. package/src/Canvas/Canvas.tsx +42 -19
  19. package/src/Sia.tsx +1 -1
  20. package/src/SiaViewer.tsx +125 -0
  21. package/src/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.tsx +7 -8
  22. package/src/Toolbar/ToolbarItems/ImageTools.tsx +2 -0
  23. package/src/index.ts +1 -1
  24. package/src/stories/SIA/SiaViewer.stories.tsx +105 -0
  25. package/src/stories/exampleData/exampleExternalAnnotations.ts +22 -22
  26. package/src/types.ts +1 -0
  27. package/dist/assets/brand-icons-Cu_C0hZ4.svg +0 -1008
  28. package/dist/assets/brand-icons-F3SPCeH1.woff +0 -0
  29. package/dist/assets/brand-icons-XL9sxUpA.woff2 +0 -0
  30. package/dist/assets/brand-icons-sqJ2Pg7a.eot +0 -0
  31. package/dist/assets/brand-icons-ubhWoxly.ttf +0 -0
  32. package/dist/assets/flags-DOLqOU7Y.png +0 -0
  33. package/dist/assets/icons-BOCtAERH.woff +0 -0
  34. package/dist/assets/icons-CHzK1VD9.eot +0 -0
  35. package/dist/assets/icons-D29ZQHHw.ttf +0 -0
  36. package/dist/assets/icons-Du6TOHnR.woff2 +0 -0
  37. package/dist/assets/icons-RwhydX30.svg +0 -1518
  38. package/dist/assets/node_modules/semantic-ui-css/semantic.min-09YPtVE6.css +0 -1
  39. package/dist/assets/outline-icons-BfdLr8tr.svg +0 -366
  40. package/dist/assets/outline-icons-DD8jm0uy.ttf +0 -0
  41. package/dist/assets/outline-icons-DInHoiqI.woff2 +0 -0
  42. package/dist/assets/outline-icons-LX8adJ4n.eot +0 -0
  43. package/dist/assets/outline-icons-aQ88nltS.woff +0 -0
  44. package/src/AnnoExampleViewer.jsx +0 -69
  45. package/src/InfoBoxes/AnnoDetails.jsx +0 -165
  46. package/src/InfoBoxes/AnnoStats.jsx +0 -106
  47. package/src/InfoBoxes/InfoBox.jsx +0 -76
  48. package/src/InfoBoxes/InfoBoxArea.jsx +0 -152
  49. package/src/InfoBoxes/LabelInfo.jsx +0 -107
  50. package/src/SIASettingButton.jsx +0 -126
@@ -11,13 +11,12 @@ import {
11
11
  import { Label } from '../../../types'
12
12
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
13
13
  import { faTag } from '@fortawesome/free-solid-svg-icons'
14
- import { IconProps } from 'semantic-ui-react'
15
14
  import TagLabel from './TagLabel'
16
15
 
17
16
  type ImageLabelInputProps = {
18
17
  isDisabled: boolean
19
18
  isVisible: boolean
20
- selectedLabelsIds: number[]
19
+ selectedLabelsIds: number[] | undefined
21
20
  possibleLabels: Label[]
22
21
  isMultilabel?: boolean
23
22
  onLabelSelect: (selectedLabelIds: number[]) => void
@@ -41,9 +40,9 @@ const ImageLabelInput = ({
41
40
  let newLabelIds: number[] = []
42
41
 
43
42
  if (isMultilabel) {
44
- newLabelIds = [...selectedLabelsIds]
43
+ newLabelIds = [...(selectedLabelsIds ?? [])]
45
44
  // check if item in list (get its index if so)
46
- const foundIndex: number = selectedLabelsIds.indexOf(clickedLabel.id)
45
+ const foundIndex: number = (selectedLabelsIds ?? []).indexOf(clickedLabel.id)
47
46
  // add label if not in list, remove label if in list
48
47
  if (foundIndex === -1) {
49
48
  newLabelIds.push(clickedLabel.id)
@@ -59,17 +58,17 @@ const ImageLabelInput = ({
59
58
 
60
59
  const getSelectedLabels = () => {
61
60
  const selectedLabels: Label[] = possibleLabels.filter((label: Label) =>
62
- selectedLabelsIds.includes(label.id),
61
+ selectedLabelsIds?.includes(label.id),
63
62
  )
64
63
 
65
64
  return selectedLabels
66
65
  }
67
66
 
68
67
  const renderLabels = () => {
69
- if (selectedLabelsIds.length === 0)
68
+ if (!selectedLabelsIds || selectedLabelsIds.length === 0)
70
69
  return (
71
70
  <div style={{ marginTop: 6 }}>
72
- <FontAwesomeIcon icon={faTag as IconProps} />
71
+ <FontAwesomeIcon icon={faTag} />
73
72
  </div>
74
73
  )
75
74
 
@@ -88,7 +87,7 @@ const ImageLabelInput = ({
88
87
 
89
88
  return (
90
89
  <CTooltip content="Add Image Label">
91
- <CDropdown visible={isVisible} autoClose={false}>
90
+ <CDropdown visible={isVisible} autoClose="outside">
92
91
  {/* this invisible toggle has to be here, othervise the menu is not showing as intended */}
93
92
  <CDropdownToggle
94
93
  variant="outline"
@@ -29,6 +29,8 @@ const ImageTools = ({
29
29
  const [isLabelPopupVisible, setIsLabelPopupVisible] = useState<boolean>(false)
30
30
 
31
31
  // close modal when the fullscreen state changes
32
+ // NOTE: imageLabelIds intentionally excluded — adding it would close the dropdown on every
33
+ // label click in multi-label mode, before the user finishes selecting labels.
32
34
  useEffect(() => {
33
35
  setIsLabelPopupVisible(false)
34
36
  }, [isFullscreen])
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- import 'semantic-ui-css/semantic.min.css'
2
1
  import './SIA.scss'
3
2
 
4
3
  // export all type definitions
@@ -6,5 +5,6 @@ export * from './types'
6
5
 
7
6
  export { default as IconButton } from './IconButton'
8
7
  export { default as Sia } from './Sia'
8
+ export { default as SiaViewer } from './SiaViewer'
9
9
  export { default as transform } from './utils/transform'
10
10
  export { default as TagLabel } from './Toolbar/ToolbarItems/ImageToolItems/TagLabel'
@@ -0,0 +1,105 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+
3
+ import SiaViewer from '../../SiaViewer'
4
+
5
+ import exampleImage from '../exampleData/exampleImage'
6
+ import exampleLabels from '../exampleData/exampleLabels'
7
+ import exampleExternalAnnotations from '../exampleData/exampleExternalAnnotations'
8
+
9
+ export const ActionsData = {}
10
+
11
+ const meta = {
12
+ title: 'Components/SiaViewer',
13
+ component: SiaViewer,
14
+ parameters: {
15
+ layout: 'fullscreen',
16
+ },
17
+ tags: ['!autodocs'],
18
+ excludeStories: /.*Data$/,
19
+ args: {
20
+ ...ActionsData,
21
+ },
22
+ } satisfies Meta<typeof SiaViewer>
23
+
24
+ export default meta
25
+ type Story = StoryObj<typeof meta>
26
+
27
+ const defaultArgs = {
28
+ ...ActionsData,
29
+ image: exampleImage,
30
+ possibleLabels: exampleLabels.voc,
31
+ }
32
+
33
+ /**
34
+ * SiaViewer with point annotations. No toolbar, no editing.
35
+ * Try clicking annotations to select them and scrolling to zoom.
36
+ */
37
+ export const WithPointAnnotations: Story = {
38
+ args: {
39
+ ...defaultArgs,
40
+ annotations: exampleExternalAnnotations.point,
41
+ },
42
+ }
43
+
44
+ /**
45
+ * SiaViewer with bbox annotations.
46
+ */
47
+ export const WithBBoxAnnotations: Story = {
48
+ args: {
49
+ ...defaultArgs,
50
+ annotations: exampleExternalAnnotations.bbox,
51
+ },
52
+ }
53
+
54
+ /**
55
+ * SiaViewer with line annotations.
56
+ */
57
+ export const WithLineAnnotations: Story = {
58
+ args: {
59
+ ...defaultArgs,
60
+ annotations: exampleExternalAnnotations.line,
61
+ },
62
+ }
63
+
64
+ /**
65
+ * SiaViewer with polygon annotations.
66
+ */
67
+ export const WithPolygonAnnotations: Story = {
68
+ args: {
69
+ ...defaultArgs,
70
+ annotations: exampleExternalAnnotations.polygon,
71
+ },
72
+ }
73
+
74
+ /**
75
+ * SiaViewer with zoom disabled.
76
+ */
77
+ export const ZoomDisabled: Story = {
78
+ args: {
79
+ ...defaultArgs,
80
+ annotations: exampleExternalAnnotations.polygon,
81
+ enableZoom: false,
82
+ },
83
+ }
84
+
85
+ /**
86
+ * SiaViewer with selection disabled. Annotations cannot be clicked.
87
+ */
88
+ export const SelectionDisabled: Story = {
89
+ args: {
90
+ ...defaultArgs,
91
+ annotations: exampleExternalAnnotations.polygon,
92
+ canSelect: false,
93
+ },
94
+ }
95
+
96
+ /**
97
+ * SiaViewer marked as junk.
98
+ */
99
+ export const Junk: Story = {
100
+ args: {
101
+ ...defaultArgs,
102
+ annotations: exampleExternalAnnotations.polygon,
103
+ isJunk: true,
104
+ },
105
+ }
@@ -37,10 +37,10 @@ const point: ExternalAnnotation[] = [
37
37
  const line: ExternalAnnotation[] = [
38
38
  {
39
39
  coordinates: [
40
- { x: 50, y: 50 },
41
- { x: 200, y: 100 },
42
- { x: 250, y: 100 },
43
- { x: 250, y: 200 },
40
+ { x: 0.05, y: 0.05 },
41
+ { x: 0.2, y: 0.1 },
42
+ { x: 0.25, y: 0.1 },
43
+ { x: 0.25, y: 0.2 },
44
44
  ],
45
45
  labelIds: [5],
46
46
  type: AnnotationTool.Line,
@@ -48,11 +48,11 @@ const line: ExternalAnnotation[] = [
48
48
  },
49
49
  {
50
50
  coordinates: [
51
- { x: 259.883, y: 300.424 },
52
- { x: 350, y: 331.5263919270834 },
53
- { x: 355, y: 320 },
54
- { x: 370, y: 300 },
55
- { x: 270, y: 250 },
51
+ { x: 0.26, y: 0.3 },
52
+ { x: 0.35, y: 0.33 },
53
+ { x: 0.36, y: 0.32 },
54
+ { x: 0.37, y: 0.3 },
55
+ { x: 0.27, y: 0.25 },
56
56
  ],
57
57
  labelIds: [8, 11],
58
58
  type: AnnotationTool.Line,
@@ -63,8 +63,8 @@ const line: ExternalAnnotation[] = [
63
63
  const bbox: ExternalAnnotation[] = [
64
64
  {
65
65
  coordinates: [
66
- { x: 50, y: 50 },
67
- { x: 200, y: 200 },
66
+ { x: 0.05, y: 0.05 },
67
+ { x: 0.2, y: 0.2 },
68
68
  ],
69
69
  labelIds: [5],
70
70
  type: AnnotationTool.BBox,
@@ -72,8 +72,8 @@ const bbox: ExternalAnnotation[] = [
72
72
  },
73
73
  {
74
74
  coordinates: [
75
- { x: 250, y: 100 },
76
- { x: 450, y: 150 },
75
+ { x: 0.25, y: 0.1 },
76
+ { x: 0.45, y: 0.15 },
77
77
  ],
78
78
  labelIds: [8, 11],
79
79
  type: AnnotationTool.BBox,
@@ -84,10 +84,10 @@ const bbox: ExternalAnnotation[] = [
84
84
  const polygon: ExternalAnnotation[] = [
85
85
  {
86
86
  coordinates: [
87
- { x: 50, y: 50 },
88
- { x: 200, y: 100 },
89
- { x: 250, y: 100 },
90
- { x: 250, y: 200 },
87
+ { x: 0.05, y: 0.05 },
88
+ { x: 0.2, y: 0.1 },
89
+ { x: 0.25, y: 0.1 },
90
+ { x: 0.25, y: 0.2 },
91
91
  ],
92
92
  labelIds: [5],
93
93
  status: AnnotationStatus.LOADED,
@@ -95,11 +95,11 @@ const polygon: ExternalAnnotation[] = [
95
95
  },
96
96
  {
97
97
  coordinates: [
98
- { x: 259.883, y: 300.424 },
99
- { x: 350, y: 331.5263919270834 },
100
- { x: 355, y: 320 },
101
- { x: 370, y: 300 },
102
- { x: 270, y: 250 },
98
+ { x: 0.26, y: 0.3 },
99
+ { x: 0.35, y: 0.33 },
100
+ { x: 0.36, y: 0.32 },
101
+ { x: 0.37, y: 0.3 },
102
+ { x: 0.27, y: 0.25 },
103
103
  ],
104
104
  labelIds: [8, 11],
105
105
  status: AnnotationStatus.LOADED,
package/src/types.ts CHANGED
@@ -53,6 +53,7 @@ export type SIANotification = {
53
53
  export type ToolCoordinates = {
54
54
  coordinates: Point[]
55
55
  type: AnnotationTool
56
+ labelIds?: number[]
56
57
  }
57
58
 
58
59
  export type UiConfig = {