-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmulti-class.html
More file actions
150 lines (139 loc) · 5.38 KB
/
multi-class.html
File metadata and controls
150 lines (139 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!DOCTYPE html>
<html>
<head>
<title>ULabel</title>
<!-- ULabel Library -->
<script src="/ulabel.js"></script>
<!-- JQuery Library -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<!-- ULabel Usage -->
<script>
/* global $ */
/* global ULabel */
$(window).on("load", function () {
function on_submit(annotations) {
var element = document.createElement('a');
element.setAttribute(
"href", ('data:text/plain;charset=utf-8,' +
encodeURIComponent(JSON.stringify(annotations, null, 2)))
);
element.setAttribute("download", "annotations.json");
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
let subtasks = {
"car_detection": {
"display_name": "Car Detection",
"classes": [
{
"name": "Sedan",
"color": "blue",
"id": 10,
"keybind": "1",
},
{
"name": "SUV",
"color": "green",
"id": 11,
"keybind": "2",
},
{
"name": "Truck",
"color": "orange",
"id": 12,
"keybind": "3",
},
],
"allowed_modes": ["bbox", "polygon", "contour", "polyline", "point", "tbar", "delete_polygon", "delete_bbox"],
"resume_from": null,
"task_meta": null,
"annotation_meta": null
},
"frame_review": {
"display_name": "Frame Review",
"classes": [
{
"name": "Blurry",
"color": "gray",
"id": 20
},
{
"name": "Occluded",
"color": "red",
"id": 21
}
],
"allowed_modes": ["whole-image"],
"resume_from": null,
"task_meta": null,
"annotation_meta": null
}
};
const AllowedToolboxItem = ULabel.get_allowed_toolbox_item_enum();
// Initial ULabel configuration
let ulabel = new ULabel({
"container_id": "container",
"image_data": "https://ulabel.s3.us-east-2.amazonaws.com/cs-demo-0.png",
"username": "DemoUser",
"submit_buttons": [
{
"name": "Submit",
"hook": on_submit,
"size_factor": 0.9,
"row_number": 1,
},
{
"name": "Reject",
"hook": () => { console.log("Reject"); },
"size_factor": 0.9,
"color": "red",
"row_number": 1,
},
{
"name": "Approve",
"hook": () => { console.log("Approve"); },
"size_factor": 0.9,
"color": "green",
"row_number": 1,
},
{
"name": "Skip",
"hook": () => { console.log("Skip"); },
"size_factor": 0.9,
"color": "pink",
"row_number": 0,
}
],
"subtasks": subtasks,
"initial_line_size": 2,
"toolbox_order": [
AllowedToolboxItem.SubmitButtons,
AllowedToolboxItem.ModeSelect,
AllowedToolboxItem.ZoomPan,
AllowedToolboxItem.AnnotationID,
AllowedToolboxItem.ClassCounter,
AllowedToolboxItem.AnnotationResize,
AllowedToolboxItem.KeypointSlider,
AllowedToolboxItem.FilterDistance,
AllowedToolboxItem.RecolorActive,
],
"toggle_brush_mode_keybind": "f",
"create_bbox_on_initial_crop": "|",
"click_and_drag_poly_annotations": false,
"size_mode": "zoom",
});
// Wait for ULabel instance to finish initialization
ulabel.init(function () {
// ULabel is now ready for use
console.log(ulabel);
});
});
</script>
</head>
<body>
<div id="container" style="width: 100%; height: 100vh; position: absolute; top: 0; left: 0;"></div>
</body>
</html>