samcoding5854 commited on
Commit
abd8f6e
1 Parent(s): 1a76268

Added Video code

Browse files
Pages/streamlit_img_label/frontend/.gitignore CHANGED
@@ -9,9 +9,6 @@ yarn.lock
9
  # testing
10
  /coverage
11
 
12
- # production
13
- /build
14
-
15
  # misc
16
  .DS_Store
17
  .env.local
 
9
  # testing
10
  /coverage
11
 
 
 
 
12
  # misc
13
  .DS_Store
14
  .env.local
Pages/streamlit_img_label/frontend/build/asset-manifest.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "files": {
3
+ "main.css": "./static/css/main.00623a57.chunk.css",
4
+ "main.js": "./static/js/main.25f4a86d.chunk.js",
5
+ "main.js.map": "./static/js/main.25f4a86d.chunk.js.map",
6
+ "runtime-main.js": "./static/js/runtime-main.4a6ba311.js",
7
+ "runtime-main.js.map": "./static/js/runtime-main.4a6ba311.js.map",
8
+ "static/js/2.b19543fd.chunk.js": "./static/js/2.b19543fd.chunk.js",
9
+ "static/js/2.b19543fd.chunk.js.map": "./static/js/2.b19543fd.chunk.js.map",
10
+ "index.html": "./index.html",
11
+ "precache-manifest.b5513ea1aa30f2a517dcf8a664ec6a82.js": "./precache-manifest.b5513ea1aa30f2a517dcf8a664ec6a82.js",
12
+ "service-worker.js": "./service-worker.js",
13
+ "static/css/main.00623a57.chunk.css.map": "./static/css/main.00623a57.chunk.css.map",
14
+ "static/js/2.b19543fd.chunk.js.LICENSE.txt": "./static/js/2.b19543fd.chunk.js.LICENSE.txt"
15
+ },
16
+ "entrypoints": [
17
+ "static/js/runtime-main.4a6ba311.js",
18
+ "static/js/2.b19543fd.chunk.js",
19
+ "static/css/main.00623a57.chunk.css",
20
+ "static/js/main.25f4a86d.chunk.js"
21
+ ]
22
+ }
Pages/streamlit_img_label/frontend/build/bootstrap.min.css ADDED
The diff for this file is too large to render. See raw diff
 
Pages/streamlit_img_label/frontend/build/index.html ADDED
@@ -0,0 +1 @@
 
 
1
+ <!doctype html><html lang="en"><head><title>Streamlit Component</title><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Streamlit Component"/><link rel="stylesheet" href="bootstrap.min.css"/><link href="./static/css/main.00623a57.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function t(t){for(var n,u,i=t[0],a=t[1],f=t[2],c=0,s=[];c<i.length;c++)u=i[c],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&s.push(o[u][0]),o[u]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(t);s.length;)s.shift()();return l.push.apply(l,f||[]),r()}function r(){for(var e,t=0;t<l.length;t++){for(var r=l[t],n=!0,i=1;i<r.length;i++){var a=r[i];0!==o[a]&&(n=!1)}n&&(l.splice(t--,1),e=u(u.s=r[0]))}return e}var n={},o={1:0},l=[];function u(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,u),r.l=!0,r.exports}u.m=e,u.c=n,u.d=function(e,t,r){u.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,t){if(1&t&&(e=u(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(u.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)u.d(r,n,function(t){return e[t]}.bind(null,n));return r},u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,"a",t),t},u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.p="./";var i=this.webpackJsonpstreamlit_img_label=this.webpackJsonpstreamlit_img_label||[],a=i.push.bind(i);i.push=t,i=i.slice();for(var f=0;f<i.length;f++)t(i[f]);var p=a;r()}([])</script><script src="./static/js/2.b19543fd.chunk.js"></script><script src="./static/js/main.25f4a86d.chunk.js"></script></body></html>
Pages/streamlit_img_label/frontend/build/precache-manifest.b5513ea1aa30f2a517dcf8a664ec6a82.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ self.__precacheManifest = (self.__precacheManifest || []).concat([
2
+ {
3
+ "revision": "257cc5bae7213cd44281875035cb3db9",
4
+ "url": "./index.html"
5
+ },
6
+ {
7
+ "revision": "d6ee921a8ec95850ad44",
8
+ "url": "./static/css/main.00623a57.chunk.css"
9
+ },
10
+ {
11
+ "revision": "fe0995493108e32950ed",
12
+ "url": "./static/js/2.b19543fd.chunk.js"
13
+ },
14
+ {
15
+ "revision": "192ac78a6f5ee7863138d8750af26b49",
16
+ "url": "./static/js/2.b19543fd.chunk.js.LICENSE.txt"
17
+ },
18
+ {
19
+ "revision": "d6ee921a8ec95850ad44",
20
+ "url": "./static/js/main.25f4a86d.chunk.js"
21
+ },
22
+ {
23
+ "revision": "acc1e1b1767fa196d6fe",
24
+ "url": "./static/js/runtime-main.4a6ba311.js"
25
+ }
26
+ ]);
Pages/streamlit_img_label/frontend/build/service-worker.js ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Welcome to your Workbox-powered service worker!
3
+ *
4
+ * You'll need to register this file in your web app and you should
5
+ * disable HTTP caching for this file too.
6
+ * See https://goo.gl/nhQhGp
7
+ *
8
+ * The rest of the code is auto-generated. Please don't update this file
9
+ * directly; instead, make changes to your Workbox build configuration
10
+ * and re-run your build process.
11
+ * See https://goo.gl/2aRDsh
12
+ */
13
+
14
+ importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
15
+
16
+ importScripts(
17
+ "./precache-manifest.b5513ea1aa30f2a517dcf8a664ec6a82.js"
18
+ );
19
+
20
+ self.addEventListener('message', (event) => {
21
+ if (event.data && event.data.type === 'SKIP_WAITING') {
22
+ self.skipWaiting();
23
+ }
24
+ });
25
+
26
+ workbox.core.clientsClaim();
27
+
28
+ /**
29
+ * The workboxSW.precacheAndRoute() method efficiently caches and responds to
30
+ * requests for URLs in the manifest.
31
+ * See https://goo.gl/S9QRab
32
+ */
33
+ self.__precacheManifest = [].concat(self.__precacheManifest || []);
34
+ workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
35
+
36
+ workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("./index.html"), {
37
+
38
+ blacklist: [/^\/_/,/\/[^/?]+\.[^/]+$/],
39
+ });
Pages/streamlit_img_label/frontend/build/static/css/main.00623a57.chunk.css ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .StreamlitImgLabel_dark__PyW4C{background-color:#0e1117}button{padding:.25rem .75rem;border-radius:.25rem;line-height:1.3;border:1px solid;margin-right:5px;margin-top:5px}button.StreamlitImgLabel_dark__PyW4C{color:#fff;border-color:hsla(0,0%,98%,.2)}
2
+ /*# sourceMappingURL=main.00623a57.chunk.css.map */
Pages/streamlit_img_label/frontend/build/static/css/main.00623a57.chunk.css.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["StreamlitImgLabel.module.css"],"names":[],"mappings":"AAAA,+BACI,wBACJ,CAEA,OACI,qBAAwB,CACxB,oBAAsB,CACtB,eAAgB,CAChB,gBAAiB,CACjB,gBAAiB,CACjB,cAEJ,CACA,qCACI,UAAY,CACZ,8BACJ","file":"main.00623a57.chunk.css","sourcesContent":[".dark{\n background-color:rgb(14, 17, 23);\n}\n\nbutton{\n padding: 0.25rem 0.75rem;\n border-radius: 0.25rem;\n line-height: 1.3;\n border: 1px solid;\n margin-right: 5px;\n margin-top: 5px;\n \n}\nbutton.dark{\n color: white;\n border-color: rgba(250, 250, 250, 0.2);\n}"]}
Pages/streamlit_img_label/frontend/build/static/js/2.b19543fd.chunk.js ADDED
The diff for this file is too large to render. See raw diff
 
Pages/streamlit_img_label/frontend/build/static/js/2.b19543fd.chunk.js.LICENSE.txt ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ object-assign
3
+ (c) Sindre Sorhus
4
+ @license MIT
5
+ */
6
+
7
+ /*!
8
+ * The buffer module from node.js, for the browser.
9
+ *
10
+ * @author Feross Aboukhadijeh <http://feross.org>
11
+ * @license MIT
12
+ */
13
+
14
+ /*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
15
+
16
+ /**
17
+ * @license
18
+ * Copyright 2018-2019 Streamlit Inc.
19
+ *
20
+ * Licensed under the Apache License, Version 2.0 (the "License");
21
+ * you may not use this file except in compliance with the License.
22
+ * You may obtain a copy of the License at
23
+ *
24
+ * http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software
27
+ * distributed under the License is distributed on an "AS IS" BASIS,
28
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
+ * See the License for the specific language governing permissions and
30
+ * limitations under the License.
31
+ */
32
+
33
+ /**
34
+ * @license
35
+ * Copyright 2018-2020 Streamlit Inc.
36
+ *
37
+ * Licensed under the Apache License, Version 2.0 (the "License");
38
+ * you may not use this file except in compliance with the License.
39
+ * You may obtain a copy of the License at
40
+ *
41
+ * http://www.apache.org/licenses/LICENSE-2.0
42
+ *
43
+ * Unless required by applicable law or agreed to in writing, software
44
+ * distributed under the License is distributed on an "AS IS" BASIS,
45
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46
+ * See the License for the specific language governing permissions and
47
+ * limitations under the License.
48
+ */
49
+
50
+ /** @license React v0.19.1
51
+ * scheduler.production.min.js
52
+ *
53
+ * Copyright (c) Facebook, Inc. and its affiliates.
54
+ *
55
+ * This source code is licensed under the MIT license found in the
56
+ * LICENSE file in the root directory of this source tree.
57
+ */
58
+
59
+ /** @license React v16.13.1
60
+ * react-dom.production.min.js
61
+ *
62
+ * Copyright (c) Facebook, Inc. and its affiliates.
63
+ *
64
+ * This source code is licensed under the MIT license found in the
65
+ * LICENSE file in the root directory of this source tree.
66
+ */
67
+
68
+ /** @license React v16.13.1
69
+ * react-is.production.min.js
70
+ *
71
+ * Copyright (c) Facebook, Inc. and its affiliates.
72
+ *
73
+ * This source code is licensed under the MIT license found in the
74
+ * LICENSE file in the root directory of this source tree.
75
+ */
76
+
77
+ /** @license React v16.13.1
78
+ * react.production.min.js
79
+ *
80
+ * Copyright (c) Facebook, Inc. and its affiliates.
81
+ *
82
+ * This source code is licensed under the MIT license found in the
83
+ * LICENSE file in the root directory of this source tree.
84
+ */
Pages/streamlit_img_label/frontend/build/static/js/2.b19543fd.chunk.js.map ADDED
The diff for this file is too large to render. See raw diff
 
Pages/streamlit_img_label/frontend/build/static/js/main.25f4a86d.chunk.js ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ (this.webpackJsonpstreamlit_img_label=this.webpackJsonpstreamlit_img_label||[]).push([[0],{14:function(e,t,a){e.exports=a(30)},27:function(e,t){},28:function(e,t){},29:function(e,t){},30:function(e,t,a){"use strict";a.r(t);var n=a(4),c=a.n(n),r=a(12),o=a.n(r),i=a(1),s=a(3),d=a(2),l=a(10),f=a(8),u=a(6),m=a.n(u),b=Object(l.b)((function(e){var t,a=Object(n.useState)("light"),r=Object(d.a)(a,2),o=r[0],u=r[1],b=Object(n.useState)([]),h=Object(d.a)(b,2),g=h[0],k=h[1],v=Object(n.useState)(new f.fabric.Canvas("")),j=Object(d.a)(v,2),O=j[0],w=j[1],p=e.args,E=p.canvasWidth,C=p.canvasHeight,R=p.imageData,x=Object(n.useState)(0),S=Object(d.a)(x,2),_=S[0],L=S[1],N=document.createElement("canvas"),I=N.getContext("2d");if(N.width=E,N.height=C,I){var W=I.createImageData(E,C);W.data.set(R),I.putImageData(W,0,0),t=N.toDataURL()}else t="";Object(n.useEffect)((function(){var a=e.args,n=a.rects,c=a.boxColor,r=new f.fabric.Canvas("c",{enableRetinaScaling:!1,backgroundImage:t,uniScaleTransform:!0});n.forEach((function(e){var t=e.top,a=e.left,n=e.width,o=e.height;r.add(new f.fabric.Rect({left:a,top:t,fill:"",width:n,height:o,objectCaching:!0,stroke:c,strokeWidth:1,strokeUniform:!0,hasRotatingPoint:!1}))})),k(n.map((function(e){return e.label}))),w(r),l.a.setFrameHeight()}),[C,E,t]);var y=function(){L(0),O.getObjects().forEach((function(e){return O.remove(e)})),D([])},D=function(e){k(e);var t=O.getObjects().map((function(t,a){return Object(s.a)(Object(s.a)({},t.getBoundingRect()),{},{label:e[a]})}));l.a.setComponentValue({rects:t})};Object(n.useEffect)((function(){if(O){return O.on("object:modified",(function(){O.renderAll(),D(g)})),function(){O.off("object:modified")}}}));var M=function(e){u(e),"dark"===e?document.body.classList.add("dark-mode"):document.body.classList.remove("dark-mode")};return Object(n.useEffect)((function(){return window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",(function(e){return M(e.matches?"dark":"light")})),M(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),function(){window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",(function(){}))}}),[]),c.a.createElement(c.a.Fragment,null,c.a.createElement("canvas",{id:"c",className:"dark"===o?m.a.dark:"",width:E,height:C}),c.a.createElement("div",{className:"dark"===o?m.a.dark:""},c.a.createElement("button",{className:"dark"===o?m.a.dark:"",onClick:function(){var t={left:.15*E+3*_,top:.15*C+3*_,width:.2*E,height:.2*C};L(_+1),O.add(new f.fabric.Rect(Object(s.a)(Object(s.a)({},t),{},{fill:"",objectCaching:!0,stroke:e.args.boxColor,strokeWidth:1,strokeUniform:!0,hasRotatingPoint:!1}))),D([].concat(Object(i.a)(g),[""]))}},"Add bounding box"),c.a.createElement("button",{className:"dark"===o?m.a.dark:"",onClick:function(){var e=O.getActiveObject(),t=O.getObjects().indexOf(e);O.remove(e),D(g.filter((function(e,a){return a!==t})))}},"Remove select"),c.a.createElement("button",{className:"dark"===o?m.a.dark:"",onClick:function(){y();var t=e.args,a=t.rects,n=t.boxColor;a.forEach((function(e){var t=e.top,a=e.left,c=e.width,r=e.height;O.add(new f.fabric.Rect({left:a,top:t,fill:"",width:c,height:r,objectCaching:!0,stroke:n,strokeWidth:1,strokeUniform:!0,hasRotatingPoint:!1}))})),D(g)}},"Reset"),c.a.createElement("button",{className:"dark"===o?m.a.dark:"",onClick:y},"Clear all")))}));o.a.render(c.a.createElement(c.a.StrictMode,null,c.a.createElement(b,null)),document.getElementById("root"))},6:function(e,t,a){e.exports={dark:"StreamlitImgLabel_dark__PyW4C"}}},[[14,1,2]]]);
2
+ //# sourceMappingURL=main.25f4a86d.chunk.js.map
Pages/streamlit_img_label/frontend/build/static/js/main.25f4a86d.chunk.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["StreamlitImgLabel.tsx","index.tsx","StreamlitImgLabel.module.css"],"names":["withStreamlitConnection","props","dataUri","useState","mode","setMode","labels","setLabels","fabric","Canvas","canvas","setCanvas","args","canvasWidth","canvasHeight","imageData","newBBoxIndex","setNewBBoxIndex","invisCanvas","document","createElement","ctx","getContext","width","height","idata","createImageData","data","set","putImageData","toDataURL","useEffect","rects","boxColor","canvasTmp","enableRetinaScaling","backgroundImage","uniScaleTransform","forEach","rect","top","left","add","Rect","fill","objectCaching","stroke","strokeWidth","strokeUniform","hasRotatingPoint","map","label","Streamlit","setFrameHeight","clearHandler","getObjects","remove","sendCoordinates","returnLabels","i","getBoundingRect","setComponentValue","on","renderAll","off","onSelectMode","body","classList","window","matchMedia","addEventListener","e","matches","removeEventListener","id","className","styles","dark","onClick","box","selectObject","getActiveObject","selectIndex","indexOf","filter","ReactDOM","render","StrictMode","getElementById","module","exports"],"mappings":"wTAwPeA,eA/NW,SAACC,GAA2B,IAiB9CC,EAjB6C,EACzBC,mBAAiB,SADQ,mBAC1CC,EAD0C,KACpCC,EADoC,OAErBF,mBAAmB,IAFE,mBAE1CG,EAF0C,KAElCC,EAFkC,OAGrBJ,mBAAS,IAAIK,SAAOC,OAAO,KAHN,mBAG1CC,EAH0C,KAGlCC,EAHkC,OAIYV,EAAMW,KAA3DC,EAJyC,EAIzCA,YAAaC,EAJ4B,EAI5BA,aAAcC,EAJc,EAIdA,UAJc,EAKTZ,mBAAiB,GALR,mBAK1Ca,EAL0C,KAK5BC,EAL4B,KAU7CC,EAAcC,SAASC,cAAc,UACrCC,EAAMH,EAAYI,WAAW,MAOjC,GALAJ,EAAYK,MAAQV,EACpBK,EAAYM,OAASV,EAIjBO,EAAK,CACL,IAAII,EAAQJ,EAAIK,gBAAgBb,EAAaC,GAG7CW,EAAME,KAAKC,IAAIb,GAGfM,EAAIQ,aAAaJ,EAAO,EAAG,GAC3BvB,EAAUgB,EAAYY,iBAEtB5B,EAAU,GAId6B,qBAAU,WAAO,IAAD,EAC4B9B,EAAMW,KAAtCoB,EADI,EACJA,MAAOC,EADH,EACGA,SACTC,EAAY,IAAI1B,SAAOC,OAAO,IAAK,CACrC0B,qBAAqB,EACrBC,gBAAiBlC,EACjBmC,mBAAmB,IAGvBL,EAAMM,SAAQ,SAACC,GAAU,IACbC,EAA6BD,EAA7BC,IAAKC,EAAwBF,EAAxBE,KAAMlB,EAAkBgB,EAAlBhB,MAAOC,EAAWe,EAAXf,OAC1BU,EAAUQ,IACN,IAAIlC,SAAOmC,KAAK,CACZF,OACAD,MACAI,KAAM,GACNrB,QACAC,SACAqB,eAAe,EACfC,OAAQb,EACRc,YAAa,EACbC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B,EAAqC,EAAfE,EAC3BO,MAAqB,GAAdV,EACPW,OAAuB,GAAfV,GAMRG,EAAgBD,EAAe,GAC/BN,EAAOgC,IACH,IAAIlC,SAAOmC,KAAX,2BACOoC,GADP,IAEInC,KAAM,GACNC,eAAe,EACfC,OAAQ7C,EAAMW,KAAKqB,SACnBc,YAAa,EACbC,eAAe,EACfC,kBAAkB,MAG1BQ,EAAgB,GAAD,mBAAKnD,GAAL,CAAa,QA2GpB,oBAMA,4BACIqE,UAAoB,SAATvE,EAAkBwE,IAAOC,KAAO,GAC3CC,QA/GS,WACrB,IAAME,EAAetE,EAAOuE,kBACtBC,EAAcxE,EAAO6C,aAAa4B,QAAQH,GAChDtE,EAAO8C,OAAOwB,GACdvB,EAAgBnD,EAAO8E,QAAO,SAACjC,EAAOQ,GAAR,OAAcA,IAAMuB,QAyG1C,iBAMA,4BACIP,UAAoB,SAATvE,EAAkBwE,IAAOC,KAAO,GAC3CC,QA7GK,WACjBxB,IADuB,MAEiBrD,EAAMW,KAAtCoB,EAFe,EAEfA,MAAOC,EAFQ,EAERA,SACfD,EAAMM,SAAQ,SAACC,GAAU,IACbC,EAA6BD,EAA7BC,IAAKC,EAAwBF,EAAxBE,KAAMlB,EAAkBgB,EAAlBhB,MAAOC,EAAWe,EAAXf,OAC1Bd,EAAOgC,IACH,IAAIlC,SAAOmC,KAAK,CACZF,OACAD,MACAI,KAAM,GACNrB,QACAC,SACAqB,eAAe,EACfC,OAAQb,EACRc,YAAa,EACbC,eAAe,EACfC,kBAAkB,QAI9BQ,EAAgBnD,KAuFR,SAMA,4BACIqE,UAAoB,SAATvE,EAAkBwE,IAAOC,KAAO,GAC3CC,QAASxB,GAFb,kBCzOhB+B,IAASC,OACP,kBAAC,IAAMC,WAAP,KACE,kBAAC,EAAD,OAEFpE,SAASqE,eAAe,U,kBCP1BC,EAAOC,QAAU,CAAC,KAAO,mC","file":"static/js/main.25f4a86d.chunk.js","sourcesContent":["import React, { useEffect, useState } from \"react\"\nimport {\n ComponentProps,\n Streamlit,\n withStreamlitConnection,\n} from \"streamlit-component-lib\"\nimport { fabric } from \"fabric\"\nimport styles from \"./StreamlitImgLabel.module.css\"\n\ninterface RectProps {\n top: number\n left: number\n width: number\n height: number\n label: string\n}\n\ninterface PythonArgs {\n canvasWidth: number\n canvasHeight: number\n rects: RectProps[]\n boxColor: string\n imageData: Uint8ClampedArray\n}\n\nconst StreamlitImgLabel = (props: ComponentProps) => {\n const [mode, setMode] = useState<string>(\"light\")\n const [labels, setLabels] = useState<string[]>([])\n const [canvas, setCanvas] = useState(new fabric.Canvas(\"\"))\n const { canvasWidth, canvasHeight, imageData }: PythonArgs = props.args\n const [newBBoxIndex, setNewBBoxIndex] = useState<number>(0)\n\n /*\n * Translate Python image data to a JavaScript Image\n */\n var invisCanvas = document.createElement(\"canvas\")\n var ctx = invisCanvas.getContext(\"2d\")\n\n invisCanvas.width = canvasWidth\n invisCanvas.height = canvasHeight\n\n // create imageData object\n let dataUri: any\n if (ctx) {\n var idata = ctx.createImageData(canvasWidth, canvasHeight)\n\n // set our buffer as source\n idata.data.set(imageData)\n\n // update canvas with new data\n ctx.putImageData(idata, 0, 0)\n dataUri = invisCanvas.toDataURL()\n } else {\n dataUri = \"\"\n }\n\n // Initialize canvas on mount and add a rectangle\n useEffect(() => {\n const { rects, boxColor }: PythonArgs = props.args\n const canvasTmp = new fabric.Canvas(\"c\", {\n enableRetinaScaling: false,\n backgroundImage: dataUri,\n uniScaleTransform: true,\n })\n\n rects.forEach((rect) => {\n const { top, left, width, height } = rect\n canvasTmp.add(\n new fabric.Rect({\n left,\n top,\n fill: \"\",\n width,\n height,\n objectCaching: true,\n stroke: boxColor,\n strokeWidth: 1,\n strokeUniform: true,\n hasRotatingPoint: false,\n })\n )\n })\n setLabels(rects.map((rect) => rect.label))\n\n setCanvas(canvasTmp)\n Streamlit.setFrameHeight()\n // eslint-disable-next-line\n }, [canvasHeight, canvasWidth, dataUri])\n\n // Create defualt bounding box\n const defaultBox = () => ({\n left: canvasWidth * 0.15 + newBBoxIndex * 3,\n top: canvasHeight * 0.15 + newBBoxIndex * 3,\n width: canvasWidth * 0.2,\n height: canvasHeight * 0.2,\n })\n\n // Add new bounding box to be image\n const addBoxHandler = () => {\n const box = defaultBox()\n setNewBBoxIndex(newBBoxIndex + 1)\n canvas.add(\n new fabric.Rect({\n ...box,\n fill: \"\",\n objectCaching: true,\n stroke: props.args.boxColor,\n strokeWidth: 1,\n strokeUniform: true,\n hasRotatingPoint: false,\n })\n )\n sendCoordinates([...labels, \"\"])\n }\n\n // Remove the selected bounding box\n const removeBoxHandler = () => {\n const selectObject = canvas.getActiveObject()\n const selectIndex = canvas.getObjects().indexOf(selectObject)\n canvas.remove(selectObject)\n sendCoordinates(labels.filter((label, i) => i !== selectIndex))\n }\n\n // Reset the bounding boxes\n const resetHandler = () => {\n clearHandler()\n const { rects, boxColor }: PythonArgs = props.args\n rects.forEach((rect) => {\n const { top, left, width, height } = rect\n canvas.add(\n new fabric.Rect({\n left,\n top,\n fill: \"\",\n width,\n height,\n objectCaching: true,\n stroke: boxColor,\n strokeWidth: 1,\n strokeUniform: true,\n hasRotatingPoint: false,\n })\n )\n })\n sendCoordinates(labels)\n }\n\n // Remove all the bounding boxes\n const clearHandler = () => {\n setNewBBoxIndex(0)\n canvas.getObjects().forEach((rect) => canvas.remove(rect))\n sendCoordinates([])\n }\n\n // Send the coordinates of the rectangle back to streamlit.\n const sendCoordinates = (returnLabels: string[]) => {\n setLabels(returnLabels)\n const rects = canvas.getObjects().map((rect, i) => ({\n ...rect.getBoundingRect(),\n label: returnLabels[i],\n }))\n Streamlit.setComponentValue({ rects })\n }\n\n // Update the bounding boxes when modified\n useEffect(() => {\n if (!canvas) {\n return\n }\n const handleEvent = () => {\n canvas.renderAll()\n sendCoordinates(labels)\n }\n\n canvas.on(\"object:modified\", handleEvent)\n return () => {\n canvas.off(\"object:modified\")\n }\n })\n\n // Adjust the theme according to the system\n const onSelectMode = (mode: string) => {\n setMode(mode)\n if (mode === \"dark\") document.body.classList.add(\"dark-mode\")\n else document.body.classList.remove(\"dark-mode\")\n }\n\n useEffect(() => {\n // Add listener to update styles\n window\n .matchMedia(\"(prefers-color-scheme: dark)\")\n .addEventListener(\"change\", (e) =>\n onSelectMode(e.matches ? \"dark\" : \"light\")\n )\n\n // Setup dark/light mode for the first time\n onSelectMode(\n window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n ? \"dark\"\n : \"light\"\n )\n\n // Remove listener\n return () => {\n window\n .matchMedia(\"(prefers-color-scheme: dark)\")\n .removeEventListener(\"change\", () => {})\n }\n }, [])\n\n return (\n <>\n <canvas\n id=\"c\"\n className={mode === \"dark\" ? styles.dark : \"\"}\n width={canvasWidth}\n height={canvasHeight}\n />\n <div className={mode === \"dark\" ? styles.dark : \"\"}>\n <button\n className={mode === \"dark\" ? styles.dark : \"\"}\n onClick={addBoxHandler}\n >\n Add bounding box\n </button>\n <button\n className={mode === \"dark\" ? styles.dark : \"\"}\n onClick={removeBoxHandler}\n >\n Remove select\n </button>\n <button\n className={mode === \"dark\" ? styles.dark : \"\"}\n onClick={resetHandler}\n >\n Reset\n </button>\n <button\n className={mode === \"dark\" ? styles.dark : \"\"}\n onClick={clearHandler}\n >\n Clear all\n </button>\n </div>\n </>\n )\n}\n\nexport default withStreamlitConnection(StreamlitImgLabel)\n","import React from \"react\"\nimport ReactDOM from \"react-dom\"\nimport StreamlitImgLabel from \"./StreamlitImgLabel\"\n\nReactDOM.render(\n <React.StrictMode>\n <StreamlitImgLabel />\n </React.StrictMode>,\n document.getElementById(\"root\")\n)\n","// extracted by mini-css-extract-plugin\nmodule.exports = {\"dark\":\"StreamlitImgLabel_dark__PyW4C\"};"],"sourceRoot":""}
Pages/streamlit_img_label/frontend/build/static/js/runtime-main.4a6ba311.js ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ !function(e){function t(t){for(var n,u,i=t[0],a=t[1],f=t[2],c=0,s=[];c<i.length;c++)u=i[c],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&s.push(o[u][0]),o[u]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(t);s.length;)s.shift()();return l.push.apply(l,f||[]),r()}function r(){for(var e,t=0;t<l.length;t++){for(var r=l[t],n=!0,i=1;i<r.length;i++){var a=r[i];0!==o[a]&&(n=!1)}n&&(l.splice(t--,1),e=u(u.s=r[0]))}return e}var n={},o={1:0},l=[];function u(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,u),r.l=!0,r.exports}u.m=e,u.c=n,u.d=function(e,t,r){u.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},u.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,t){if(1&t&&(e=u(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(u.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)u.d(r,n,function(t){return e[t]}.bind(null,n));return r},u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,"a",t),t},u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.p="./";var i=this.webpackJsonpstreamlit_img_label=this.webpackJsonpstreamlit_img_label||[],a=i.push.bind(i);i.push=t,i=i.slice();for(var f=0;f<i.length;f++)t(i[f]);var p=a;r()}([]);
2
+ //# sourceMappingURL=runtime-main.4a6ba311.js.map
Pages/streamlit_img_label/frontend/build/static/js/runtime-main.4a6ba311.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["../webpack/bootstrap"],"names":["webpackJsonpCallback","data","moduleId","chunkId","chunkIds","moreModules","executeModules","i","resolves","length","Object","prototype","hasOwnProperty","call","installedChunks","push","modules","parentJsonpFunction","shift","deferredModules","apply","checkDeferredModules","result","deferredModule","fulfilled","j","depId","splice","__webpack_require__","s","installedModules","1","exports","module","l","m","c","d","name","getter","o","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","p","jsonpArray","this","oldJsonpFunction","slice"],"mappings":"aACE,SAASA,EAAqBC,GAQ7B,IAPA,IAMIC,EAAUC,EANVC,EAAWH,EAAK,GAChBI,EAAcJ,EAAK,GACnBK,EAAiBL,EAAK,GAIHM,EAAI,EAAGC,EAAW,GACpCD,EAAIH,EAASK,OAAQF,IACzBJ,EAAUC,EAASG,GAChBG,OAAOC,UAAUC,eAAeC,KAAKC,EAAiBX,IAAYW,EAAgBX,IACpFK,EAASO,KAAKD,EAAgBX,GAAS,IAExCW,EAAgBX,GAAW,EAE5B,IAAID,KAAYG,EACZK,OAAOC,UAAUC,eAAeC,KAAKR,EAAaH,KACpDc,EAAQd,GAAYG,EAAYH,IAKlC,IAFGe,GAAqBA,EAAoBhB,GAEtCO,EAASC,QACdD,EAASU,OAATV,GAOD,OAHAW,EAAgBJ,KAAKK,MAAMD,EAAiBb,GAAkB,IAGvDe,IAER,SAASA,IAER,IADA,IAAIC,EACIf,EAAI,EAAGA,EAAIY,EAAgBV,OAAQF,IAAK,CAG/C,IAFA,IAAIgB,EAAiBJ,EAAgBZ,GACjCiB,GAAY,EACRC,EAAI,EAAGA,EAAIF,EAAed,OAAQgB,IAAK,CAC9C,IAAIC,EAAQH,EAAeE,GACG,IAA3BX,EAAgBY,KAAcF,GAAY,GAE3CA,IACFL,EAAgBQ,OAAOpB,IAAK,GAC5Be,EAASM,EAAoBA,EAAoBC,EAAIN,EAAe,KAItE,OAAOD,EAIR,IAAIQ,EAAmB,GAKnBhB,EAAkB,CACrBiB,EAAG,GAGAZ,EAAkB,GAGtB,SAASS,EAAoB1B,GAG5B,GAAG4B,EAAiB5B,GACnB,OAAO4B,EAAiB5B,GAAU8B,QAGnC,IAAIC,EAASH,EAAi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AGzG7B,EAAoB8B,EAAI,KAExB,IAAIC,EAAaC,KAAsC,gCAAIA,KAAsC,iCAAK,GAClGC,EAAmBF,EAAW5C,KAAKuC,KAAKK,GAC5CA,EAAW5C,KAAOf,EAClB2D,EAAaA,EAAWG,QACxB,IAAI,IAAIvD,EAAI,EAAGA,EAAIoD,EAAWlD,OAAQF,IAAKP,EAAqB2D,EAAWpD,IAC3E,IAAIU,EAAsB4C,EAI1BxC,I","file":"static/js/runtime-main.4a6ba311.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n \t\tvar executeModules = data[2];\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t\t// add entry modules from loaded chunk to deferred list\n \t\tdeferredModules.push.apply(deferredModules, executeModules || []);\n\n \t\t// run deferred modules when all chunks ready\n \t\treturn checkDeferredModules();\n \t};\n \tfunction checkDeferredModules() {\n \t\tvar result;\n \t\tfor(var i = 0; i < deferredModules.length; i++) {\n \t\t\tvar deferredModule = deferredModules[i];\n \t\t\tvar fulfilled = true;\n \t\t\tfor(var j = 1; j < deferredModule.length; j++) {\n \t\t\t\tvar depId = deferredModule[j];\n \t\t\t\tif(installedChunks[depId] !== 0) fulfilled = false;\n \t\t\t}\n \t\t\tif(fulfilled) {\n \t\t\t\tdeferredModules.splice(i--, 1);\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = deferredModule[0]);\n \t\t\t}\n \t\t}\n\n \t\treturn result;\n \t}\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t1: 0\n \t};\n\n \tvar deferredModules = [];\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"./\";\n\n \tvar jsonpArray = this[\"webpackJsonpstreamlit_img_label\"] = this[\"webpackJsonpstreamlit_img_label\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// run deferred modules from other chunks\n \tcheckDeferredModules();\n"],"sourceRoot":""}