lightly-studio 0.3.3__py3-none-any.whl → 0.3.4__py3-none-any.whl

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.

Potentially problematic release.


This version of lightly-studio might be problematic. Click here for more details.

Files changed (122) hide show
  1. lightly_studio/api/app.py +2 -0
  2. lightly_studio/api/routes/api/caption.py +30 -0
  3. lightly_studio/api/routes/api/embeddings2d.py +36 -4
  4. lightly_studio/api/routes/api/metadata.py +57 -1
  5. lightly_studio/core/add_samples.py +138 -0
  6. lightly_studio/core/dataset.py +143 -16
  7. lightly_studio/dataset/loader.py +2 -8
  8. lightly_studio/db_manager.py +10 -4
  9. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/0.B3oFNb6O.css +1 -0
  10. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/2.CkOblLn7.css +1 -0
  11. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/Samples.CIbricz7.css +1 -0
  12. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/_layout.7Ma7YdVg.css +1 -0
  13. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/{useFeatureFlags.CV-KWLNP.css → _layout.CefECEWA.css} +1 -1
  14. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/transform.2jKMtOWG.css +1 -0
  15. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/-DXuGN29.js +1 -0
  16. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{Cs1XmhiF.js → B7302SU7.js} +1 -1
  17. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/BeWf8-vJ.js +1 -0
  18. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Bqz7dyEC.js +1 -0
  19. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/C1FmrZbK.js +1 -0
  20. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{BdfTHw61.js → CSCQddQS.js} +1 -1
  21. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CZGpyrcA.js +1 -0
  22. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CfQ4mGwl.js +1 -0
  23. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CiaNZCBa.js +1 -0
  24. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Cqo0Vpvt.js +417 -0
  25. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Cy4fgWTG.js +1 -0
  26. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/D5w4xp5l.js +1 -0
  27. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DD63uD-T.js +1 -0
  28. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DQ8aZ1o-.js +3 -0
  29. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{keKYsoph.js → DSxvnAMh.js} +1 -1
  30. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/D_JuJOO3.js +20 -0
  31. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/D_ynJAfY.js +2 -0
  32. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Dafy4oEQ.js +1 -0
  33. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{BfHVnyNT.js → Dj4O-5se.js} +1 -1
  34. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DmjAI-UV.js +1 -0
  35. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Dug7Bq1S.js +1 -0
  36. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Dv5BSBQG.js +1 -0
  37. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DzBTnFhV.js +1 -0
  38. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DzX_yyqb.js +1 -0
  39. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Frwd2CjB.js +1 -0
  40. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/H4l0JFh9.js +1 -0
  41. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/H60ATh8g.js +2 -0
  42. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{6t3IJ0vQ.js → qIv1kPyv.js} +1 -1
  43. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/sLqs1uaK.js +20 -0
  44. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/u-it74zV.js +96 -0
  45. lightly_studio/dist_lightly_studio_view_app/_app/immutable/entry/app.BPc0HQPq.js +2 -0
  46. lightly_studio/dist_lightly_studio_view_app/_app/immutable/entry/start.SNvc2nrm.js +1 -0
  47. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/0.5jT7P06o.js +1 -0
  48. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/1.Cdy-7S5q.js +1 -0
  49. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/10.C_uoESTX.js +1 -0
  50. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/12.DcO8wIAc.js +1 -0
  51. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/{2.C8HLK8mj.js → 2.BIldfkxL.js} +268 -113
  52. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/{3.CLvg3QcJ.js → 3.BC9z_TWM.js} +1 -1
  53. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/{4.BQhDtXUI.js → 4.D8X_Ch5n.js} +1 -1
  54. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/5.CAXhxJu6.js +39 -0
  55. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/{6.uBV1Lhat.js → 6.DRA5Ru_2.js} +1 -1
  56. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/7.WVBsruHQ.js +1 -0
  57. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/8.BuKUrCEN.js +20 -0
  58. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/9.CUIn1yCR.js +1 -0
  59. lightly_studio/dist_lightly_studio_view_app/_app/version.json +1 -1
  60. lightly_studio/dist_lightly_studio_view_app/index.html +15 -14
  61. lightly_studio/examples/example.py +4 -0
  62. lightly_studio/examples/example_coco.py +4 -0
  63. lightly_studio/examples/example_coco_caption.py +24 -0
  64. lightly_studio/examples/example_metadata.py +4 -1
  65. lightly_studio/examples/example_selection.py +4 -0
  66. lightly_studio/examples/example_split_work.py +4 -0
  67. lightly_studio/examples/example_yolo.py +4 -0
  68. lightly_studio/export/export_dataset.py +11 -3
  69. lightly_studio/metadata/compute_typicality.py +1 -1
  70. lightly_studio/models/caption.py +73 -0
  71. lightly_studio/models/dataset.py +1 -2
  72. lightly_studio/models/metadata.py +1 -1
  73. lightly_studio/models/sample.py +2 -2
  74. lightly_studio/resolvers/caption_resolver.py +80 -0
  75. lightly_studio/resolvers/dataset_resolver.py +4 -7
  76. lightly_studio/resolvers/metadata_resolver/__init__.py +2 -2
  77. lightly_studio/resolvers/metadata_resolver/sample/__init__.py +3 -3
  78. lightly_studio/resolvers/metadata_resolver/sample/bulk_update_metadata.py +46 -0
  79. lightly_studio/resolvers/samples_filter.py +18 -10
  80. lightly_studio/type_definitions.py +2 -0
  81. {lightly_studio-0.3.3.dist-info → lightly_studio-0.3.4.dist-info}/METADATA +86 -21
  82. {lightly_studio-0.3.3.dist-info → lightly_studio-0.3.4.dist-info}/RECORD +83 -77
  83. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/0.CA_CXIBb.css +0 -1
  84. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/_layout.DS78jgNY.css +0 -1
  85. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/index.BVs_sZj9.css +0 -1
  86. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/transform.D487hwJk.css +0 -1
  87. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/8NsknIT2.js +0 -1
  88. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/BND_-4Kp.js +0 -1
  89. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/BjkP1AHA.js +0 -1
  90. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/BuuNVL9G.js +0 -1
  91. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/BzKGpnl4.js +0 -1
  92. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CCx7Ho51.js +0 -1
  93. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CH6P3X75.js +0 -1
  94. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CR2upx_Q.js +0 -4
  95. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CWPZrTTJ.js +0 -1
  96. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CwPowJfP.js +0 -1
  97. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CxFKfZ9T.js +0 -1
  98. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Cxevwdid.js +0 -1
  99. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/D4whDBUi.js +0 -1
  100. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/D6r9vr07.js +0 -1
  101. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DA6bFLPR.js +0 -1
  102. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DEgUu98i.js +0 -3
  103. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DGTPl6Gk.js +0 -1
  104. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DKGxBSlK.js +0 -1
  105. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DQXoLcsF.js +0 -1
  106. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DQe_kdRt.js +0 -92
  107. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DcY4jgG3.js +0 -1
  108. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/H7C68rOM.js +0 -1
  109. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/RmD8FzRo.js +0 -1
  110. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/V-MnMC1X.js +0 -1
  111. lightly_studio/dist_lightly_studio_view_app/_app/immutable/entry/app.BVr6DYqP.js +0 -2
  112. lightly_studio/dist_lightly_studio_view_app/_app/immutable/entry/start.u7zsVvqp.js +0 -1
  113. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/0.Da2agmdd.js +0 -1
  114. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/1.B11tVRJV.js +0 -1
  115. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/10.l30Zud4h.js +0 -1
  116. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/12.CgKPGcAP.js +0 -1
  117. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/5.-6XqWX5G.js +0 -1
  118. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/7.BXsgoQZh.js +0 -1
  119. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/8.BkbcnUs8.js +0 -1
  120. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/9.Bkrv-Vww.js +0 -1
  121. lightly_studio/resolvers/metadata_resolver/sample/bulk_set_metadata.py +0 -48
  122. {lightly_studio-0.3.3.dist-info → lightly_studio-0.3.4.dist-info}/WHEEL +0 -0
@@ -1 +1 @@
1
- import{u as a}from"../chunks/CCx7Ho51.js";import{L as d}from"../chunks/Cxevwdid.js";const s=async({parent:t,params:{dataset_id:e}})=>{const{globalStorage:o}=await t(),{tagsSelected:n}=a({dataset_id:e,kind:["annotation"]});return{annotationsSelectedTagsIds:n,annotationsSelectedAnnotationLabelsIds:o.selectedAnnotationFilterIds}},r=Object.freeze(Object.defineProperty({__proto__:null,load:s},Symbol.toStringTag,{value:"Module"}));export{d as component,r as universal};
1
+ import{u as a}from"../chunks/Cy4fgWTG.js";import{L as d}from"../chunks/Dv5BSBQG.js";const s=async({parent:t,params:{dataset_id:e}})=>{const{globalStorage:o}=await t(),{tagsSelected:n}=a({dataset_id:e,kind:["annotation"]});return{annotationsSelectedTagsIds:n,annotationsSelectedAnnotationLabelsIds:o.selectedAnnotationFilterIds}},r=Object.freeze(Object.defineProperty({__proto__:null,load:s},Symbol.toStringTag,{value:"Module"}));export{d as component,r as universal};
@@ -1 +1 @@
1
- import{u as a}from"../chunks/8NsknIT2.js";import{u as l}from"../chunks/CCx7Ho51.js";import{u as m}from"../chunks/6t3IJ0vQ.js";import{L as b}from"../chunks/Cxevwdid.js";const r=async({params:{dataset_id:e}})=>{const{selectedAnnotationFilterIds:s,textEmbedding:o}=m(),{tagsSelected:t}=l({dataset_id:e,kind:["sample"]}),{dimensionsValues:n}=a();return{samplesSelectedTagsIds:t,samplesDimensions:n,samplesTextEmbedding:o,samplesSelectedAnnotationLabelsIds:s}},c=Object.freeze(Object.defineProperty({__proto__:null,load:r},Symbol.toStringTag,{value:"Module"}));export{b as component,c as universal};
1
+ import{u as a}from"../chunks/Bqz7dyEC.js";import{u as l}from"../chunks/Cy4fgWTG.js";import{u as m}from"../chunks/qIv1kPyv.js";import{L as b}from"../chunks/Dv5BSBQG.js";const r=async({params:{dataset_id:e}})=>{const{selectedAnnotationFilterIds:s,textEmbedding:o}=m(),{tagsSelected:t}=l({dataset_id:e,kind:["sample"]}),{dimensionsValues:n}=a();return{samplesSelectedTagsIds:t,samplesDimensions:n,samplesTextEmbedding:o,samplesSelectedAnnotationLabelsIds:s}},c=Object.freeze(Object.defineProperty({__proto__:null,load:r},Symbol.toStringTag,{value:"Module"}));export{b as component,c as universal};
@@ -0,0 +1,39 @@
1
+ import"../chunks/CWj6FrbW.js";import{p as mt,f as _,n as re,a as gt,au as Qt,g as t,b as r,s as h,c as $,r as I,t as ut,m as vt,u as De,Y as s,ak as R,aa as te,$ as ee}from"../chunks/Frwd2CjB.js";import{c as J,a as c,f as Q,t as ae,b as $t}from"../chunks/CiaNZCBa.js";import{s as It}from"../chunks/DzX_yyqb.js";import{i as Y,s as j,a as zt}from"../chunks/-DXuGN29.js";import{p as yt}from"../chunks/DSxvnAMh.js";import{I as le,o as He,p as Fe,q as ze,r as At,f as Ne,s as Xe,_ as Ye,t as Ue,C as Ze,v as Ke,S as Oe,n as je,w as Ge,x as Ve}from"../chunks/Cqo0Vpvt.js";import{u as ie}from"../chunks/qIv1kPyv.js";import{u as de,k as We,t as ct,s as H,e as qe,b as Je}from"../chunks/D_ynJAfY.js";import"../chunks/Bqz7dyEC.js";import"../chunks/D5w4xp5l.js";import"../chunks/69_IOA4Y.js";import{a as Qe,g as ta}from"../chunks/DQ8aZ1o-.js";import{e as ne}from"../chunks/Dug7Bq1S.js";import{s as ce,r as ue,p as ea,b as oe}from"../chunks/Dafy4oEQ.js";import{S as aa}from"../chunks/CZGpyrcA.js";import{r as St}from"../chunks/CfQ4mGwl.js";import{S as na,s as oa,d as sa,R as ra}from"../chunks/DmjAI-UV.js";import{s as se}from"../chunks/H60ATh8g.js";import{B as la,a as ia,b as wt,c as Ht,H as da,d as Ft,D as ca,e as ua,u as me,Z as ma,g as ga}from"../chunks/u-it74zV.js";import{b as ha,d as va,e as fa,r as pa}from"../chunks/DD63uD-T.js";function _a(u,e){mt(e,!0);/**
2
+ * @license @lucide/svelte v0.482.0 - ISC
3
+ *
4
+ * ISC License
5
+ *
6
+ * Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
7
+ *
8
+ * Permission to use, copy, modify, and/or distribute this software for any
9
+ * purpose with or without fee is hereby granted, provided that the above
10
+ * copyright notice and this permission notice appear in all copies.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ *
20
+ */let m=ue(e,["$$slots","$$events","$$legacy"]);const l=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}],["circle",{cx:"10",cy:"12",r:"2"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22"}]];le(u,ce({name:"file-image"},()=>m,{get iconNode(){return l},children:(n,i)=>{var d=J(),p=_(d);It(p,()=>e.children??re),c(n,d)},$$slots:{default:!0}})),gt()}function ba(u,e){mt(e,!0);/**
21
+ * @license @lucide/svelte v0.482.0 - ISC
22
+ *
23
+ * ISC License
24
+ *
25
+ * Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
26
+ *
27
+ * Permission to use, copy, modify, and/or distribute this software for any
28
+ * purpose with or without fee is hereby granted, provided that the above
29
+ * copyright notice and this permission notice appear in all copies.
30
+ *
31
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
32
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
33
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
34
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
35
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
36
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
37
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
38
+ *
39
+ */let m=ue(e,["$$slots","$$events","$$legacy"]);const l=[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18"}],["circle",{cx:"12",cy:"8",r:"2"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2"}]];le(u,ce({name:"images"},()=>m,{get iconNode(){return l},children:(n,i)=>{var d=J(),p=_(d);It(p,()=>e.children??re),c(n,d)},$$slots:{default:!0}})),gt()}var xa=Q('<!> <span class="hidden sm:inline">Home</span>',1),wa=Q('<!> <span class="max-w-[150px] truncate"> </span>',1),ya=Q('<!> <span class="hidden sm:inline">Samples</span>',1),Sa=Q('<!> <span class="max-w-[200px] truncate"><!></span>',1),$a=Q("<!> <!> <!> <!> <!> <!> <!>",1);function Ia(u,e){mt(e,!0);const m=()=>j(i,"$samplesTotalCount",l),[l,n]=zt(),{samplesTotalCount:i}=ie();la(u,{class:"mb-2","data-testid":"sample-details-breadcrumb",children:(d,p)=>{ia(d,{children:(tt,ot)=>{var F=$a(),w=_(F);wt(w,{children:(A,G)=>{{let g=r(()=>St.toHome());Ht(A,{get href(){return t(g)},class:"flex items-center gap-2",children:(P,T)=>{var b=xa(),y=_(b);da(y,{class:"h-4 w-4"}),Qt(2),c(P,b)},$$slots:{default:!0}})}},$$slots:{default:!0}});var z=h(w,2);Ft(z,{});var C=h(z,2);wt(C,{children:(A,G)=>{{let g=r(()=>St.toSamples(e.dataset.dataset_id));Ht(A,{get href(){return t(g)},class:"flex items-center gap-2",children:(P,T)=>{var b=wa(),y=_(b);ca(y,{class:"h-4 w-4"});var M=h(y,2),et=$(M,!0);I(M),ut(()=>se(et,e.dataset.name)),c(P,b)},$$slots:{default:!0}})}},$$slots:{default:!0}});var U=h(C,2);Ft(U,{});var N=h(U,2);wt(N,{children:(A,G)=>{{let g=r(()=>St.toSamples(e.dataset.dataset_id));Ht(A,{get href(){return t(g)},class:"flex items-center gap-2",children:(P,T)=>{var b=ya(),y=_(b);ba(y,{class:"h-4 w-4"}),Qt(2),c(P,b)},$$slots:{default:!0}})}},$$slots:{default:!0}});var st=h(N,2);Ft(st,{});var rt=h(st,2);wt(rt,{children:(A,G)=>{ua(A,{class:"flex items-center gap-2",children:(g,P)=>{var T=Sa(),b=_(T);_a(b,{class:"h-4 w-4"});var y=h(b,2),M=$(y);{var et=V=>{var lt=ae();ut(()=>se(lt,`Sample ${e.sampleIndex+1} of ${m()??""}`)),c(V,lt)},Pt=V=>{var lt=ae("Sample");c(V,lt)};Y(M,V=>{e.sampleIndex!==void 0?V(et):V(Pt,!1)})}I(y),c(g,T)},$$slots:{default:!0}})},$$slots:{default:!0}}),c(tt,F)},$$slots:{default:!0}})},$$slots:{default:!0}}),gt(),n()}function Aa(u,e){mt(e,!0);const m=()=>j(t(F),"$annotationResp",i),l=()=>j(t(U),"$sample",i),n=()=>j(tt,"$showAnnotationTextLabelsStore",i),[i,d]=zt(),p=ea(e,"isResizable",3,!1),{showAnnotationTextLabelsStore:tt}=de(),ot=r(()=>ze({datasetId:e.datasetId,annotationId:e.annotationId})),F=r(()=>t(ot).annotation),w=r(()=>t(ot).updateAnnotation);let z=r(()=>m().data);const C=r(()=>me({sampleId:e.sampleId,datasetId:e.datasetId})),U=r(()=>t(C).sample);let N=r(()=>m().data?He(m().data):void 0);const st=g=>{(async()=>{try{await t(w)({annotation_id:e.annotationId,dataset_id:e.datasetId,bounding_box:g})}catch(T){console.error("Failed to update annotation:",T.message)}})()};var rt=J(),A=_(rt);{var G=g=>{var P=J(),T=_(P);We(T,()=>t(N),b=>{Fe(b,{get groupId(){return t(z).annotation_id},get onSelect(){return e.toggleAnnotationSelection},get box(){return t(N)},get isSelected(){return e.isSelected},children:(y,M)=>{{let et=r(()=>({x:0,y:0,width:l().data.width,height:l().data.height}));na(y,{get annotation(){return t(z)},get showLabel(){return n()},get imageWidth(){return l().data.width},get constraintBox(){return t(et)},get isResizable(){return p()},onBoundingBoxChanged:st})}},$$slots:{default:!0}})}),c(g,P)};Y(A,g=>{t(z)&&l().data&&t(N)&&g(G)})}c(u,rt),gt(),d()}const Pa=({datasetId:u})=>{const e=At(ha());return e.subscribe(()=>{}),{createAnnotation:l=>new Promise((n,i)=>{vt(e).mutate({path:{dataset_id:u},body:l},{onSuccess:d=>{n(d)},onError:d=>{i(d)}})})}},Ma=()=>{const u=At(va());return u.subscribe(()=>{}),{createLabel:m=>new Promise((l,n)=>{vt(u).mutate({body:m},{onSuccess:i=>{l(i)},onError:i=>{n(i)}})})}},ka=({datasetId:u})=>{const e=At(fa());return e.subscribe(()=>{}),{deleteAnnotation:l=>new Promise((n,i)=>{vt(e).mutate({path:{dataset_id:u,annotation_id:l}},{onSuccess:()=>{n()},onError:d=>{i(d)}})})}},Ba=({datasetId:u})=>{const e=At(pa());return e.subscribe(()=>{}),{removeTagFromSample:(l,n)=>new Promise((i,d)=>{vt(e).mutate({path:{dataset_id:u,sample_id:l,tag_id:n}},{onSuccess:()=>i(),onError:p=>d(p)})})}};var Ea=$t('<line x1="0" stroke-width="1" vector-effect="non-scaling-stroke" stroke-dasharray="5,5" opacity="0.6"></line><line y1="0" vector-effect="non-scaling-stroke" stroke-width="1" stroke-dasharray="5,5" opacity="0.6"></line>',1),Ra=$t('<rect class="select-none" fill="transparent" role="button" style="outline: 0;cursor: crosshair;" tabindex="0"></rect>'),Ca=$t("<g><!><!><!></g><!>",1),Ta=$t("<image></image><!>",1),La=Q('<div class="h-full w-full overflow-hidden"><div class="sample relative h-full w-full"><div class="absolute right-4 top-2 z-30"><!></div> <!> <!></div></div>'),Da=Q('<div class="flex h-full w-full flex-col space-y-4"><div class="flex w-full items-center"><!></div> <!> <div class="flex min-h-0 flex-1 gap-4"><div class="flex-1"><!></div> <div class="relative w-[375px]"><!></div></div></div>');function Ha(u,e){mt(e,!0);const m=()=>j(T,"$labels",p),l=()=>j(y,"$isEditingMode",p),n=()=>j(t(G),"$sample",p),i=()=>j(ot,"$selectedSampleIds",p),d=()=>j(z,"$isHidden",p),[p,tt]=zt(),{selectedSampleIds:ot,toggleSampleSelection:F}=ie(),w=e.dataset.dataset_id,{isHidden:z,handleKeyEvent:C}=Ne(),{settingsStore:U}=de(),{deleteAnnotation:N}=ka({datasetId:w}),{removeTagFromSample:st}=Ba({datasetId:w}),rt=()=>{ta(St.toSamples(w))},A=r(()=>me({sampleId:e.sampleId,datasetId:w})),G=r(()=>t(A).sample),g=r(()=>t(A).refetch),{createAnnotation:P}=Pa({datasetId:w}),T=Xe(),{createLabel:b}=Ma(),{isEditingMode:y}=yt.data.globalStorage;let M=R(!1);const et=async({x:a,y:o,width:k,height:L,labelName:v})=>{if(!m().data)return;let B=m().data.find(x=>x.annotation_label_name===v);B||(B=await b({annotation_label_name:v}));try{const x=await P({sample_id:e.sampleId,annotation_type:"object_detection",x:Math.round(a),y:Math.round(o),width:Math.round(k),height:Math.round(L),annotation_label_id:B.annotation_label_id});return t(g)(),s(Z,x.annotation_id,!0),ct.success("Annotation created successfully"),x}catch(x){ct.error("Failed to create annotation. Please try again."),console.error("Error creating annotation:",x);return}},Pt=a=>{switch(a.key){case vt(U).key_go_back:rt();break;case" ":a.preventDefault(),a.stopPropagation(),console.log("space pressed in sample details"),l()?s(M,!0):F(e.sampleId);break}C(a)},V=a=>{a.key===" "&&s(M,!1),C(a)};let lt=r(()=>ga(e.sampleId)),Z=R(void 0);Qe(()=>{s(Z,void 0),s(Xt,void 0)});const Nt=a=>{t(M)||(t(Z)===a?s(Z,void 0):s(Z,a,!0))};let Xt=R(void 0),it=R(!1),S=R(null),W=R(null),K=R(null);const ge=()=>{s(it,!1),s(S,null),s(K,null)};let ht=R(!1);const Yt=10,he=()=>{if(!t(W))return;const a=oa(t(W));let o=null;const k=sa().on("start",L=>{if(!t(ht))return;s(it,!0);const v=t(W).getBoundingClientRect(),B=L.sourceEvent.clientX,x=L.sourceEvent.clientY,D=(B-v.left)/v.width*n().data.width,E=(x-v.top)/v.height*n().data.height;o={x:D,y:E},s(S,{x:D,y:E,width:0,height:0},!0),s(K,{x:D,y:E},!0)}).on("drag",L=>{if(!t(S)||!t(it)||!o)return;const v=t(W).getBoundingClientRect(),B=L.sourceEvent.clientX,x=L.sourceEvent.clientY;let D=(B-v.left)/v.width*n().data.width,E=(x-v.top)/v.height*n().data.height;const Bt=n().data.width,Et=n().data.height;D=Math.max(0,Math.min(D,Bt)),E=Math.max(0,Math.min(E,Et));const nt=Math.min(o.x,D),dt=Math.min(o.y,E),Rt=Math.abs(D-o.x),Ot=Math.abs(E-o.y);s(S,{x:nt,y:dt,width:Rt,height:Ot},!0),s(K,{x:D,y:E},!0)}).on("end",()=>{!t(S)||!t(it)||(t(S).width>Yt&&t(S).height>Yt&&t(at)&&et({x:t(S).x,y:t(S).y,width:t(S).width,height:t(S).height,labelName:t(at).label}),ge(),o=null)});return a.call(k),a.on("mousemove",fe),()=>{k.on("start",null).on("drag",null).on("end",null)}},ve=a=>{if(!t(W)||t(it))return;const o=t(W).getBoundingClientRect(),k=a.clientX,L=a.clientY,v=(k-o.left)/o.width*n().data.width,B=(L-o.top)/o.height*n().data.height;s(K,{x:v,y:B},!0),a.stopPropagation(),a.preventDefault()},fe=Ye.throttle(ve,50);De(()=>{he(),t(G).subscribe(a=>{if(a.isSuccess&&a.data){let o=Ue(a.data);s(Mt,o,!0)}else s(Mt,[],!0)})});let at=R(void 0),Mt=R(te([])),ft=R(te(new Set));const pe=a=>{const o=new Set(t(ft));o.has(a)?o.delete(a):o.add(a),s(ft,o,!0)},_e=r(()=>t(Mt).filter(a=>!t(ft).has(a.annotation_id))),kt=r(()=>t(at)?Ge(t(at).label,1).color:"blue"),be=async a=>{if(!n().data)return;(async()=>{try{await N(a),ct.success("Annotation deleted successfully"),t(g)(),t(Z)===a&&s(Z,void 0)}catch(k){ct.error("Failed to delete annotation. Please try again."),console.error("Error deleting annotation:",k)}})()},xe=async a=>{try{await st(e.sampleId,a),ct.success("Tag removed successfully"),t(g)()}catch(o){ct.error("Failed to remove tag. Please try again."),console.error("Error removing tag from sample:",o)}},we=r(()=>t(M)?"grab":t(ht)?"crosshair":"auto"),ye=r(()=>l()&&!t(M)),Ut=r(()=>t(ht)&&!t(M));let Zt=R(null);var Kt=J();ne("keydown",ee,Pt),ne("keyup",ee,V);var Se=_(Kt);{var $e=a=>{var o=Da(),k=$(o),L=$(k);Ia(L,{get dataset(){return e.dataset},get sampleIndex(){return e.sampleIndex}}),I(k);var v=h(k,2);aa(v,{class:"mb-4 bg-border-hard"});var B=h(v,2),x=$(B),D=$(x);Ze(D,{className:"h-full",children:(nt,dt)=>{Ke(nt,{className:"h-full",children:(Rt,Ot)=>{var Ct=La(),Tt=$(Ct),Lt=$(Tt),Ae=$(Lt);{let q=r(()=>i().has(e.sampleId));Oe(Ae,{onSelect:()=>F(e.sampleId),get isSelected(){return t(q)}})}I(Lt);var jt=h(Lt,2);{var Pe=q=>{var pt=J(),_t=_(pt);It(_t,()=>e.children),c(q,pt)};Y(jt,q=>{e.children&&q(Pe)})}var Me=h(jt,2);ma(Me,{get width(){return n().data.width},get height(){return n().data.height},get cursor(){return t(we)},get boundingBox(){return t(Xt)},zoomableContent:pt=>{var _t=Ta(),Gt=_(_t),ke=h(Gt);{var Be=Dt=>{var Vt=Ca(),bt=_(Vt);let Wt;var qt=$(bt);qe(qt,17,()=>t(_e),f=>f.annotation_id,(f,X)=>{{let O=r(()=>t(Z)===t(X).annotation_id);Aa(f,{get annotationId(){return t(X).annotation_id},get sampleId(){return e.sampleId},get datasetId(){return w},get isResizable(){return t(ye)},get isSelected(){return t(O)},toggleAnnotationSelection:Nt})}});var Jt=h(qt);{var Ee=f=>{ra(f,{get bbox(){return t(S)},get colorStroke(){return t(kt)},colorFill:"rgba(0, 123, 255, 0.1)",style:"outline: 0;",opacity:.8,scale:1})};Y(Jt,f=>{t(S)&&t(it)&&t(at)&&f(Ee)})}var Re=h(Jt);{var Ce=f=>{var X=Ea(),O=_(X),xt=h(O);ut(()=>{H(O,"y1",t(K).y),H(O,"x2",n().data.width),H(O,"y2",t(K).y),H(O,"stroke",t(kt)),H(xt,"x1",t(K).x),H(xt,"x2",t(K).x),H(xt,"y2",n().data.height),H(xt,"stroke",t(kt))}),c(f,X)};Y(Re,f=>{t(K)&&t(Ut)&&f(Ce)})}I(bt);var Te=h(bt);{var Le=f=>{var X=Ra();oe(X,O=>s(W,O),()=>t(W)),ut(()=>{H(X,"width",n().data.width),H(X,"height",n().data.height)}),c(f,X)};Y(Te,f=>{t(Ut)&&f(Le)})}ut(f=>Wt=Je(bt,0,"",null,Wt,f),[()=>({invisible:d()})]),c(Dt,Vt)};Y(ke,Dt=>{n().data&&Dt(Be)})}ut(()=>H(Gt,"href",t(lt))),c(pt,_t)},$$slots:{zoomableContent:!0}}),I(Tt),oe(Tt,q=>s(Zt,q),()=>t(Zt)),I(Ct),c(Rt,Ct)},$$slots:{default:!0}})},$$slots:{default:!0}}),I(x);var E=h(x,2),Bt=$(E);{var Et=nt=>{Ve(nt,{get sample(){return n().data},get annotationsIdsToHide(){return t(ft)},get selectedAnnotationId(){return t(Z)},onAnnotationClick:Nt,onToggleShowAnnotation:pe,onDeleteAnnotation:be,onRemoveTag:xe,get onUpdate(){return t(g)},get addAnnotationEnabled(){return t(ht)},set addAnnotationEnabled(dt){s(ht,dt,!0)},get addAnnotationLabel(){return t(at)},set addAnnotationLabel(dt){s(at,dt,!0)}})};Y(Bt,nt=>{n().data&&nt(Et)})}I(E),I(B),I(o),c(a,o)},Ie=a=>{je(a,{})};Y(Se,a=>{n().data?a($e):a(Ie,!1)})}c(u,Kt),gt(),tt()}var Fa=Q('<div class="flex h-full w-full space-x-4 px-4 pb-4" data-testid="sample-details"><div class="h-full w-full space-y-6 rounded-[1vw] bg-card p-4"><!></div></div>');function rn(u,e){mt(e,!0);const m=r(()=>yt.params.sampleId),l=yt.data.dataset,n=r(()=>Number(yt.params.sampleIndex));var i=Fa(),d=$(i),p=$(d);Ha(p,{get sampleId(){return t(m)},get dataset(){return l},get sampleIndex(){return t(n)},children:(tt,ot)=>{var F=J(),w=_(F);{var z=C=>{var U=J(),N=_(U);It(N,()=>e.children),c(C,U)};Y(w,C=>{e.children&&C(z)})}c(tt,F)},$$slots:{default:!0}}),I(d),I(i),c(u,i),gt()}export{rn as component};
@@ -1 +1 @@
1
- import{r as s}from"../chunks/H7C68rOM.js";import{r as d}from"../chunks/CxFKfZ9T.js";import{r as n}from"../chunks/B90CZVMX.js";const i=async()=>{const{data:t}=await d();if(!t||t.length===0)throw new Error("No datasets found");const e=t.toSorted((r,o)=>new Date(o.created_at||0).getTime()-new Date(r.created_at||0).getTime())[0],a=e==null?void 0:e.dataset_id;if(!a)throw new Error("No valid dataset ID found");n(307,s.toSamples(a))},m=Object.freeze(Object.defineProperty({__proto__:null,load:i},Symbol.toStringTag,{value:"Module"}));export{m as universal};
1
+ import{r as s}from"../chunks/CfQ4mGwl.js";import{r as d}from"../chunks/D5w4xp5l.js";import{r as n}from"../chunks/B90CZVMX.js";const i=async()=>{const{data:t}=await d();if(!t||t.length===0)throw new Error("No datasets found");const e=t.toSorted((r,o)=>new Date(o.created_at||0).getTime()-new Date(r.created_at||0).getTime())[0],a=e==null?void 0:e.dataset_id;if(!a)throw new Error("No valid dataset ID found");n(307,s.toSamples(a))},m=Object.freeze(Object.defineProperty({__proto__:null,load:i},Symbol.toStringTag,{value:"Module"}));export{m as universal};
@@ -0,0 +1 @@
1
+ import"../chunks/CWj6FrbW.js";import{p as f,u as $,g as a,a as _,b as o}from"../chunks/Frwd2CjB.js";import{s as i,a as h}from"../chunks/-DXuGN29.js";import{A as S}from"../chunks/Cqo0Vpvt.js";import{u as T}from"../chunks/qIv1kPyv.js";import"../chunks/D_ynJAfY.js";import"../chunks/Bqz7dyEC.js";import"../chunks/D5w4xp5l.js";import"../chunks/DSxvnAMh.js";import"../chunks/69_IOA4Y.js";import"../chunks/DQ8aZ1o-.js";import{u as G}from"../chunks/Cy4fgWTG.js";import"../chunks/DzX_yyqb.js";function q(n,t){f(t,!0);const p=()=>i(c,"$lastGridType",s),e=()=>i(d,"$sampleSize",s),[s,m]=h(),{datasetId:r,sampleSize:d,selectedAnnotationFilterIds:l}=t.data,{lastGridType:c}=T(),u=o(()=>G({dataset_id:r})),g=o(()=>a(u).clearTagsSelected);$(()=>{p()!=="annotations"&&a(g)()}),S(n,{get itemHeight(){return e().height},get itemWidth(){return e().width},get dataset_id(){return r},get selectedAnnotationFilterIds(){return l}}),_(),m()}export{q as component};
@@ -0,0 +1,20 @@
1
+ import{p as U,f as E,n as Qt,a as z,w as Dt,m as _t,$ as gt,g as t,b as i,c as g,r as f,s as S,t as G,Y as pt,ak as Et,au as Ct}from"../chunks/Frwd2CjB.js";import{l as Xt}from"../chunks/D5w4xp5l.js";import{u as xt}from"../chunks/qIv1kPyv.js";import"../chunks/CWj6FrbW.js";import{c as Q,a as m,f as C,t as Nt,b as ta}from"../chunks/CiaNZCBa.js";import{i as T,s as R,a as Y}from"../chunks/-DXuGN29.js";import{e as ht}from"../chunks/Dug7Bq1S.js";import{s as et,e as aa,g as ea,u as na,k as oa,b as sa,t as ia}from"../chunks/D_ynJAfY.js";import{g as at,c as ra}from"../chunks/DQ8aZ1o-.js";import{I as da,s as la,q as nt,y as ca,z as ua,B as va,D as ma,o as bt,E as Bt,F as fa,C as Lt,v as Rt,H as _a,n as jt,f as ga,S as pa}from"../chunks/Cqo0Vpvt.js";import"../chunks/Bqz7dyEC.js";import{p as H}from"../chunks/DSxvnAMh.js";import"../chunks/69_IOA4Y.js";import{S as ha}from"../chunks/CZGpyrcA.js";import{s as ba}from"../chunks/DzX_yyqb.js";import{r as q}from"../chunks/CfQ4mGwl.js";import{S as xa}from"../chunks/DmjAI-UV.js";import{B as Ia,a as Aa,b as tt,c as mt,H as wa,d as ft,D as Sa,e as $a,Z as ya,g as Ma,u as ka}from"../chunks/u-it74zV.js";import{S as Pa}from"../chunks/CSCQddQS.js";import{s as V}from"../chunks/H60ATh8g.js";import{C as Ca}from"../chunks/sLqs1uaK.js";import{s as Na,r as Ba}from"../chunks/Dafy4oEQ.js";function Da(u,a){U(a,!0);/**
2
+ * @license @lucide/svelte v0.482.0 - ISC
3
+ *
4
+ * ISC License
5
+ *
6
+ * Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
7
+ *
8
+ * Permission to use, copy, modify, and/or distribute this software for any
9
+ * purpose with or without fee is hereby granted, provided that the above
10
+ * copyright notice and this permission notice appear in all copies.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ *
20
+ */let e=Ba(a,["$$slots","$$events","$$legacy"]);const d=[["path",{d:"M5 3a2 2 0 0 0-2 2"}],["path",{d:"M19 3a2 2 0 0 1 2 2"}],["path",{d:"M21 19a2 2 0 0 1-2 2"}],["path",{d:"M5 21a2 2 0 0 1-2-2"}],["path",{d:"M9 3h1"}],["path",{d:"M9 21h1"}],["path",{d:"M14 3h1"}],["path",{d:"M14 21h1"}],["path",{d:"M3 9v1"}],["path",{d:"M21 9v1"}],["path",{d:"M3 14v1"}],["path",{d:"M21 14v1"}]];da(u,Na({name:"square-dashed"},()=>e,{get iconNode(){return d},children:(o,l)=>{var s=Q(),I=E(s);ba(I,()=>a.children??Qt),m(o,s)},$$slots:{default:!0}})),z()}const Ea=({annotationIndex:u,...a})=>{const e=Dt({isLoading:!1});return(async()=>{e.update(o=>({...o,isLoading:!0}));try{const{data:o}=await Xt({path:{dataset_id:a.dataset_id},query:{cursor:u>0?u-1:0,limit:3,annotation_label_ids:a.annotation_label_ids,tag_ids:a.tag_ids}});if(!o){e.update(n=>({...n,isLoading:!1,error:"No annotations data received",data:void 0}));return}const{setAnnotationsTotalCount:l}=xt();l(o.total_count);let s;const I=u>0?o.data[0]:void 0;o.data.length>1&&(s=u===0?o.data[1]:o.data[2]),e.update(n=>({...n,isLoading:!1,error:void 0,data:{annotationNext:s,annotationPrevious:I}}))}catch(o){e.update(l=>({...l,isLoading:!1,error:String(o)}))}})(),e},La=async({parent:u,params:{dataset_id:a,annotationId:e,annotationIndex:d}})=>{const{annotationsSelectedTagsIds:o,annotationsSelectedAnnotationLabelsIds:l,dataset:s}=await u(),I=parseInt(d,10),n=Dt();if(!s)throw new Error("Dataset data not found");return Ea({annotationIndex:I,dataset_id:a,currentAnnotationId:e,annotation_label_ids:Array.from(_t(l)),tag_ids:Array.from(_t(o))}).subscribe(({data:D})=>{n.set(D)}),{annotationAdjacents:n,annotationIndex:I,annotationId:e,dataset:s}},Pe=Object.freeze(Object.defineProperty({__proto__:null,load:La},Symbol.toStringTag,{value:"Module"}));function Ra(u,a){U(a,!0);const e=()=>R(t(s),"$annotationAdjacents",d),[d,o]=Y(),l=i(()=>H.data.annotationIndex),s=i(()=>H.data.annotationAdjacents),I=()=>{e().annotationNext&&at(q.toSampleWithAnnotation({datasetId:e().annotationNext.dataset_id,sampleId:e().annotationNext.sample_id,annotationId:e().annotationNext.annotation_id,annotationIndex:t(l)+1}))},n=()=>{e().annotationPrevious&&at(q.toSampleWithAnnotation({datasetId:e().annotationPrevious.dataset_id,sampleId:e().annotationPrevious.sample_id,annotationId:e().annotationPrevious.annotation_id,annotationIndex:t(l)-1}))},D=p=>{switch(p.key){case"ArrowRight":I();break;case"ArrowLeft":n();break}};var $=Q();ht("keydown",gt,D);var w=E($);{var y=p=>{{let h=i(()=>!!e().annotationPrevious),A=i(()=>!!e().annotationNext);Pa(p,{get hasPrevious(){return t(h)},get hasNext(){return t(A)},onPrevious:n,onNext:I})}};T(w,p=>{e()&&p(y)})}m(u,$),z(),o()}const ja={object_detection:"Object Detection",instance_segmentation:"Instance Segmentation",semantic_segmentation:"Semantic Segmentation",classification:"Classification"};var Ta=C('<span class="text-sm"> </span> <span class="break-all text-sm"> </span>',1);function Ha(u,a){var e=Ta(),d=E(e),o=g(d,!0);f(d);var l=S(d,2),s=g(l,!0);f(l),G(()=>{V(o,a.label),et(l,"data-testid",`annotation-metadata-${a.id}`),V(s,a.value)}),m(u,e)}var Ua=C('<span class="break-all text-sm"> </span>'),za=C('<span class="text-sm"> </span> <!>',1);function Fa(u,a){U(a,!0);const e=()=>R(s,"$result",o),d=()=>R(a.isEditingMode,"$isEditingMode",o),[o,l]=Y(),s=la(),{updateAnnotation:I}=nt({datasetId:a.datasetId,annotationId:a.annotationId,onUpdate:a.onUpdate}),n=i(()=>va(e().data||[])),D=i(()=>{const b=t(n).find(r=>r.value===a.value);return b||{value:a.value,label:a.value}});var $=za(),w=E($),y=g(w,!0);f(w);var p=S(w,2);{var h=b=>{{const r=(x,v)=>{let k=()=>v==null?void 0:v().inputValue;ua(x,{get label(){return k()}})};let c=i(()=>t(n).find(x=>{var v;return x.value===((v=t(D))==null?void 0:v.value)}));ca(b,{get items(){return t(n)},get selectedItem(){return t(c)},name:"annotation-label",placeholder:"Select a label",onSelect:x=>{I({annotation_id:a.annotationId,dataset_id:a.datasetId,label_name:x.value})},notFound:r,$$slots:{notFound:!0}})}},A=b=>{var r=Ua();et(r,"data-testid","annotation-metadata-label");var c=g(r,!0);f(r),G(()=>V(c,a.value)),m(b,r)};T(p,b=>{d()?b(h):b(A,!1)})}G(()=>V(y,a.label)),m(u,$),z(),l()}var Oa=C('<div class="flex flex-col gap-4"><div class="grid grid-cols-[6rem_1fr] gap-y-3 text-diffuse-foreground"></div></div>');function qa(u,a){U(a,!0);const e=()=>R(t(I),"$annotationResp",d),[d,o]=Y(),{datasetId:l}=H.data,s=i(()=>nt({datasetId:l,annotationId:a.annotationId})),I=i(()=>t(s).annotation);let n=i(()=>e().data);const D=i(()=>{var A,b;if(!t(n))return[];let h=[{id:"label",label:"Label:",value:(b=(A=t(n))==null?void 0:A.annotation_label)==null?void 0:b.annotation_label_name},{id:"type",label:"Type:",value:ja[t(n).annotation_type]||"Unknown"}];if(t(n)&&!ma(t(n))){const{height:r,width:c}=bt(t(n));h=[{id:"height",label:"Height:",value:Bt(Math.round(r))+"px"},{id:"width",label:"Width:",value:Bt(Math.round(c))+"px"},...h]}return h}),{isEditingMode:$}=H.data.globalStorage;var w=Q(),y=E(w);{var p=h=>{fa(h,{title:"Annotation details",children:(A,b)=>{var r=Oa(),c=g(r);aa(c,21,()=>t(D),({label:x,value:v,id:k})=>x,(x,v)=>{let k=()=>t(v).label,L=()=>t(v).value,P=()=>t(v).id;var N=Q(),j=E(N);{var F=B=>{Fa(B,{get onUpdate(){return a.onUpdate},get annotationId(){return a.annotationId},get datasetId(){return l},get label(){return k()},get value(){return L()},get isEditingMode(){return $}})},_=B=>{Ha(B,{get label(){return k()},get id(){return P()},get value(){return L()}})};T(j,B=>{P()==="label"&&$?B(F):B(_,!1)})}m(x,N)}),f(c),f(r),m(A,r)}})};T(y,h=>{t(D).length>0&&h(p)})}m(u,w),z(),o()}var Ga=C('<!> <h2 class="py-2 text-lg font-semibold"><a>Check all sample annotations</a></h2>',1),Ka=C('<div class="flex h-full w-full items-center justify-center"><!></div>'),Wa=C('<div class="flex h-full min-h-0 flex-col space-y-4 overflow-hidden dark:[color-scheme:dark]"><!> <!></div>');function Va(u,a){U(a,!0);const{datasetId:e}=H.data;let d=Et(void 0);nt({datasetId:e,annotationId:a.annotationId}).annotation.subscribe(n=>{n.isSuccess&&pt(d,n.data.sample,!0)});const l=ea(),[s,I]=l;Lt(u,{className:"h-full",children:(n,D)=>{Rt(n,{className:"h-full flex flex-col",children:($,w)=>{var y=Wa(),p=g(y);qa(p,{get annotationId(){return a.annotationId},get onUpdate(){return a.onUpdate}});var h=S(p,2);{var A=r=>{var c=Ga(),x=E(c);_a(x,{get sample(){return t(d)},showCustomMetadata:!1});var v=S(x,2),k=g(v);f(v),G(L=>et(k,"href",L),[()=>s(q.toSample({sampleId:t(d).sample_id,datasetId:t(d).dataset_id}),void 0)]),m(r,c)},b=r=>{var c=Ka(),x=g(c);jt(x,{size:"large",align:"center"}),f(c),m(r,c)};T(h,r=>{t(d)?r(A):r(b,!1)})}f(y),m($,y)},$$slots:{default:!0}})},$$slots:{default:!0}}),z()}var Ya=C('<!> <span class="hidden sm:inline">Home</span>',1),Za=C('<!> <span class="max-w-[150px] truncate"> </span>',1),Ja=C('<!> <span class="hidden sm:inline">Annotations</span>',1),Qa=C('<!> <span class="max-w-[200px] truncate"><!></span>',1),Xa=C("<!> <!> <!> <!> <!> <!> <!>",1);function te(u,a){U(a,!0);const e=()=>R(l,"$annotationsTotalCount",d),[d,o]=Y(),{annotationsTotalCount:l}=xt();Ia(u,{class:"mb-2",children:(s,I)=>{Aa(s,{children:(n,D)=>{var $=Xa(),w=E($);tt(w,{children:(c,x)=>{{let v=i(()=>q.toHome());mt(c,{get href(){return t(v)},class:"flex items-center gap-2",children:(k,L)=>{var P=Ya(),N=E(P);wa(N,{class:"h-4 w-4"}),Ct(2),m(k,P)},$$slots:{default:!0}})}},$$slots:{default:!0}});var y=S(w,2);ft(y,{});var p=S(y,2);tt(p,{children:(c,x)=>{{let v=i(()=>q.toAnnotations(a.dataset.dataset_id));mt(c,{get href(){return t(v)},class:"flex items-center gap-2",children:(k,L)=>{var P=Za(),N=E(P);Sa(N,{class:"h-4 w-4"});var j=S(N,2),F=g(j,!0);f(j),G(()=>V(F,a.dataset.name)),m(k,P)},$$slots:{default:!0}})}},$$slots:{default:!0}});var h=S(p,2);ft(h,{});var A=S(h,2);tt(A,{children:(c,x)=>{{let v=i(()=>q.toAnnotations(a.dataset.dataset_id));mt(c,{get href(){return t(v)},class:"flex items-center gap-2",children:(k,L)=>{var P=Ja(),N=E(P);Ca(N,{class:"h-4 w-4"}),Ct(2),m(k,P)},$$slots:{default:!0}})}},$$slots:{default:!0}});var b=S(A,2);ft(b,{});var r=S(b,2);tt(r,{children:(c,x)=>{$a(c,{class:"flex items-center gap-2",children:(v,k)=>{var L=Qa(),P=E(L);Da(P,{class:"h-4 w-4"});var N=S(P,2),j=g(N);{var F=B=>{var K=Nt();G(()=>V(K,`Annotation ${a.annotationIndex+1} of ${e()??""}`)),m(B,K)},_=B=>{var K=Nt("Annotation");m(B,K)};T(j,B=>{a.annotationIndex?B(F):B(_,!1)})}f(N),m(v,L)},$$slots:{default:!0}})},$$slots:{default:!0}}),m(n,$)},$$slots:{default:!0}})},$$slots:{default:!0}}),z(),o()}var ae=ta("<image></image><g><!></g>",1),ee=C('<div class="h-full w-full overflow-hidden"><div class="sample relative h-full w-full"><div class="absolute right-4 top-2 z-30"><!></div> <!> <!></div></div>'),ne=C('<div class="flex h-full w-full items-center justify-center"><!></div>'),oe=C('<div class="flex h-full w-full flex-col space-y-4"><div class="flex w-full items-center"><!></div> <!> <div class="flex min-h-0 flex-1 gap-4"><div class="flex-1"><!></div> <div class="relative w-[375px]"><!></div></div></div>');function se(u,a){U(a,!0);const e=()=>R(Tt,"$isEditingMode",s),d=()=>R(t(P),"$annotationResp",s),o=()=>R(D,"$selectedSampleAnnotationCropIds",s),l=()=>R(y,"$isHidden",s),[s,I]=Y(),{toggleSampleAnnotationCropSelection:n,selectedSampleAnnotationCropIds:D,clearReversibleActionsByGroupId:$,addReversibleAction:w}=xt(),{isHidden:y,handleKeyEvent:p}=ga(),{settingsStore:h}=na(),A=" ",b=_t(h).key_go_back;let r=Et(!1);const c=()=>{var M;(M=a.sample)!=null&&M.dataset_id?at(q.toAnnotations(a.sample.dataset_id)):at("/")},x=M=>{switch(M.key){case b:c();break;case" ":M.preventDefault(),e()?pt(r,!0):n(a.annotationId);break;case A:M.preventDefault(),n(a.annotationId);break}p(M)},v=M=>{M.key===" "&&pt(r,!1),p(M)},k=H.data.datasetId,L=i(()=>nt({datasetId:k,annotationId:a.annotationId})),P=i(()=>t(L).annotation),N=i(()=>t(L).updateAnnotation),j="bbox-change-annotation-details";ra(()=>{$(j)});const F=M=>{if(t(_)){const Z={annotation_id:t(_).annotation_id,dataset_id:t(_).dataset_id,bounding_box:M},rt=bt(t(_)),St=async()=>{const J={annotation_id:t(_).annotation_id,dataset_id:t(_).dataset_id,bounding_box:rt};await t(N)(J)};(async()=>{try{await t(N)(Z),w({id:`bbox-change-${t(_).annotation_id}-${Date.now()}`,description:`Revert bounding box change for annotation ${t(_).annotation_id}`,execute:St,timestamp:new Date,groupId:j})}catch(J){ia.error("Failed to update annotations:"+J.message)}})()}};let _=i(()=>d().data),B=i(()=>{var M,Z;return Ma(((Z=(M=t(_))==null?void 0:M.sample)==null?void 0:Z.sample_id)||"")}),K=i(()=>t(_)?bt(t(_)):void 0);const{isEditingMode:Tt}=H.data.globalStorage,Ht=i(()=>t(r)?"grab":"auto"),Ut=i(()=>e()&&!t(r));var ot=oe();ht("keydown",gt,x),ht("keyup",gt,v);var st=g(ot),zt=g(st);te(zt,{get dataset(){return a.dataset},get annotationIndex(){return a.annotationIndex}}),f(st);var It=S(st,2);ha(It,{class:"mb-4 bg-border-hard"});var At=S(It,2),it=g(At),Ft=g(it);Lt(Ft,{className:"h-full",children:(M,Z)=>{Rt(M,{className:"h-full",children:(rt,St)=>{var dt=Q(),J=E(dt);{var qt=W=>{var O=ee(),X=g(O),lt=g(X),Kt=g(lt);{let yt=i(()=>o().has(a.annotationId));pa(Kt,{onSelect:()=>n(a.annotationId),get isSelected(){return t(yt)}})}f(lt);var $t=S(lt,2);Ra($t,{});var Wt=S($t,2);ya(Wt,{get width(){return t(_).sample.width},get height(){return t(_).sample.height},get cursor(){return t(Ht)},get boundingBox(){return t(K)},zoomableContent:(Vt,ct)=>{let Yt=()=>ct==null?void 0:ct().scale;var Mt=ae(),kt=E(Mt),ut=S(kt);let Pt;var Zt=g(ut);oa(Zt,()=>d().dataUpdatedAt,vt=>{{let Jt=i(()=>({x:0,y:0,width:t(_).sample.width,height:t(_).sample.height}));xa(vt,{get annotation(){return t(_)},showLabel:!0,get scale(){return Yt()},get imageWidth(){return t(_).sample.width},get isResizable(){return t(Ut)},onBoundingBoxChanged:F,get constraintBox(){return t(Jt)}})}}),f(ut),G(vt=>{et(kt,"href",t(B)),Pt=sa(ut,0,"",null,Pt,vt)},[()=>({invisible:l()})]),m(Vt,Mt)},$$slots:{zoomableContent:!0}}),f(X),f(O),m(W,O)},Gt=W=>{var O=ne(),X=g(O);jt(X,{size:"large",align:"center"}),f(O),m(W,O)};T(J,W=>{t(_)?W(qt):W(Gt,!1)})}m(rt,dt)},$$slots:{default:!0}})},$$slots:{default:!0}}),f(it);var wt=S(it,2),Ot=g(wt);Va(Ot,{get annotationId(){return a.annotationId}}),f(wt),f(At),f(ot),m(u,ot),z(),I()}var ie=C('<div class="flex h-full w-full space-x-4 px-4 pb-4" data-testid="annotation-details"><div class="h-full w-full space-y-6 rounded-[1vw] bg-card p-4"><!></div></div>');function Ce(u,a){U(a,!0);const e=()=>R(t($),"$sample",d),[d,o]=Y(),l=i(()=>a.data.annotationId),s=i(()=>a.data.dataset),I=i(()=>a.data.annotationIndex),{sampleId:n}=H.params,D=i(()=>ka({sampleId:n,datasetId:t(s).dataset_id})),$=i(()=>t(D).sample);var w=ie(),y=g(w),p=g(y);{var h=A=>{se(A,{get annotationId(){return t(l)},get annotationIndex(){return t(I)},get dataset(){return t(s)},get sample(){return e().data}})};T(p,A=>{e().data&&t(l)&&t(s)&&A(h)})}f(y),f(w),m(u,w),z(),o()}export{Ce as component,Pe as universal};
@@ -0,0 +1 @@
1
+ import"../chunks/CWj6FrbW.js";import{a as n,s as d}from"../chunks/-DXuGN29.js";import"../chunks/Cqo0Vpvt.js";import"../chunks/qIv1kPyv.js";import"../chunks/D_ynJAfY.js";import"../chunks/Bqz7dyEC.js";import"../chunks/D5w4xp5l.js";import"../chunks/DSxvnAMh.js";import"../chunks/69_IOA4Y.js";import"../chunks/DQ8aZ1o-.js";import"../chunks/DzX_yyqb.js";import{S as g}from"../chunks/BeWf8-vJ.js";function A(e,r){const t=()=>d(a,"$sampleSize",o),[o,i]=n(),{datasetId:s,sampleSize:a,selectedAnnotationFilterIds:m,globalStorage:{textEmbedding:p}}=r.data;g(e,{get sampleHeight(){return t().height},get sampleWidth(){return t().width},get textEmbedding(){return p},get dataset_id(){return s},get selectedAnnotationFilterIds(){return m}}),i()}export{A as component};
@@ -1 +1 @@
1
- {"version":"1759479212790"}
1
+ {"version":"1760445896529"}
@@ -5,35 +5,36 @@
5
5
  <link rel="icon" href="/favicon.png" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
7
 
8
- <link rel="modulepreload" href="/_app/immutable/entry/start.u7zsVvqp.js">
9
- <link rel="modulepreload" href="/_app/immutable/chunks/DEgUu98i.js">
10
- <link rel="modulepreload" href="/_app/immutable/chunks/CH6P3X75.js">
8
+ <link rel="modulepreload" href="/_app/immutable/entry/start.SNvc2nrm.js">
9
+ <link rel="modulepreload" href="/_app/immutable/chunks/DQ8aZ1o-.js">
10
+ <link rel="modulepreload" href="/_app/immutable/chunks/Frwd2CjB.js">
11
11
  <link rel="modulepreload" href="/_app/immutable/chunks/DIeogL5L.js">
12
12
  <link rel="modulepreload" href="/_app/immutable/chunks/CYgJF_JY.js">
13
- <link rel="modulepreload" href="/_app/immutable/entry/app.BVr6DYqP.js">
14
- <link rel="modulepreload" href="/_app/immutable/chunks/DQXoLcsF.js">
15
- <link rel="modulepreload" href="/_app/immutable/chunks/DA6bFLPR.js">
16
- <link rel="modulepreload" href="/_app/immutable/chunks/BfHVnyNT.js">
13
+ <link rel="modulepreload" href="/_app/immutable/entry/app.BPc0HQPq.js">
14
+ <link rel="modulepreload" href="/_app/immutable/chunks/C1FmrZbK.js">
15
+ <link rel="modulepreload" href="/_app/immutable/chunks/Dj4O-5se.js">
17
16
  <link rel="modulepreload" href="/_app/immutable/chunks/CWj6FrbW.js">
18
17
  <link rel="modulepreload" href="/_app/immutable/chunks/69_IOA4Y.js">
19
- <link rel="modulepreload" href="/_app/immutable/chunks/Cs1XmhiF.js">
20
- <link rel="modulepreload" href="/_app/immutable/chunks/DGTPl6Gk.js">
21
- <link rel="modulepreload" href="/_app/immutable/chunks/D4whDBUi.js">
22
- <link rel="modulepreload" href="/_app/immutable/chunks/RmD8FzRo.js">
18
+ <link rel="modulepreload" href="/_app/immutable/chunks/B7302SU7.js">
19
+ <link rel="modulepreload" href="/_app/immutable/chunks/H60ATh8g.js">
20
+ <link rel="modulepreload" href="/_app/immutable/chunks/Dug7Bq1S.js">
21
+ <link rel="modulepreload" href="/_app/immutable/chunks/CiaNZCBa.js">
22
+ <link rel="modulepreload" href="/_app/immutable/chunks/-DXuGN29.js">
23
+ <link rel="modulepreload" href="/_app/immutable/chunks/Dafy4oEQ.js">
23
24
  </head>
24
25
  <body data-sveltekit-preload-data="hover" class="flex h-screen w-screen flex-col dark:bg-black">
25
26
  <div style="display: contents">
26
27
  <script>
27
28
  {
28
- __sveltekit_1gqf9ui = {
29
+ __sveltekit_7kclq1 = {
29
30
  base: ""
30
31
  };
31
32
 
32
33
  const element = document.currentScript.parentElement;
33
34
 
34
35
  Promise.all([
35
- import("/_app/immutable/entry/start.u7zsVvqp.js"),
36
- import("/_app/immutable/entry/app.BVr6DYqP.js")
36
+ import("/_app/immutable/entry/start.SNvc2nrm.js"),
37
+ import("/_app/immutable/entry/app.BPc0HQPq.js")
37
38
  ]).then(([kit, app]) => {
38
39
  kit.start(app, element);
39
40
  });
@@ -5,11 +5,15 @@ from pathlib import Path
5
5
  from environs import Env
6
6
 
7
7
  import lightly_studio as ls
8
+ from lightly_studio import db_manager
8
9
 
9
10
  # Read environment variables
10
11
  env = Env()
11
12
  env.read_env()
12
13
 
14
+ # Cleanup an existing database
15
+ db_manager.connect(cleanup_existing=True)
16
+
13
17
  # Define the path to the dataset directory
14
18
  dataset_path = Path(env.path("DATASET_PATH", "/path/to/your/dataset"))
15
19
  dataset_path = dataset_path.parent if dataset_path.is_file() else dataset_path
@@ -1,6 +1,10 @@
1
1
  """Example of how to add samples in coco format to a dataset."""
2
2
 
3
3
  import lightly_studio as ls
4
+ from lightly_studio import db_manager
5
+
6
+ # Cleanup an existing database
7
+ db_manager.connect(cleanup_existing=True)
4
8
 
5
9
  # Create a DatasetLoader from a path
6
10
  dataset = ls.Dataset.create()
@@ -0,0 +1,24 @@
1
+ """Example of how to add samples in coco caption format to a dataset."""
2
+
3
+ import lightly_studio as ls
4
+ from lightly_studio import db_manager
5
+ from lightly_studio.resolvers import caption_resolver
6
+
7
+ # Cleanup an existing database
8
+ db_manager.connect(cleanup_existing=True)
9
+
10
+ # Create a DatasetLoader from a path
11
+ dataset = ls.Dataset.create()
12
+ dataset.add_samples_from_coco_caption(
13
+ annotations_json="/path/to/your/dataset/annotations.json",
14
+ images_path="/path/to/your/dataset",
15
+ )
16
+
17
+ # Display some details about the captions
18
+ captions_result = caption_resolver.get_all(session=dataset.session, dataset_id=dataset.dataset_id)
19
+ print(captions_result.total_count)
20
+
21
+ for caption in captions_result.captions[:10]:
22
+ print(caption)
23
+
24
+ ls.start_gui()
@@ -83,7 +83,7 @@ def add_bulk_metadata(session: Session, sample_ids: list[UUID]) -> None:
83
83
 
84
84
  # Bulk insert metadata
85
85
  start_time = time.time()
86
- metadata_resolver.bulk_set_metadata(session, sample_metadata)
86
+ metadata_resolver.bulk_update_metadata(session, sample_metadata)
87
87
  elapsed_time = time.time() - start_time
88
88
 
89
89
  print(f"✅ Added metadata to {len(sample_ids)} samples in {elapsed_time:.2f}s")
@@ -293,6 +293,9 @@ def demonstrate_dictionary_like_access(samples: list[Sample]) -> None:
293
293
  def main() -> None:
294
294
  """Main function to demonstrate metadata functionality."""
295
295
  try:
296
+ # Cleanup an existing database
297
+ db_manager.connect(cleanup_existing=True)
298
+
296
299
  # Load existing dataset
297
300
  dataset, samples = load_existing_dataset()
298
301
 
@@ -5,11 +5,15 @@ from pathlib import Path
5
5
  from environs import Env
6
6
 
7
7
  import lightly_studio as ls
8
+ from lightly_studio import db_manager
8
9
 
9
10
  # Read environment variables
10
11
  env = Env()
11
12
  env.read_env()
12
13
 
14
+ # Cleanup an existing database
15
+ db_manager.connect(cleanup_existing=True)
16
+
13
17
  # Define the path to the dataset directory
14
18
  dataset_path = Path(env.path("DATASET_PATH", "/path/to/your/dataset"))
15
19
  dataset_path = dataset_path.parent if dataset_path.is_file() else dataset_path
@@ -5,11 +5,15 @@ import math
5
5
  from environs import Env
6
6
 
7
7
  import lightly_studio as ls
8
+ from lightly_studio import db_manager
8
9
 
9
10
  # Read environment variables
10
11
  env = Env()
11
12
  env.read_env()
12
13
 
14
+ # Cleanup an existing database
15
+ db_manager.connect(cleanup_existing=True)
16
+
13
17
  # Create a Dataset instance
14
18
  dataset = ls.Dataset.create()
15
19
 
@@ -5,11 +5,15 @@ from pathlib import Path
5
5
  from environs import Env
6
6
 
7
7
  import lightly_studio as ls
8
+ from lightly_studio import db_manager
8
9
 
9
10
  # Read environment variables
10
11
  env = Env()
11
12
  env.read_env()
12
13
 
14
+ # Cleanup an existing database
15
+ db_manager.connect(cleanup_existing=True)
16
+
13
17
  # Define the path to the dataset directory
14
18
  dataset_path = Path(env.path("DATASET_PATH", "/path/to/your/dataset"))
15
19
 
@@ -1,5 +1,7 @@
1
1
  """Exports datasets from Lightly Studio into various formats."""
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  from pathlib import Path
4
6
  from typing import Iterable
5
7
 
@@ -8,6 +10,9 @@ from sqlmodel import Session
8
10
 
9
11
  from lightly_studio.core.sample import Sample
10
12
  from lightly_studio.export.lightly_studio_label_input import LightlyStudioObjectDetectionInput
13
+ from lightly_studio.type_definitions import PathLike
14
+
15
+ DEFAULT_EXPORT_FILENAME = "coco_export.json"
11
16
 
12
17
 
13
18
  class DatasetExport:
@@ -27,19 +32,22 @@ class DatasetExport:
27
32
  self.session = session
28
33
  self.samples = samples
29
34
 
30
- def to_coco_object_detections(self, output_json: Path) -> None:
35
+ def to_coco_object_detections(self, output_json: PathLike | None = None) -> None:
31
36
  """Exports object detection annotations to a COCO format JSON file.
32
37
 
33
38
  Args:
34
- output_json: The path to the output COCO JSON file.
39
+ output_json: The path to the output COCO JSON file. If not provided,
40
+ defaults to "coco_export.json" in the current working directory.
35
41
 
36
42
  Raises:
37
43
  ValueError: If the annotation task with the given name does not exist.
38
44
  """
45
+ if output_json is None:
46
+ output_json = DEFAULT_EXPORT_FILENAME
39
47
  to_coco_object_detections(
40
48
  session=self.session,
41
49
  samples=self.samples,
42
- output_json=output_json,
50
+ output_json=Path(output_json),
43
51
  )
44
52
 
45
53
 
@@ -64,4 +64,4 @@ def compute_typicality_metadata(
64
64
  for sample, typicality in zip(samples, typicality_values)
65
65
  ]
66
66
 
67
- metadata_resolver.bulk_set_metadata(session, metadata)
67
+ metadata_resolver.bulk_update_metadata(session, metadata)
@@ -0,0 +1,73 @@
1
+ """This module defines the caption model."""
2
+
3
+ from datetime import datetime, timezone
4
+ from typing import TYPE_CHECKING, List, Optional
5
+ from uuid import UUID, uuid4
6
+
7
+ from pydantic import BaseModel, ConfigDict
8
+ from pydantic import Field as PydanticField
9
+ from sqlalchemy.orm import Mapped
10
+ from sqlmodel import Field, Relationship, SQLModel
11
+
12
+ if TYPE_CHECKING:
13
+ from lightly_studio.models.sample import SampleTable
14
+
15
+
16
+ class CaptionTable(SQLModel, table=True):
17
+ """Class for caption model."""
18
+
19
+ __tablename__ = "caption"
20
+
21
+ created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc), index=True)
22
+
23
+ caption_id: UUID = Field(default_factory=uuid4, primary_key=True)
24
+ dataset_id: UUID = Field(foreign_key="datasets.dataset_id")
25
+ sample_id: UUID = Field(foreign_key="samples.sample_id")
26
+
27
+ sample: Mapped[Optional["SampleTable"]] = Relationship(
28
+ sa_relationship_kwargs={"lazy": "select"},
29
+ )
30
+
31
+ text: str
32
+
33
+
34
+ class CaptionCreate(SQLModel):
35
+ """Input model for creating captions."""
36
+
37
+ dataset_id: UUID
38
+ sample_id: UUID
39
+ text: str
40
+
41
+
42
+ class CaptionSampleView(SQLModel):
43
+ """Sample class for caption view."""
44
+
45
+ file_path_abs: str
46
+ file_name: str
47
+ dataset_id: UUID
48
+ sample_id: UUID
49
+
50
+
51
+ class CaptionView(SQLModel):
52
+ """Response model for caption."""
53
+
54
+ sample_id: UUID
55
+ dataset_id: UUID
56
+ caption_id: UUID
57
+ text: str
58
+
59
+
60
+ class CaptionDetailsView(CaptionView):
61
+ """Response model for caption."""
62
+
63
+ sample: CaptionSampleView
64
+
65
+
66
+ class CaptionsListView(BaseModel):
67
+ """Response model for counted captions."""
68
+
69
+ model_config = ConfigDict(populate_by_name=True)
70
+
71
+ captions: List[CaptionDetailsView] = PydanticField(..., alias="data")
72
+ total_count: int
73
+ next_cursor: Optional[int] = PydanticField(..., alias="nextCursor")
@@ -19,8 +19,7 @@ from lightly_studio.resolvers.samples_filter import SampleFilter
19
19
  class DatasetBase(SQLModel):
20
20
  """Base class for the Dataset model."""
21
21
 
22
- name: str
23
- directory: str
22
+ name: str = Field(unique=True, index=True)
24
23
 
25
24
 
26
25
  class DatasetCreate(DatasetBase):
@@ -188,7 +188,7 @@ class SampleMetadataTable(MetadataBase, table=True):
188
188
  """This class defines the SampleMetadataTable model."""
189
189
 
190
190
  __tablename__ = "metadata"
191
- sample_id: UUID = Field(foreign_key="samples.sample_id")
191
+ sample_id: UUID = Field(foreign_key="samples.sample_id", unique=True)
192
192
 
193
193
  sample: SampleTable = Relationship(back_populates="metadata_dict")
194
194
 
@@ -170,8 +170,8 @@ class SampleView(SQLModel):
170
170
  file_path_abs: str
171
171
  sample_id: UUID
172
172
  dataset_id: UUID
173
- annotations: List["AnnotationView"] = Field([])
174
- tags: List[SampleViewTag] = Field([])
173
+ annotations: List["AnnotationView"]
174
+ tags: List[SampleViewTag]
175
175
  metadata_dict: Optional["SampleMetadataView"] = None
176
176
  width: int
177
177
  height: int
@@ -0,0 +1,80 @@
1
+ """Resolvers for caption."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Sequence
6
+ from uuid import UUID
7
+
8
+ from pydantic import BaseModel
9
+ from sqlmodel import Session, col, func, select
10
+
11
+ from lightly_studio.api.routes.api.validators import Paginated
12
+ from lightly_studio.models.caption import CaptionCreate, CaptionTable
13
+
14
+
15
+ class GetAllCaptionsResult(BaseModel):
16
+ """Result wrapper for caption listings."""
17
+
18
+ captions: Sequence[CaptionTable]
19
+ total_count: int
20
+ next_cursor: int | None = None
21
+
22
+
23
+ def create_many(session: Session, captions: Sequence[CaptionCreate]) -> list[CaptionTable]:
24
+ """Create many captions in bulk.
25
+
26
+ Args:
27
+ session: Database session
28
+ captions: The captions to create
29
+
30
+ Returns:
31
+ The created captions
32
+ """
33
+ if not captions:
34
+ return []
35
+
36
+ db_captions = [CaptionTable.model_validate(caption) for caption in captions]
37
+ session.bulk_save_objects(db_captions)
38
+ session.commit()
39
+ return db_captions
40
+
41
+
42
+ def get_all(
43
+ session: Session,
44
+ dataset_id: UUID,
45
+ pagination: Paginated | None = None,
46
+ ) -> GetAllCaptionsResult:
47
+ """Get all captions from the database.
48
+
49
+ Args:
50
+ session: Database session
51
+ dataset_id: dataset_id parameter to filter the query
52
+ pagination: Optional pagination parameters
53
+
54
+ Returns:
55
+ List of captions matching the filters, total number of captions, next cursor (pagination)
56
+ """
57
+ query = select(CaptionTable).order_by(
58
+ col(CaptionTable.created_at).asc(),
59
+ col(CaptionTable.caption_id).asc(),
60
+ )
61
+ count_query = select(func.count()).select_from(CaptionTable)
62
+
63
+ query = query.where(CaptionTable.dataset_id == dataset_id)
64
+ count_query = count_query.where(CaptionTable.dataset_id == dataset_id)
65
+
66
+ if pagination is not None:
67
+ query = query.offset(pagination.offset).limit(pagination.limit)
68
+
69
+ captions = session.exec(query).all()
70
+ total_count = session.exec(count_query).one()
71
+
72
+ next_cursor: int | None = None
73
+ if pagination and pagination.offset + pagination.limit < total_count:
74
+ next_cursor = pagination.offset + pagination.limit
75
+
76
+ return GetAllCaptionsResult(
77
+ captions=captions,
78
+ total_count=total_count,
79
+ next_cursor=next_cursor,
80
+ )
@@ -41,6 +41,9 @@ class ExportFilter(BaseModel):
41
41
 
42
42
  def create(session: Session, dataset: DatasetCreate) -> DatasetTable:
43
43
  """Create a new dataset in the database."""
44
+ existing = get_by_name(session=session, name=dataset.name)
45
+ if existing:
46
+ raise ValueError(f"Dataset with name '{dataset.name}' already exists.")
44
47
  db_dataset = DatasetTable.model_validate(dataset)
45
48
  session.add(db_dataset)
46
49
  session.commit()
@@ -69,12 +72,7 @@ def get_by_id(session: Session, dataset_id: UUID) -> DatasetTable | None:
69
72
 
70
73
  def get_by_name(session: Session, name: str) -> DatasetTable | None:
71
74
  """Retrieve a single dataset by name."""
72
- datasets = session.exec(select(DatasetTable).where(DatasetTable.name == name)).all()
73
- if len(datasets) == 0:
74
- return None
75
- if len(datasets) > 1:
76
- raise ValueError(f"Cannot retrieve a dataset, found multiple with name '{name}'.")
77
- return datasets[0]
75
+ return session.exec(select(DatasetTable).where(DatasetTable.name == name)).one_or_none()
78
76
 
79
77
 
80
78
  def update(session: Session, dataset_id: UUID, dataset_data: DatasetCreate) -> DatasetTable:
@@ -84,7 +82,6 @@ def update(session: Session, dataset_id: UUID, dataset_data: DatasetCreate) -> D
84
82
  raise ValueError(f"Dataset ID was not found '{dataset_id}'.")
85
83
 
86
84
  dataset.name = dataset_data.name
87
- dataset.directory = dataset_data.directory
88
85
  dataset.updated_at = datetime.now(timezone.utc)
89
86
 
90
87
  session.commit()
@@ -1,14 +1,14 @@
1
1
  """Metadata resolver module."""
2
2
 
3
3
  from lightly_studio.resolvers.metadata_resolver.sample import (
4
- bulk_set_metadata,
4
+ bulk_update_metadata,
5
5
  get_by_sample_id,
6
6
  get_value_for_sample,
7
7
  set_value_for_sample,
8
8
  )
9
9
 
10
10
  __all__ = [
11
- "bulk_set_metadata",
11
+ "bulk_update_metadata",
12
12
  "get_by_sample_id",
13
13
  "get_value_for_sample",
14
14
  "set_value_for_sample",