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
@@ -1,69 +0,0 @@
1
- import Prompt from './Prompt'
2
- import React from 'react'
3
- import { Card, Image } from 'semantic-ui-react'
4
-
5
- const LabelExampleViewer = (props) => {
6
- const requestExample = (e) => {
7
- e.stopPropagation()
8
- if (props.onRequestExample) {
9
- props.onRequestExample()
10
- }
11
- }
12
- const renderContent = () => {
13
- if (!props.lbl) return null
14
- if (!props.exampleImg) return null
15
- const description = (
16
- <div>
17
- {props.lbl.description}
18
- <h4>Comment:</h4>
19
- {props.exampleImg.anno ? props.exampleImg.anno.comment : 'no comment'}
20
- </div>
21
- )
22
- return (
23
- <div>
24
- <Card
25
-
26
- // image={props.exampleImg.img}
27
- // description={props.lbl.description}
28
- // header={props.lbl.label}
29
- // // description={props.exampleImg.anno.comment}
30
- // extra={props.exampleImg.anno.comment}
31
- >
32
- <Image
33
- onClick={(e) => requestExample(e)}
34
- src={props.exampleImg.img}
35
- wrapped
36
- ui={false}
37
- />
38
- <Card.Content>
39
- <Card.Header>{props.lbl.label}</Card.Header>
40
- {/* <Card.Description>{props.lbl.description}</Card.Description> */}
41
- <Card.Description>{description}</Card.Description>
42
- {/* <Card.Description>{props.exampleImg.anno.comment}</Card.Description> */}
43
- </Card.Content>
44
- </Card>
45
- {/* <Header inverted>{props.lbl.label}</Header>
46
- {props.lbl.description}
47
- <Image src={props.exampleImg.img} centered size='medium'></Image> */}
48
- </div>
49
- )
50
- }
51
-
52
- const handlePromptClick = () => {
53
- if (props.onClose) {
54
- props.onClose()
55
- }
56
- }
57
-
58
- return (
59
- <Prompt
60
- onClick={() => {
61
- handlePromptClick()
62
- }}
63
- active={props.active}
64
- content={renderContent()}
65
- />
66
- )
67
- }
68
-
69
- export default LabelExampleViewer
@@ -1,165 +0,0 @@
1
- import React, { useState, useEffect, useRef } from 'react'
2
- import { List, TextArea, Form, Label, Icon } from 'semantic-ui-react'
3
- import InfoBox from './InfoBox'
4
- import PopUp from '../SiaPopup'
5
-
6
- const AnnoDetails = (props) => {
7
- const [comment, setComment] = useState('')
8
- const [example, setExample] = useState(false)
9
- const [showSaveBtn, setShowSaveBtn] = useState(false)
10
- const tARef = useRef()
11
- useEffect(() => {
12
- if (props.anno) {
13
- if (props.anno.comment) {
14
- setComment(props.anno.comment)
15
- } else {
16
- setComment('')
17
- }
18
- }
19
- }, [props.anno])
20
-
21
- useEffect(() => {
22
- if (tARef.current) {
23
- tARef.current.focus()
24
- }
25
- }, [props.commentInputTrigger])
26
-
27
- const onDismiss = () => {
28
- if (props.onDismiss) {
29
- props.onDismiss()
30
- }
31
- }
32
-
33
- const onCommentUpdate = () => {
34
- if (props.onCommentUpdate) {
35
- props.onCommentUpdate(comment)
36
- }
37
- setShowSaveBtn(false)
38
- }
39
-
40
- const onMarkExampleClick = () => {
41
- // setExample(!example)
42
- if (props.onMarkExample) {
43
- props.onMarkExample(props.anno)
44
- }
45
- }
46
-
47
- const renderSaveBtn = () => {
48
- if (showSaveBtn) {
49
- return <Label as="a" corner="right" icon="save" color="red"></Label>
50
- }
51
- }
52
-
53
- const renderComment = () => {
54
- return (
55
- <div>
56
- <Form onClick={() => {}}>
57
- {renderSaveBtn()}
58
- <TextArea
59
- placeholder="Write a comment"
60
- ref={tARef}
61
- value={comment}
62
- rows={2}
63
- onBlur={() => onCommentUpdate()}
64
- onFocus={() => setShowSaveBtn(true)}
65
- onChange={(e) => setComment(e.target.value)}
66
- ></TextArea>
67
- </Form>
68
- </div>
69
- )
70
- }
71
- const renderLabels = () => {
72
- if (props.anno) {
73
- const selectedLabelIds = props.anno.labelIds
74
- if (!selectedLabelIds) return 'No Label'
75
-
76
- let lbls = ''
77
- props.anno.labelIds.forEach((lbl, idx) => {
78
- const labelObject = props.possibleLabels.find((el) => {
79
- return el.id === lbl
80
- })
81
- if (idx > 0) lbls += ', '
82
- lbls += labelObject.label
83
- })
84
- if (!lbls) return 'No Label'
85
- return lbls
86
- } else {
87
- return 'No Label'
88
- }
89
- }
90
-
91
- const renderExampleMark = () => {
92
- if (!props.allowedToMarkExample) return null
93
- let color = 'grey'
94
- let iconName = 'bookmark outline'
95
- if (props.anno) {
96
- if (props.anno.isExample) {
97
- color = 'yellow'
98
- iconName = 'bookmark'
99
- }
100
- }
101
- const mark = (
102
- <Label
103
- as="a"
104
- color={color}
105
- style={{ opacity: 0.8 }}
106
- size="medium"
107
- corner="left"
108
- onClick={() => {
109
- onMarkExampleClick()
110
- }}
111
- >
112
- <Icon name={iconName} />
113
- </Label>
114
- )
115
- return (
116
- <PopUp
117
- content="Mark this annotation as example for other annotators"
118
- trigger={mark}
119
- />
120
- )
121
- }
122
-
123
- const renderDescription = () => {
124
- if (props.anno) {
125
- return (
126
- <div>
127
- {renderExampleMark()}
128
- {/* <Header>
129
- Labels
130
- </Header>
131
- <div>
132
- {renderLabels()}
133
- </div> */}
134
- <List>
135
- <List.Item icon="at" content={props.anno.id} />
136
- <List.Item icon="tag" content={renderLabels()} />
137
- <List.Item
138
- icon="time"
139
- content={`${props.anno.annoTime.toLocaleString('us', {
140
- minimumFractionDigits: 2,
141
- maximumFractionDigits: 2,
142
- })} seconds`}
143
- />
144
- {/* <List.Item icon='time' content={props.anno.annoTime} /> */}
145
- </List>
146
- {renderComment()}
147
- </div>
148
- )
149
- } else {
150
- return 'No annotation selected!'
151
- }
152
- }
153
-
154
- return (
155
- <InfoBox
156
- header={'Annotation Details'}
157
- content={renderDescription()}
158
- visible={props.visible}
159
- defaultPos={props.defaultPos}
160
- onDismiss={(e) => onDismiss()}
161
- />
162
- )
163
- }
164
-
165
- export default AnnoDetails
@@ -1,106 +0,0 @@
1
- import React, { useState, useEffect } from 'react'
2
- import { List, Label } from 'semantic-ui-react'
3
- import InfoBox from './InfoBox'
4
- import * as colorlut from '../utils/color'
5
- // import actions from '../../../../actions'
6
- // import * as transform from '../utils/transform'
7
- // const { siaShowImgBar } = actions
8
-
9
- const AnnoStats = (props) => {
10
- const [hideList, setHideList] = useState([])
11
-
12
- useEffect(() => {
13
- setHideList([])
14
- }, [props.imgLoadCount])
15
-
16
- const onDismiss = () => {
17
- if (props.onDismiss) {
18
- props.onDismiss()
19
- }
20
- }
21
-
22
- const onLblClick = (lbl) => {
23
- let hideLbl = false
24
- if (hideList.includes(lbl.id)) {
25
- setHideList(hideList.filter((e) => e !== lbl.id))
26
- hideLbl = false
27
- } else {
28
- // hideList.push(lbl.id)
29
- setHideList([...hideList, lbl.id])
30
- hideLbl = true
31
- }
32
- if (props.onHideLbl) {
33
- props.onHideLbl(lbl, hideLbl)
34
- }
35
- }
36
-
37
- const renderRow = (s) => {
38
- const opacity = hideList.includes(s.id) ? 0.5 : 1.0
39
- return (
40
- <List.Item key={s.id}>
41
- <List.Content>
42
- <Label
43
- as="a"
44
- tag
45
- style={{ background: s.color, opacity: opacity }}
46
- onClick={() => onLblClick(s)}
47
- >
48
- {s.label}
49
- <Label.Detail>{s.amount}</Label.Detail>
50
- </Label>
51
- </List.Content>
52
- </List.Item>
53
- )
54
- }
55
-
56
- const renderRows = () => {
57
- let stats = {}
58
- props.annos.forEach((a) => {
59
- // // console.log('render rows', a)
60
- if (a.status !== 'deleted') {
61
- a.labelIds.forEach((lblId) => {
62
- if (lblId in stats) {
63
- stats[lblId] += 1
64
- } else {
65
- stats[lblId] = 1
66
- }
67
- })
68
- if (a.labelIds.length === 0) {
69
- if ((-1) in stats) {
70
- stats[-1] += 1
71
- } else {
72
- stats[-1] = 1
73
- }
74
- }
75
- }
76
- })
77
- const res = Object.entries(stats).map(([key, value]) => {
78
- let lbl = props.possibleLabels.find((e) => {
79
- return e.id === parseInt(key)
80
- })
81
- if (!lbl) {
82
- lbl = { id: -1, label: 'No Label', color: colorlut.getDefaultColor() }
83
- }
84
-
85
- lbl.amount = value
86
- // return renderRow({class:idToLbl[key], amount:value, color:idToColor[key]})
87
- return renderRow(lbl)
88
- })
89
- return res
90
- }
91
- const renderDescription = () => {
92
- return <List>{renderRows()}</List>
93
- }
94
-
95
- return (
96
- <InfoBox
97
- header={'Annotations per Label'}
98
- content={renderDescription()}
99
- visible={props.visible}
100
- defaultPos={props.defaultPos}
101
- onDismiss={(e) => onDismiss()}
102
- />
103
- )
104
- }
105
-
106
- export default AnnoStats
@@ -1,76 +0,0 @@
1
- import React, { Component } from 'react'
2
- import { Header, Message } from 'semantic-ui-react'
3
- import Draggable from 'react-draggable'
4
-
5
- class InfoBox extends Component {
6
- constructor(props) {
7
- super(props)
8
- this.state = {
9
- style: {
10
- position: 'fixed',
11
- top: 200,
12
- left: 200,
13
- width: 250,
14
- },
15
- }
16
- }
17
-
18
- componentDidMount() {
19
- this.updateStyle()
20
- }
21
-
22
- componentDidUpdate(prevProps) {
23
- if (this.props.defaultPos !== prevProps.defaultPos) {
24
- this.updateStyle()
25
- }
26
- }
27
-
28
- handleOnStop(e) {
29
- if (this.props.onStop) {
30
- this.props.onStop(e)
31
- }
32
- }
33
-
34
- updateStyle() {
35
- this.setState({
36
- style: { ...this.state.style, ...this.props.defaultPos },
37
- })
38
- }
39
-
40
- onDismiss(e) {
41
- if (this.props.onDismiss) {
42
- this.props.onDismiss(e)
43
- }
44
- }
45
-
46
- render() {
47
- if (!this.props.visible) return null
48
- return (
49
- <Draggable handle=".handle" onStop={(e) => this.handleOnStop(e)}>
50
- <div style={this.state.style}>
51
- <Message
52
- style={{ opacity: 0.98 }}
53
- onDismiss={(e) => {
54
- this.onDismiss(e)
55
- }}
56
- size="small"
57
- >
58
- <Header
59
- textAlign="center"
60
- as="h5"
61
- className="handle"
62
- style={{ cursor: 'grab' }}
63
- >
64
- {this.props.header}
65
- </Header>
66
- {/* <Message.Header textAlign='center' className="handle" style={{cursor: 'grab'}}>{this.props.header}</Message.Header> */}
67
- <hr />
68
- <Message.Content>{this.props.content}</Message.Content>
69
- </Message>
70
- </div>
71
- </Draggable>
72
- )
73
- }
74
- }
75
-
76
- export default InfoBox
@@ -1,152 +0,0 @@
1
- import { Component } from 'react'
2
- import AnnoDetails from './AnnoDetails'
3
- import AnnoStats from './AnnoStats'
4
- import LabelInfo from './LabelInfo'
5
-
6
- class InfoBoxes extends Component {
7
- constructor(props) {
8
- super(props)
9
- this.state = {
10
- position: {
11
- top: 0,
12
- left: 0,
13
- },
14
- }
15
- }
16
-
17
- componentDidMount() {
18
- this.updateLayout()
19
- }
20
-
21
- componentDidUpdate(prevProps) {
22
- if (this.props.layoutUpdate !== prevProps.layoutUpdate) {
23
- this.updateLayout()
24
- }
25
- if (this.props.commentInputTrigger !== prevProps.commentInputTrigger) {
26
- if (!this.props.uiConfig.annoDetails.visible) {
27
- this.showAnnoDetails(true)
28
- }
29
- }
30
- }
31
-
32
- updateLayout() {
33
- if (this.props.container.current) {
34
- const container = this.props.container.current.getBoundingClientRect()
35
- this.setState({
36
- position: {
37
- ...this.state.position,
38
- left: container.right - 250,
39
- top: container.top,
40
- },
41
- })
42
- }
43
- }
44
-
45
- showAnnoDetails(show = true) {
46
- this.props.onUiConfigUpdate({
47
- ...this.props.uiConfig,
48
- annoDetails: {
49
- ...this.props.uiConfig.annoDetails,
50
- visible: show,
51
- },
52
- })
53
- }
54
-
55
- onDismiss(type) {
56
- if (this.props.onUiConfigUpdate) {
57
- switch (type) {
58
- case 'AnnoDetails':
59
- this.showAnnoDetails(false)
60
- break
61
- case 'LabelInfo':
62
- this.props.onUiConfigUpdate({
63
- ...this.props.uiConfig,
64
- labelInfo: {
65
- ...this.props.uiConfig.labelInfo,
66
- visible: false,
67
- },
68
- })
69
- break
70
- case 'AnnoStats':
71
- this.props.onUiConfigUpdate({
72
- ...this.props.uiConfig,
73
- annoStats: {
74
- ...this.props.uiConfig.annoStats,
75
- visible: false,
76
- },
77
- })
78
- break
79
- default:
80
- break
81
- }
82
- }
83
- }
84
-
85
- onCommentUpdate(comment) {
86
- if (this.props.onCommentUpdate) {
87
- this.props.onCommentUpdate(comment)
88
- }
89
- }
90
-
91
- onMarkExample(anno) {
92
- if (this.props.onMarkExample) {
93
- this.props.onMarkExample(anno)
94
- }
95
- }
96
-
97
- onHideLbl(lbl, hide) {
98
- if (this.props.onHideLbl) {
99
- this.props.onHideLbl(lbl, hide)
100
- }
101
- }
102
-
103
- render() {
104
- if (!this.props.annos) return null
105
- // if (!this.props.selectedAnno) return null
106
- return (
107
- <div>
108
- <LabelInfo
109
- selectedAnno={this.props.selectedAnno}
110
- possibleLabels={this.props.possibleLabels}
111
- defaultPos={this.state.position}
112
- onDismiss={() => this.onDismiss('LabelInfo')}
113
- visible={this.props.uiConfig.labelInfo.visible}
114
- onGetAnnoExample={(exampleArgs) =>
115
- this.props.onGetAnnoExample ? this.props.onGetAnnoExample(exampleArgs) : {}
116
- }
117
- exampleImg={this.props.exampleImg}
118
- />
119
- <AnnoDetails
120
- anno={this.props.selectedAnno}
121
- possibleLabels={this.props.possibleLabels}
122
- defaultPos={{
123
- left: this.state.position.left - 300,
124
- top: this.state.position.top,
125
- }}
126
- onDismiss={() => this.onDismiss('AnnoDetails')}
127
- onCommentUpdate={(comment) => this.onCommentUpdate(comment)}
128
- onMarkExample={(anno) => this.onMarkExample(anno)}
129
- allowedToMarkExample={this.props.allowedToMarkExample}
130
- commentInputTrigger={this.props.commentInputTrigger}
131
- visible={this.props.uiConfig.annoDetails.visible}
132
- />
133
- <AnnoStats
134
- selectedAnno={this.props.selectedAnno}
135
- annos={this.props.annos}
136
- possibleLabels={this.props.possibleLabels}
137
- defaultPos={{
138
- left: this.state.position.left,
139
- top: this.state.position.top + 400,
140
- }}
141
- // defaultPos={this.state.position}
142
- onDismiss={() => this.onDismiss('AnnoStats')}
143
- onHideLbl={(lbl, hide) => this.onHideLbl(lbl, hide)}
144
- visible={this.props.uiConfig.annoStats.visible}
145
- imgLoadCount={this.props.imgLoadCount}
146
- />
147
- </div>
148
- )
149
- }
150
- }
151
-
152
- export default InfoBoxes
@@ -1,107 +0,0 @@
1
- import React, { useEffect, useState } from 'react'
2
- import InfoBox from './InfoBox'
3
- import SiaPopup from '../SiaPopup'
4
- import AnnoExampleViewer from '../AnnoExampleViewer'
5
- const LabelInfo = (props) => {
6
- const [showExampleViewer, setShowExampleViewer] = useState(false)
7
- const [myLbl, setMyLbl] = useState(undefined)
8
- // const { data: exampleImg, mutate: getAnnoExample } = exampleApi.useGetAnnoExampleImg({})
9
- useEffect(() => {
10
- if (props.selectedAnno) {
11
- const selectedLabelIds = props.selectedAnno.labelIds
12
- if (selectedLabelIds) {
13
- const lbl = props.possibleLabels.find((e) => {
14
- return selectedLabelIds[0] === e.id
15
- })
16
- if (lbl) {
17
- if (lbl !== myLbl) {
18
- setMyLbl(lbl)
19
- if (props.visible)
20
- // getAnnoExample({llId:lbl.id, type:'annoBased', drawAnno: true, addContext:0.05})
21
- requestImg(lbl, props.selectedAnno)
22
- }
23
- }
24
- }
25
- }
26
- }, [props.selectedAnno])
27
- const onDismiss = () => {
28
- if (props.onDismiss) {
29
- props.onDismiss()
30
- }
31
- }
32
-
33
- const requestImg = (lbl, anno) => {
34
- if (props.onGetAnnoExample) {
35
- props.onGetAnnoExample({ lbl: lbl, anno: anno })
36
- }
37
- }
38
-
39
- const handleImgClick = () => {
40
- // setShowExampleViewer(true)
41
- // requestImg(myLbl, props.selectedAnno)
42
-
43
- setShowExampleViewer(true)
44
- // getAnnoExample({llId:myLbl.id, type:'annoBased', drawAnno: true, addContext:0.05})
45
- }
46
-
47
- const renderExampleImg = () => {
48
- if (!props.exampleImg) return null
49
- return (
50
- <div>
51
- <h4 onClick={() => handleImgClick()}>Example:</h4>
52
- <SiaPopup
53
- trigger={
54
- <img
55
- src={props.exampleImg.img}
56
- onClick={() => handleImgClick()}
57
- style={{ borderRadius: 25, width: '100%' }}
58
- />
59
- }
60
- content={'Click on image to view more examples'}
61
- />
62
- </div>
63
- )
64
- }
65
-
66
- const renderDescription = () => {
67
- // if (props.selectedAnno){
68
- // if (myLbl){
69
- // const selectedLabelIds = props.selectedAnno.labelIds
70
- // if (!selectedLabelIds) return 'No Label'
71
- // const lbl = props.possibleLabels.find( e => {
72
- // return selectedLabelIds[0] === e.id
73
- // })
74
- if (!myLbl) return 'No Label'
75
- return (
76
- <div>
77
- <h4>{myLbl.label}</h4>
78
- <div dangerouslySetInnerHTML={{ __html: myLbl.description }} />
79
- {renderExampleImg()}
80
- <AnnoExampleViewer
81
- onRequestExample={() => requestImg(myLbl, props.selectedAnno)}
82
- onClose={() => {
83
- setShowExampleViewer(false)
84
- }}
85
- active={showExampleViewer}
86
- lbl={myLbl}
87
- exampleImg={props.exampleImg}
88
- />
89
- </div>
90
- )
91
- // } else {
92
- // return 'No Label'
93
- // }
94
- }
95
-
96
- return (
97
- <InfoBox
98
- header="Label Info"
99
- content={renderDescription()}
100
- visible={props.visible}
101
- defaultPos={props.defaultPos}
102
- onDismiss={() => onDismiss()}
103
- />
104
- )
105
- }
106
-
107
- export default LabelInfo