|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <title>ULabel Interactive Demo</title> |
| 5 | + |
| 6 | + <!-- ULabel Library (minified build, served alongside this page) --> |
| 7 | + <script src="./ulabel.min.js"></script> |
| 8 | + |
| 9 | + <!-- JQuery Library --> |
| 10 | + <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> |
| 11 | + |
| 12 | + <!-- ULabel Usage --> |
| 13 | + <script> |
| 14 | + /* global $ */ |
| 15 | + /* global ULabel */ |
| 16 | + |
| 17 | + $(window).on("load", function() { |
| 18 | + |
| 19 | + let resume_from = [ |
| 20 | + { |
| 21 | + "id": "a1035bf8-324d-44c9-9119-7c0c1888d3ba", |
| 22 | + "spatial_type": "bbox", |
| 23 | + "spatial_payload": [[871.84, 480.78], [833.71, 396.29]], |
| 24 | + "classification_payloads": [ |
| 25 | + {"class_id": 11, "confidence": 1.0}, |
| 26 | + ], |
| 27 | + }, |
| 28 | + { |
| 29 | + "id": "dec78d65-9cb4-43ec-8c5a-dcbbae7a3d74", |
| 30 | + "spatial_type": "bbox", |
| 31 | + "spatial_payload": [[1257.66, 541.35], [1079.71, 411.99]], |
| 32 | + "classification_payloads": [ |
| 33 | + {"class_id": 10, "confidence": 1.0}, |
| 34 | + ], |
| 35 | + }, |
| 36 | + ]; |
| 37 | + |
| 38 | + function on_submit(annotations) { |
| 39 | + var element = document.createElement('a'); |
| 40 | + element.setAttribute( |
| 41 | + "href", ('data:text/plain;charset=utf-8,' + |
| 42 | + encodeURIComponent(JSON.stringify(annotations, null, 2))) |
| 43 | + ); |
| 44 | + element.setAttribute("download", "annotations.json"); |
| 45 | + element.style.display = 'none'; |
| 46 | + document.body.appendChild(element); |
| 47 | + element.click(); |
| 48 | + document.body.removeChild(element); |
| 49 | + } |
| 50 | + |
| 51 | + let subtasks = { |
| 52 | + "car_detection": { |
| 53 | + "display_name": "Object Detection", |
| 54 | + "classes": [ |
| 55 | + { |
| 56 | + "name": "Car", |
| 57 | + "color": "orange", |
| 58 | + "id": 10 |
| 59 | + }, |
| 60 | + { |
| 61 | + "name": "Pedestrian", |
| 62 | + "color": "cyan", |
| 63 | + "id": 11 |
| 64 | + } |
| 65 | + ], |
| 66 | + "allowed_modes": ["point", "bbox", "polygon", "contour", "polyline", "tbar", "delete_bbox", "delete_polygon"], |
| 67 | + "resume_from": resume_from, |
| 68 | + "task_meta": null, |
| 69 | + "annotation_meta": null |
| 70 | + } |
| 71 | + }; |
| 72 | + |
| 73 | + // Initial ULabel configuration |
| 74 | + let ulabel = new ULabel({ |
| 75 | + "container_id": "container", |
| 76 | + "image_data": "https://ulabel.s3.us-east-2.amazonaws.com/cs-demo-0.png", |
| 77 | + "username": "DemoUser", |
| 78 | + "submit_buttons": on_submit, |
| 79 | + "subtasks": subtasks |
| 80 | + }); |
| 81 | + // Wait for ULabel instance to finish initialization |
| 82 | + ulabel.init(function() { |
| 83 | + // ULabel is now ready for use |
| 84 | + }); |
| 85 | + |
| 86 | + }); |
| 87 | + </script> |
| 88 | + </head> |
| 89 | + <body> |
| 90 | + <div id="container" style="width: 100%; height: 100vh; position: absolute; top: 0; left: 0;"></div> |
| 91 | + </body> |
| 92 | +</html> |
0 commit comments