lightly-studio 0.3.1__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.
- lightly_studio/__init__.py +11 -0
- lightly_studio/api/__init__.py +0 -0
- lightly_studio/api/app.py +110 -0
- lightly_studio/api/cache.py +77 -0
- lightly_studio/api/db.py +133 -0
- lightly_studio/api/db_tables.py +32 -0
- lightly_studio/api/features.py +7 -0
- lightly_studio/api/routes/api/annotation.py +233 -0
- lightly_studio/api/routes/api/annotation_label.py +90 -0
- lightly_studio/api/routes/api/annotation_task.py +38 -0
- lightly_studio/api/routes/api/classifier.py +387 -0
- lightly_studio/api/routes/api/dataset.py +182 -0
- lightly_studio/api/routes/api/dataset_tag.py +257 -0
- lightly_studio/api/routes/api/exceptions.py +96 -0
- lightly_studio/api/routes/api/features.py +17 -0
- lightly_studio/api/routes/api/metadata.py +37 -0
- lightly_studio/api/routes/api/metrics.py +80 -0
- lightly_studio/api/routes/api/sample.py +196 -0
- lightly_studio/api/routes/api/settings.py +45 -0
- lightly_studio/api/routes/api/status.py +19 -0
- lightly_studio/api/routes/api/text_embedding.py +48 -0
- lightly_studio/api/routes/api/validators.py +17 -0
- lightly_studio/api/routes/healthz.py +13 -0
- lightly_studio/api/routes/images.py +104 -0
- lightly_studio/api/routes/webapp.py +51 -0
- lightly_studio/api/server.py +82 -0
- lightly_studio/core/__init__.py +0 -0
- lightly_studio/core/dataset.py +523 -0
- lightly_studio/core/sample.py +77 -0
- lightly_studio/core/start_gui.py +15 -0
- lightly_studio/dataset/__init__.py +0 -0
- lightly_studio/dataset/edge_embedding_generator.py +144 -0
- lightly_studio/dataset/embedding_generator.py +91 -0
- lightly_studio/dataset/embedding_manager.py +163 -0
- lightly_studio/dataset/env.py +16 -0
- lightly_studio/dataset/file_utils.py +35 -0
- lightly_studio/dataset/loader.py +622 -0
- lightly_studio/dataset/mobileclip_embedding_generator.py +144 -0
- lightly_studio/dist_lightly_studio_view_app/_app/env.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/0.DenzbfeK.css +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/LightlyLogo.BNjCIww-.png +0 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/OpenSans- +0 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/OpenSans-Bold.DGvYQtcs.ttf +0 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/OpenSans-Italic-VariableFont_wdth_wght.B4AZ-wl6.ttf +0 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/OpenSans-Regular.DxJTClRG.ttf +0 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/OpenSans-SemiBold.D3TTYgdB.ttf +0 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/OpenSans-VariableFont_wdth_wght.BZBpG5Iz.ttf +0 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/SelectableSvgGroup.OwPEPQZu.css +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/SelectableSvgGroup.b653GmVf.css +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/_layout.T-zjSUd3.css +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/useFeatureFlags.CV-KWLNP.css +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/69_IOA4Y.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/B2FVR0s0.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/B90CZVMX.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/B9zumHo5.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/BJXwVxaE.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Bsi3UGy5.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Bu7uvVrG.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Bx1xMsFy.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/BylOuP6i.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/C8I8rFJQ.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CDnpyLsT.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CWj6FrbW.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CYgJF_JY.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CcaPhhk3.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CvOmgdoc.js +93 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CxtLVaYz.js +3 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/D5-A_Ffd.js +4 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/D6RI2Zrd.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/D6su9Aln.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/D98V7j6A.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DIRAtgl0.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DIeogL5L.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DOlTMNyt.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DjUWrjOv.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DjfY96ND.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/H7C68rOM.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/O-EABkf9.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/XO7A28GO.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/hQVEETDE.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/l7KrR96u.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/nAHhluT7.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/r64xT6ao.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/vC4nQVEB.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/x9G_hzyY.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/entry/app.CjnvpsmS.js +2 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/entry/start.0o1H7wM9.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/0.XRq_TUwu.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/1.B4rNYwVp.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/10.DfBwOEhN.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/11.CWG1ehzT.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/12.CwF2_8mP.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/2.CS4muRY-.js +6 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/3.CWHpKonm.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/4.OUWOLQeV.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/5.Dm6t9F5W.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/6.Bw5ck4gK.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/7.CF0EDTR6.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/8.Cw30LEcV.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/9.CPu3CiBc.js +1 -0
- lightly_studio/dist_lightly_studio_view_app/_app/version.json +1 -0
- lightly_studio/dist_lightly_studio_view_app/apple-touch-icon-precomposed.png +0 -0
- lightly_studio/dist_lightly_studio_view_app/apple-touch-icon.png +0 -0
- lightly_studio/dist_lightly_studio_view_app/favicon.png +0 -0
- lightly_studio/dist_lightly_studio_view_app/index.html +44 -0
- lightly_studio/examples/example.py +23 -0
- lightly_studio/examples/example_metadata.py +338 -0
- lightly_studio/examples/example_selection.py +39 -0
- lightly_studio/examples/example_split_work.py +67 -0
- lightly_studio/examples/example_v2.py +21 -0
- lightly_studio/export_schema.py +18 -0
- lightly_studio/few_shot_classifier/__init__.py +0 -0
- lightly_studio/few_shot_classifier/classifier.py +80 -0
- lightly_studio/few_shot_classifier/classifier_manager.py +663 -0
- lightly_studio/few_shot_classifier/random_forest_classifier.py +489 -0
- lightly_studio/metadata/complex_metadata.py +47 -0
- lightly_studio/metadata/gps_coordinate.py +41 -0
- lightly_studio/metadata/metadata_protocol.py +17 -0
- lightly_studio/metrics/__init__.py +0 -0
- lightly_studio/metrics/detection/__init__.py +0 -0
- lightly_studio/metrics/detection/map.py +268 -0
- lightly_studio/models/__init__.py +1 -0
- lightly_studio/models/annotation/__init__.py +0 -0
- lightly_studio/models/annotation/annotation_base.py +171 -0
- lightly_studio/models/annotation/instance_segmentation.py +56 -0
- lightly_studio/models/annotation/links.py +17 -0
- lightly_studio/models/annotation/object_detection.py +47 -0
- lightly_studio/models/annotation/semantic_segmentation.py +44 -0
- lightly_studio/models/annotation_label.py +47 -0
- lightly_studio/models/annotation_task.py +28 -0
- lightly_studio/models/classifier.py +20 -0
- lightly_studio/models/dataset.py +84 -0
- lightly_studio/models/embedding_model.py +30 -0
- lightly_studio/models/metadata.py +208 -0
- lightly_studio/models/sample.py +180 -0
- lightly_studio/models/sample_embedding.py +37 -0
- lightly_studio/models/settings.py +60 -0
- lightly_studio/models/tag.py +96 -0
- lightly_studio/py.typed +0 -0
- lightly_studio/resolvers/__init__.py +7 -0
- lightly_studio/resolvers/annotation_label_resolver/__init__.py +21 -0
- lightly_studio/resolvers/annotation_label_resolver/create.py +27 -0
- lightly_studio/resolvers/annotation_label_resolver/delete.py +28 -0
- lightly_studio/resolvers/annotation_label_resolver/get_all.py +22 -0
- lightly_studio/resolvers/annotation_label_resolver/get_by_id.py +24 -0
- lightly_studio/resolvers/annotation_label_resolver/get_by_ids.py +25 -0
- lightly_studio/resolvers/annotation_label_resolver/get_by_label_name.py +24 -0
- lightly_studio/resolvers/annotation_label_resolver/names_by_ids.py +25 -0
- lightly_studio/resolvers/annotation_label_resolver/update.py +38 -0
- lightly_studio/resolvers/annotation_resolver/__init__.py +33 -0
- lightly_studio/resolvers/annotation_resolver/count_annotations_by_dataset.py +120 -0
- lightly_studio/resolvers/annotation_resolver/create.py +19 -0
- lightly_studio/resolvers/annotation_resolver/create_many.py +96 -0
- lightly_studio/resolvers/annotation_resolver/delete_annotation.py +45 -0
- lightly_studio/resolvers/annotation_resolver/delete_annotations.py +56 -0
- lightly_studio/resolvers/annotation_resolver/get_all.py +74 -0
- lightly_studio/resolvers/annotation_resolver/get_by_id.py +18 -0
- lightly_studio/resolvers/annotation_resolver/update_annotation_label.py +144 -0
- lightly_studio/resolvers/annotation_resolver/update_bounding_box.py +68 -0
- lightly_studio/resolvers/annotation_task_resolver.py +31 -0
- lightly_studio/resolvers/annotations/__init__.py +1 -0
- lightly_studio/resolvers/annotations/annotations_filter.py +89 -0
- lightly_studio/resolvers/dataset_resolver.py +278 -0
- lightly_studio/resolvers/embedding_model_resolver.py +100 -0
- lightly_studio/resolvers/metadata_resolver/__init__.py +15 -0
- lightly_studio/resolvers/metadata_resolver/metadata_filter.py +163 -0
- lightly_studio/resolvers/metadata_resolver/sample/__init__.py +21 -0
- lightly_studio/resolvers/metadata_resolver/sample/bulk_set_metadata.py +48 -0
- lightly_studio/resolvers/metadata_resolver/sample/get_by_sample_id.py +24 -0
- lightly_studio/resolvers/metadata_resolver/sample/get_metadata_info.py +104 -0
- lightly_studio/resolvers/metadata_resolver/sample/get_value_for_sample.py +27 -0
- lightly_studio/resolvers/metadata_resolver/sample/set_value_for_sample.py +53 -0
- lightly_studio/resolvers/sample_embedding_resolver.py +86 -0
- lightly_studio/resolvers/sample_resolver.py +249 -0
- lightly_studio/resolvers/samples_filter.py +81 -0
- lightly_studio/resolvers/settings_resolver.py +58 -0
- lightly_studio/resolvers/tag_resolver.py +276 -0
- lightly_studio/selection/README.md +6 -0
- lightly_studio/selection/mundig.py +105 -0
- lightly_studio/selection/select.py +96 -0
- lightly_studio/selection/select_via_db.py +93 -0
- lightly_studio/selection/selection_config.py +31 -0
- lightly_studio/services/annotations_service/__init__.py +21 -0
- lightly_studio/services/annotations_service/get_annotation_by_id.py +31 -0
- lightly_studio/services/annotations_service/update_annotation.py +65 -0
- lightly_studio/services/annotations_service/update_annotation_label.py +48 -0
- lightly_studio/services/annotations_service/update_annotations.py +29 -0
- lightly_studio/setup_logging.py +19 -0
- lightly_studio/type_definitions.py +19 -0
- lightly_studio/vendor/ACKNOWLEDGEMENTS +422 -0
- lightly_studio/vendor/LICENSE +31 -0
- lightly_studio/vendor/LICENSE_weights_data +50 -0
- lightly_studio/vendor/README.md +5 -0
- lightly_studio/vendor/__init__.py +1 -0
- lightly_studio/vendor/mobileclip/__init__.py +96 -0
- lightly_studio/vendor/mobileclip/clip.py +77 -0
- lightly_studio/vendor/mobileclip/configs/mobileclip_b.json +18 -0
- lightly_studio/vendor/mobileclip/configs/mobileclip_s0.json +18 -0
- lightly_studio/vendor/mobileclip/configs/mobileclip_s1.json +18 -0
- lightly_studio/vendor/mobileclip/configs/mobileclip_s2.json +18 -0
- lightly_studio/vendor/mobileclip/image_encoder.py +67 -0
- lightly_studio/vendor/mobileclip/logger.py +154 -0
- lightly_studio/vendor/mobileclip/models/__init__.py +10 -0
- lightly_studio/vendor/mobileclip/models/mci.py +933 -0
- lightly_studio/vendor/mobileclip/models/vit.py +433 -0
- lightly_studio/vendor/mobileclip/modules/__init__.py +4 -0
- lightly_studio/vendor/mobileclip/modules/common/__init__.py +4 -0
- lightly_studio/vendor/mobileclip/modules/common/mobileone.py +341 -0
- lightly_studio/vendor/mobileclip/modules/common/transformer.py +451 -0
- lightly_studio/vendor/mobileclip/modules/image/__init__.py +4 -0
- lightly_studio/vendor/mobileclip/modules/image/image_projection.py +113 -0
- lightly_studio/vendor/mobileclip/modules/image/replknet.py +188 -0
- lightly_studio/vendor/mobileclip/modules/text/__init__.py +4 -0
- lightly_studio/vendor/mobileclip/modules/text/repmixer.py +281 -0
- lightly_studio/vendor/mobileclip/modules/text/tokenizer.py +38 -0
- lightly_studio/vendor/mobileclip/text_encoder.py +245 -0
- lightly_studio-0.3.1.dist-info/METADATA +520 -0
- lightly_studio-0.3.1.dist-info/RECORD +219 -0
- lightly_studio-0.3.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var Mt=d=>{throw TypeError(d)};var Ot=(d,t,a)=>t.has(d)||Mt("Cannot "+a);var Ae=(d,t,a)=>(Ot(d,t,"read from private field"),a?a.call(d):t.get(d)),rt=(d,t,a)=>t.has(d)?Mt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(d):t.set(d,a);var Nt=(d,t,a)=>(Ot(d,t,"access private method"),a);import{u as it,a as Zt}from"../chunks/vC4nQVEB.js";import{c as lt,a as ea}from"../chunks/BJXwVxaE.js";import{r as Ge,i as ta,a as aa,b as sa}from"../chunks/H7C68rOM.js";import{r as ra}from"../chunks/B90CZVMX.js";import{ad as xt,g as e,L as M,p as Oe,f as C,n as dt,a as Ne,s as r,c as i,ax as X,d as p,r as o,t as de,V as Be,ay as na,am as oa,z as Vt,l as Ze,u as Dt,w as ia}from"../chunks/l7KrR96u.js";import"../chunks/CWj6FrbW.js";import{c as U,a as s,t as $,d as fe}from"../chunks/Bu7uvVrG.js";import{a as L,i as se,s as Ke}from"../chunks/XO7A28GO.js";import{s as Ye,u as Et}from"../chunks/DIRAtgl0.js";import{s as ct,r as at,c as ve,a as Re,p as et,b as Lt}from"../chunks/D98V7j6A.js";import{p as He}from"../chunks/Bsi3UGy5.js";import{R as bt,I as ut,T as je,c as ot,F as ht,U as _t,e as Je,i as nt,l as la,V as yt,W as wt,X as Ct,Y as St,Z as Pt,_ as kt,$ as da,a0 as zt,b as Rt,a1 as ca,a2 as jt,a3 as qt,f as ua,a4 as At,a5 as va,a6 as fa,a7 as Ht,a8 as ma,m as mt,k as _a,s as ga,o as pa,a9 as ha,aa as $a,ab as xa,ac as ba,ad as ya,ae as Gt,af as wa,ag as Ca,ah as Sa,g as Pa,ai as ka,d as Ta,u as Ia,K as Ea,aj as Aa,ak as Fa,al as Ma}from"../chunks/CvOmgdoc.js";import{g as Ue,o as Kt,c as Wt}from"../chunks/CxtLVaYz.js";import{S as vt,f as Qe,a as Oa}from"../chunks/D5-A_Ffd.js";import{C as Na}from"../chunks/CDnpyLsT.js";import{s as K}from"../chunks/D6RI2Zrd.js";import{u as Jt}from"../chunks/D6su9Aln.js";import{u as Da}from"../chunks/x9G_hzyY.js";import"../chunks/69_IOA4Y.js";import{u as La,c as za,a as Ra}from"../chunks/Bx1xMsFy.js";import{u as ja,a as Ba}from"../chunks/hQVEETDE.js";import{i as Qt}from"../chunks/O-EABkf9.js";import{T as Va}from"../chunks/r64xT6ao.js";import{p as Tt}from"../chunks/C8I8rFJQ.js";var qa=["forEach","isDisjointFrom","isSubsetOf","isSupersetOf"],Ha=["difference","intersection","symmetricDifference","union"],Bt=!1,tt,Ve,We,gt,Ut;const pt=class pt extends Set{constructor(a){super();rt(this,gt);rt(this,tt,new Map);rt(this,Ve,xt(0));rt(this,We,xt(0));if(a){for(var l of a)super.add(l);Ae(this,We).v=super.size}Bt||Nt(this,gt,Ut).call(this)}has(a){var l=super.has(a),n=Ae(this,tt),u=n.get(a);if(u===void 0){if(!l)return e(Ae(this,Ve)),!1;u=xt(!0),n.set(a,u)}return e(u),l}add(a){return super.has(a)||(super.add(a),M(Ae(this,We),super.size),bt(Ae(this,Ve))),this}delete(a){var l=super.delete(a),n=Ae(this,tt),u=n.get(a);return u!==void 0&&(n.delete(a),M(u,!1)),l&&(M(Ae(this,We),super.size),bt(Ae(this,Ve))),l}clear(){if(super.size!==0){super.clear();var a=Ae(this,tt);for(var l of a.values())M(l,!1);a.clear(),M(Ae(this,We),0),bt(Ae(this,Ve))}}keys(){return this.values()}values(){return e(Ae(this,Ve)),super.values()}entries(){return e(Ae(this,Ve)),super.entries()}[Symbol.iterator](){return this.keys()}get size(){return e(Ae(this,We))}};tt=new WeakMap,Ve=new WeakMap,We=new WeakMap,gt=new WeakSet,Ut=function(){Bt=!0;var a=pt.prototype,l=Set.prototype;for(const n of qa)a[n]=function(...u){return e(Ae(this,Ve)),l[n].apply(this,u)};for(const n of Ha)a[n]=function(...u){e(Ae(this,Ve));var v=l[n].apply(this,u);return new pt(v)}};let It=pt;function Yt(d,t){Oe(t,!0);let a=at(t,["$$slots","$$events","$$legacy"]);ut(d,ct({name:"image"},()=>a,{iconNode:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}],["circle",{cx:"9",cy:"9",r:"2"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"}]],children:(n,u)=>{var v=U(),y=C(v);Ye(y,()=>t.children??dt),s(n,v)},$$slots:{default:!0}})),Ne()}var Ga=$("<!> Samples",1),Ka=$("<!> Annotations",1),Wa=$('<div class="mb-5 mt-2 text-lg font-semibold">Collections</div> <!> <div class="flex space-x-2"><!> <!></div>',1);function Ja(d,t){Oe(t,!0);const a="is-active inline-flex rounded-md bg-muted",l=()=>{Ue(Ge.toSamples(t.datasetId))},n=()=>{Ue(Ge.toAnnotations(t.datasetId))};var u=Wa(),v=r(C(u),2);vt(v,{class:"mb-4 bg-border-hard"});var y=r(v,2),W=i(y);const E=p(()=>ot("flex-1","px-2",t.gridType=="samples"&&a));je(W,{variant:"ghost",get class(){return e(E)},onclick:l,"data-testid":"collections-nav-samples-button","data-sveltekit-noscroll":!0,children:(F,S)=>{var k=Ga(),b=C(k);Yt(b,{class:"size-4"}),X(),s(F,k)},$$slots:{default:!0}});var A=r(W,2);const P=p(()=>ot("flex-1","px-2",t.gridType=="annotations"&&a));je(A,{get class(){return e(P)},variant:"ghost",onclick:n,"data-testid":"collections-nav-annotations-button","data-sveltekit-noscroll":!0,children:(F,S)=>{var k=Ka(),b=C(k);Na(b,{class:"size-4"}),X(),s(F,k)},$$slots:{default:!0}}),o(y),s(d,u),Ne()}var Qa=$('<div class="space-y-1"><h2 class="text-md capitalize"> </h2> <div class="flex justify-between text-sm text-diffuse-foreground"><span> </span> <span> </span></div> <div class="relative p-2"><!></div></div>'),Ua=$('<div class="space-y-4"><div class="space-y-1"><h2 class="text-md">Width</h2> <div class="flex justify-between text-sm text-diffuse-foreground"><span> </span> <span> </span></div> <div class="relative p-2"><!></div></div> <div class="space-y-1"><h2 class="text-md">Height</h2> <div class="flex justify-between text-sm text-diffuse-foreground"><span> </span> <span> </span></div> <div class="relative p-2"><!></div></div> <!></div>');function Ya(d,t){Oe(t,!0);const[a,l]=Ke(),n=()=>L(A,"$values",a),u=()=>L(b,"$metadataValues",a),v=()=>L(k,"$metadataBounds",a),y=()=>L(E,"$bounds",a),W=He.params.dataset_id,{dimensionsBounds:E,dimensionsValues:A,updateDimensionsValues:P}=Jt(),F=g=>{P({min_width:g[0],max_width:g[1],min_height:n().min_height,max_height:n().max_height})},S=g=>{P({min_width:n().min_width,max_width:n().max_width,min_height:g[0],max_height:g[1]})},{metadataBounds:k,metadataValues:b,updateMetadataValues:f}=Da(W),x=g=>N=>{const V={...u()};V[g]={min:N[0],max:N[1]},f(V)},j=p(()=>Object.keys(v()).filter(g=>{const N=v()[g];return N&&typeof N.min=="number"&&typeof N.max=="number"})),Y=(g,N)=>{const V=v()[N];return V&&Number.isInteger(V.min)&&Number.isInteger(V.max)?Qe(g):Oa(g)};ht(d,{title:"Metadata FIlters",children:(g,N)=>{var V=Ua(),pe=i(V),we=r(i(pe),2),T=i(we),Ce=i(T);o(T);var Pe=r(T,2),De=i(Pe);o(Pe),o(we);var me=r(we,2),te=i(me);const Se=p(()=>[n().min_width,n().max_width]);_t(te,{type:"multiple",class:"filter-width",get min(){return y().min_width},get max(){return y().max_width},get value(){return e(Se)},onValueCommit:F}),o(me),o(pe);var J=r(pe,2),re=r(i(J),2),he=i(re),ke=i(he);o(he);var $e=r(he,2),Te=i($e);o($e),o(re);var Fe=r(re,2),m=i(Fe);const c=p(()=>[n().min_height,n().max_height]);_t(m,{type:"multiple",class:"filter-height",get min(){return y().min_height},get max(){return y().max_height},get value(){return e(c)},onValueCommit:S}),o(Fe),o(J);var _=r(J,2);{var ce=I=>{var Q=U(),B=C(Q);Je(B,17,()=>e(j),nt,(xe,ne)=>{var q=Qa();const z=p(()=>v()[e(ne)]),oe=p(()=>u()[e(ne)]),ie=p(()=>Number.isInteger(e(z).min)&&Number.isInteger(e(z).max));var Z=i(q),Me=i(Z,!0);o(Z);var h=r(Z,2),R=i(h),w=i(R,!0);o(R);var H=r(R,2),O=i(H,!0);o(H),o(h);var D=r(h,2),ue=i(D);const G=p(()=>e(ie)?1:.01),le=p(()=>[e(oe).min,e(oe).max]),Ie=p(()=>x(e(ne)));_t(ue,{type:"multiple",get class(){return`filter-${e(ne)??""}`},get min(){return e(z).min},get max(){return e(z).max},get step(){return e(G)},get value(){return e(le)},get onValueCommit(){return e(Ie)}}),o(D),o(q),de((_e,ge,be)=>{K(Me,_e),K(w,ge),K(O,be)},[()=>e(ne).replace(/_/g," "),()=>Y(e(oe).min,e(ne)),()=>Y(e(oe).max,e(ne))]),s(xe,q)}),s(I,Q)};se(_,I=>{e(j).length>0&&I(ce)})}o(V),de((I,Q,B,xe)=>{K(Ce,`${I??""}px`),K(De,`${Q??""}px`),K(ke,`${B??""}px`),K(Te,`${xe??""}px`)},[()=>Qe(n().min_width),()=>Qe(n().max_width),()=>Qe(n().min_height),()=>Qe(n().max_height)]),s(g,V)},$$slots:{default:!0}}),Ne(),l()}function Xa(d,t){Oe(t,!0);let a=at(t,["$$slots","$$events","$$legacy"]);ut(d,ct({name:"eraser"},()=>a,{iconNode:[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"}],["path",{d:"M22 21H7"}],["path",{d:"m5 11 9 9"}]],children:(n,u)=>{var v=U(),y=C(v);Ye(y,()=>t.children??dt),s(n,v)},$$slots:{default:!0}})),Ne()}function Za(d,t){Oe(t,!0);let a=at(t,["$$slots","$$events","$$legacy"]);ut(d,ct({name:"grid-3x3"},()=>a,{iconNode:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M3 9h18"}],["path",{d:"M3 15h18"}],["path",{d:"M9 3v18"}],["path",{d:"M15 3v18"}]],children:(n,u)=>{var v=U(),y=C(v);Ye(y,()=>t.children??dt),s(n,v)},$$slots:{default:!0}})),Ne()}function es(d,t){Oe(t,!0);let a=at(t,["$$slots","$$events","$$legacy"]);ut(d,ct({name:"plus"},()=>a,{iconNode:[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]],children:(n,u)=>{var v=U(),y=C(v);Ye(y,()=>t.children??dt),s(n,v)},$$slots:{default:!0}})),Ne()}function ts(d,t){Oe(t,!0);let a=at(t,["$$slots","$$events","$$legacy"]);ut(d,ct({name:"sliders-horizontal"},()=>a,{iconNode:[["line",{x1:"21",x2:"14",y1:"4",y2:"4"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22"}]],children:(n,u)=>{var v=U(),y=C(v);Ye(y,()=>t.children??dt),s(n,v)},$$slots:{default:!0}})),Ne()}const as=async d=>{const t={data:{},error:void 0};try{const a=await lt.POST("/api/metrics/compute/detection/map",{body:d});if(a.error)throw new Error(JSON.stringify(a.error,null,2));if(!a.data)throw new Error("No data returned from metrics calculation");t.data=a.data}catch(a){t.error="Error computing metrics: "+String(a)}return t};var ss=$("<!> <!>",1),rs=$("<!> <!>",1),ns=$("<!> <!>",1),os=$("<!> <!>",1),is=$('<div class="rounded-md bg-destructive/15 p-3 text-sm text-destructive"> </div>'),ls=$('<span class="mr-2 animate-spin">⟳</span>'),ds=$("<!> Compute",1),cs=$('<div class="space-y-6"><!> <!> <!> <!> <div class="flex space-x-2"><!> <!></div></div>'),us=$('<div class="flex justify-between"><span class="truncate"> </span> <span class="font-medium"> </span></div>'),vs=$('<div class="rounded-lg bg-muted p-4"><h4 class="text-md mb-2 font-medium">mAP by Class</h4> <div class="max-h-60 space-y-1 overflow-y-auto text-sm"></div></div>'),fs=$('<div class="space-y-4"><div class="rounded-lg bg-muted p-4"><h4 class="text-md mb-2 font-medium">mAP Results</h4> <div class="space-y-2 text-sm"><div class="flex justify-between"><span>mAP:</span> <span class="font-medium"> </span></div> <div class="flex justify-between"><span>mAP@50:</span> <span class="font-medium"> </span></div> <div class="flex justify-between"><span>mAP@75:</span> <span class="font-medium"> </span></div></div></div> <!> <!></div>'),ms=$('<div class="flex w-80 flex-col rounded-[1vw] bg-card p-4"><div class="mb-5 mt-2 text-lg font-semibold">Metrics</div> <!> <div class="flex-1 space-y-6"><!></div></div>'),_s=$('<div class="hidden"></div>');function gs(d,t){Oe(t,!0);const[a,l]=Ke(),n=()=>L(F,"$isMetricsPanelOpen",a),u=()=>L(P,"$hasEnoughTasksForMetrics",a),v=()=>L(A,"$annotationTasks",a),y=()=>L(E,"$tags",a);let W=He.params.dataset_id;const{tags:E}=Et({dataset_id:W}),{annotationTasks:A,hasEnoughTasksForMetrics:P}=la(),{isMetricsPanelOpen:F}=ja();let S=Be(""),k=Be(""),b=Be(""),f=Be(null),x=Be(!1),j=Be("");async function Y(){if(!e(S)||!e(k)){M(j,"Please select both ground truth and prediction tasks");return}M(x,!0),M(j,"");try{const T=await as({dataset_id:W,ground_truth_task_id:e(S),prediction_task_id:e(k),tag_id:e(b)||null});T.error?M(j,Re(T.error)):M(f,Re(T.data))}catch(T){M(j,Re(String(T)))}finally{M(x,!1)}}function g(){M(S,""),M(k,""),M(b,""),M(f,null),M(j,"")}var N=U(),V=C(N);{var pe=T=>{var Ce=ms(),Pe=r(i(Ce),2);vt(Pe,{class:"mb-4 bg-border-hard"});var De=r(Pe,2),me=i(De);{var te=J=>{var re=cs(),he=i(re);yt(he,{label:"Ground Truth Task",children:(I,Q)=>{var B=U(),xe=C(B);ve(xe,()=>kt,(ne,q)=>{q(ne,{type:"single",name:"groundTruthTaskId",get value(){return e(S)},set value(z){M(S,Re(z))},children:(z,oe)=>{var ie=ss(),Z=C(ie);ve(Z,()=>wt,(h,R)=>{R(h,{class:"w-full",children:(w,H)=>{X();var O=fe();de(D=>K(O,D),[()=>{var D;return((D=v().find(ue=>ue.annotation_task_id===e(S)))==null?void 0:D.name)||"Select ground truth task"}]),s(w,O)},$$slots:{default:!0}})});var Me=r(Z,2);ve(Me,()=>Ct,(h,R)=>{R(h,{children:(w,H)=>{var O=U(),D=C(O);ve(D,()=>St,(ue,G)=>{G(ue,{children:(le,Ie)=>{var _e=U(),ge=C(_e);Je(ge,1,()=>v().filter(be=>!be.is_prediction),nt,(be,ee)=>{var ae=U(),ye=C(ae);{var ze=Ee=>{var Le=U(),qe=C(Le);ve(qe,()=>Pt,(ft,Xe)=>{Xe(ft,{get value(){return e(ee).annotation_task_id},get label(){return e(ee).name},children:($t,Xt)=>{X();var st=fe();de(()=>K(st,e(ee).name)),s($t,st)},$$slots:{default:!0}})}),s(Ee,Le)};se(ye,Ee=>{e(ee).annotation_task_id&&Ee(ze)})}s(be,ae)}),s(le,_e)},$$slots:{default:!0}})}),s(w,O)},$$slots:{default:!0}})}),s(z,ie)},$$slots:{default:!0}})}),s(I,B)}});var ke=r(he,2);yt(ke,{label:"Prediction Task",children:(I,Q)=>{var B=U(),xe=C(B);ve(xe,()=>kt,(ne,q)=>{q(ne,{type:"single",name:"predictionTaskId",get value(){return e(k)},set value(z){M(k,Re(z))},children:(z,oe)=>{var ie=rs(),Z=C(ie);ve(Z,()=>wt,(h,R)=>{R(h,{class:"w-full",children:(w,H)=>{X();var O=fe();de(D=>K(O,D),[()=>{var D;return((D=v().find(ue=>ue.annotation_task_id===e(k)))==null?void 0:D.name)||"Select prediction task"}]),s(w,O)},$$slots:{default:!0}})});var Me=r(Z,2);ve(Me,()=>Ct,(h,R)=>{R(h,{children:(w,H)=>{var O=U(),D=C(O);ve(D,()=>St,(ue,G)=>{G(ue,{children:(le,Ie)=>{var _e=U(),ge=C(_e);Je(ge,1,()=>v().filter(be=>be.is_prediction),nt,(be,ee)=>{var ae=U(),ye=C(ae);{var ze=Ee=>{var Le=U(),qe=C(Le);ve(qe,()=>Pt,(ft,Xe)=>{Xe(ft,{get value(){return e(ee).annotation_task_id},get label(){return e(ee).name},children:($t,Xt)=>{X();var st=fe();de(()=>K(st,e(ee).name)),s($t,st)},$$slots:{default:!0}})}),s(Ee,Le)};se(ye,Ee=>{e(ee).annotation_task_id&&Ee(ze)})}s(be,ae)}),s(le,_e)},$$slots:{default:!0}})}),s(w,O)},$$slots:{default:!0}})}),s(z,ie)},$$slots:{default:!0}})}),s(I,B)}});var $e=r(ke,2);yt($e,{label:"Tag (Optional)",children:(I,Q)=>{var B=U(),xe=C(B);ve(xe,()=>kt,(ne,q)=>{q(ne,{type:"single",name:"tagId",get value(){return e(b)},set value(z){M(b,Re(z))},children:(z,oe)=>{var ie=os(),Z=C(ie);ve(Z,()=>wt,(h,R)=>{R(h,{class:"w-full",children:(w,H)=>{X();var O=fe();de(D=>K(O,D),[()=>{var D;return((D=y().find(ue=>ue.tag_id===e(b)))==null?void 0:D.name)||"Select tag (optional)"}]),s(w,O)},$$slots:{default:!0}})});var Me=r(Z,2);ve(Me,()=>Ct,(h,R)=>{R(h,{children:(w,H)=>{var O=U(),D=C(O);ve(D,()=>St,(ue,G)=>{G(ue,{children:(le,Ie)=>{var _e=ns(),ge=C(_e);ve(ge,()=>da,(ee,ae)=>{ae(ee,{children:(ye,ze)=>{X();var Ee=fe("Sample tags");s(ye,Ee)},$$slots:{default:!0}})});var be=r(ge,2);Je(be,1,()=>y().filter(ee=>ee.kind==="sample"),nt,(ee,ae)=>{var ye=U(),ze=C(ye);ve(ze,()=>Pt,(Ee,Le)=>{Le(Ee,{get value(){return e(ae).tag_id},get label(){return e(ae).name},children:(qe,ft)=>{X();var Xe=fe();de(()=>K(Xe,e(ae).name)),s(qe,Xe)},$$slots:{default:!0}})}),s(ee,ye)}),s(le,_e)},$$slots:{default:!0}})}),s(w,O)},$$slots:{default:!0}})}),s(z,ie)},$$slots:{default:!0}})}),s(I,B)}});var Te=r($e,2);{var Fe=I=>{var Q=is(),B=i(Q,!0);o(Q),de(()=>K(B,e(j))),s(I,Q)};se(Te,I=>{e(j)&&I(Fe)})}var m=r(Te,2),c=i(m);je(c,{variant:"outline",class:"flex-1",onclick:g,get disabled(){return e(x)},children:(I,Q)=>{X();var B=fe("Reset");s(I,B)},$$slots:{default:!0}});var _=r(c,2);const ce=p(()=>!e(S)||!e(k)||e(x));je(_,{variant:"default",class:"flex-1",onclick:Y,get disabled(){return e(ce)},children:(I,Q)=>{var B=ds(),xe=C(B);{var ne=q=>{var z=ls();s(q,z)};se(xe,q=>{e(x)&&q(ne)})}X(),s(I,B)},$$slots:{default:!0}}),o(m),o(re),s(J,re)},Se=J=>{var re=fs(),he=i(re),ke=r(i(he),2),$e=i(ke),Te=r(i($e),2),Fe=i(Te);o(Te),o($e);var m=r($e,2),c=r(i(m),2),_=i(c);o(c),o(m);var ce=r(m,2),I=r(i(ce),2),Q=i(I);o(I),o(ce),o(ke),o(he);var B=r(he,2);{var xe=q=>{var z=vs(),oe=r(i(z),2);Je(oe,21,()=>Object.entries(e(f).map_per_class).sort(([ie],[Z])=>ie<Z?-1:ie>Z?1:0),nt,(ie,Z)=>{let Me=()=>e(Z)[0],h=()=>e(Z)[1];var R=us(),w=i(R),H=i(w);o(w);var O=r(w,2),D=i(O);o(O),o(R),de(ue=>{K(H,`${Me()??""}:`),K(D,`${ue??""}%`)},[()=>(h()*100).toFixed(2)]),s(ie,R)}),o(oe),o(z),s(q,z)};se(B,q=>{e(f).map_per_class&&q(xe)})}var ne=r(B,2);je(ne,{variant:"outline",class:"mt-4 w-full",onclick:()=>M(f,null),children:(q,z)=>{X();var oe=fe("Back to Form");s(q,oe)},$$slots:{default:!0}}),o(re),de((q,z,oe)=>{K(Fe,`${q??""}%`),K(_,`${z??""}%`),K(Q,`${oe??""}%`)},[()=>(e(f).map*100).toFixed(2),()=>(e(f).map_50*100).toFixed(2),()=>(e(f).map_75*100).toFixed(2)]),s(J,re)};se(me,J=>{e(f)?J(Se,!1):J(te)})}o(De),o(Ce),s(T,Ce)},we=T=>{var Ce=_s();s(T,Ce)};se(V,T=>{n()&&u()?T(pe):T(we,!1)})}s(d,N),Ne(),l()}var ps=$("<input>"),hs=$("<input>");function Ft(d,t){Oe(t,!0);let a=et(t,"ref",15,null),l=et(t,"value",15),n=et(t,"files",15),u=at(t,["$$slots","$$events","$$legacy","ref","value","type","files","class"]);var v=U(),y=C(v);{var W=A=>{var P=ps();zt(P);let F;Lt(P,S=>a(S),()=>a()),de(S=>F=Rt(P,F,{class:S,type:"file",...u}),[()=>ot("border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-base file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t.class)]),ca(P,n),jt(P,l),s(A,P)},E=A=>{var P=hs();zt(P);let F;Lt(P,S=>a(S),()=>a()),de(S=>F=Rt(P,F,{class:S,type:t.type,...u}),[()=>ot("border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-base file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t.class)]),jt(P,l),s(A,P)};se(y,A=>{t.type==="file"?A(W):A(E,!1)})}s(d,v),Ne()}var $s=$('<div class="flex w-80 flex-col rounded-[1vw] bg-card p-4"><div class="mb-5 mt-2 flex items-center justify-between"><div class="text-lg font-semibold">Create Classifier</div> <!></div> <!> <div class="flex-1 space-y-6"><!> <div class="space-y-2"><label for="classifier-name" class="text-sm font-medium">Classifier Name</label> <!></div> <!></div></div>'),xs=$('<div class="hidden"></div>');function bs(d,t){Oe(t,!1);const[a,l]=Ke(),n=()=>L(v,"$isCreateClassifiersPanelOpen",a),u=()=>L(W,"$error",a),{isCreateClassifiersPanelOpen:v,closeCreateClassifiersPanel:y}=ua(),{error:W,createClassifier:E}=qt(),{clearClassifierSamples:A}=it();let P=na(""),F=He.params.dataset_id;function S(){A(),M(P,""),y(),Ue(Ge.toSamples(F))}Qt();var k=U(),b=C(k);{var f=j=>{var Y=$s(),g=i(Y),N=r(i(g),2);je(N,{variant:"ghost",size:"icon",onclick:S,class:"h-8 w-8",children:(te,Se)=>{X();var J=fe("✕");s(te,J)},$$slots:{default:!0}}),o(g);var V=r(g,2);vt(V,{class:"mb-4 bg-border-hard"});var pe=r(V,2),we=i(pe);{var T=te=>{At(te,{title:"Error occured",children:(Se,J)=>{X();var re=fe();de(()=>K(re,u())),s(Se,re)}})};se(we,te=>{u()&&te(T)})}var Ce=r(we,2),Pe=r(i(Ce),2);Ft(Pe,{id:"classifier-name",type:"text",placeholder:"Enter classifier name",get value(){return e(P)},set value(te){M(P,te)},$$legacy:!0}),o(Ce);var De=r(Ce,2);const me=oa(()=>!e(P).trim());je(De,{variant:"default",class:"w-full",onclick:()=>E({name:e(P),class_list:["positive","negative"],dataset_id:F}),get disabled(){return e(me)},children:(te,Se)=>{X();var J=fe("Create Classifier");s(te,J)},$$slots:{default:!0}}),o(pe),o(Y),s(j,Y)},x=j=>{var Y=xs();s(j,Y)};se(b,j=>{n()?j(f):j(x,!1)})}s(d,k),Ne(),l()}var ys=$('<div class="w-300 flex space-x-4 text-diffuse-foreground"><!> <!> <!></div>');function ws(d,t){Oe(t,!0);const[a,l]=Ke(),n=()=>L(y,"$sampleSize",a),u=et(t,"min",3,100),v=et(t,"max",3,1500),{sampleSize:y,updateSampleSize:W}=it(),E=p(()=>n().width),A=va.throttle(f=>{W(f[0])},100);var P=ys(),F=i(P);Za(F,{class:"h-6 w-6"});var S=r(F,2);const k=p(()=>[e(E)]);_t(S,{class:"w-full flex-1",get value(){return e(k)},get min(){return u()},get max(){return v()},step:1,onValueChange:A});var b=r(S,2);Yt(b,{class:"h-6 w-6"}),o(P),s(d,P),Ne(),l()}var Cs=$('<div class="h-3 w-3 cursor-pointer rounded-sm border"></div>'),Ss=$('<div class="color-picker-container"><!></div> <p class="flex-1 truncate text-base font-normal" data-testid="label-menu-label-name"> </p> <span class="text-sm text-diffuse-foreground" data-testid="label-menu-label-count"> </span>',1),Ps=$('<div class="width-full flex items-center space-x-2"><!> <!></div>'),ks=$('<div class="width-full space-y-2 overflow-hidden"></div>');function Ts(d,t){Oe(t,!0);const[a,l]=Ke(),n=()=>L(A,"$customLabelColorsStore",a),u=()=>L(v(),"$annotationFilters",a);let v=et(t,"annotationFilters",19,()=>[]);const{setCustomColor:y,getCustomColor:W,hasCustomColor:E,customLabelColorsStore:A}=pa();function P(b,f,x){y(b,f,x)}function F(b){if(E(b)){const x=W(b);return(x==null?void 0:x.color)||"#ff0000"}const f=mt(b,1).color;try{const x=f.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(x){const j=parseInt(x[1]),Y=parseInt(x[2]),g=parseInt(x[3]);return`#${((1<<24)+(j<<16)+(Y<<8)+g).toString(16).slice(1)}`}}catch(x){console.error("Error converting rgba to hex",x)}return"#ff0000"}function S(b){if(E(b)){const f=W(b);return(f==null?void 0:f.alpha)||1}return .4}const k=p(()=>{const b=n(),f={};for(const x of Object.keys(b)){const j=b[x];f[x]={borderColor:j.color,backgroundColor:mt(x,.4).color}}return f});ht(d,{title:"Labels",children:(b,f)=>{var x=ks();Je(x,5,u,({label_name:j,current_count:Y,total_count:g,selected:N})=>j,(j,Y)=>{let g=()=>e(Y).label_name,N=()=>e(Y).current_count,V=()=>e(Y).total_count,pe=()=>e(Y).selected;var we=Ps(),T=i(we);const Ce=p(()=>`${g()}-label`);fa(T,{get id(){return g()},get checked(){return pe()},get"aria-labelledby"(){return e(Ce)},onCheckedChange:()=>t.onToggleAnnotationFilter(g())});var Pe=r(T,2);const De=p(()=>`${g()}-label`);Ht(Pe,{get id(){return e(De)},get for(){return g()},"data-testid":"labels-menu-item",class:"flex min-w-0 flex-1 cursor-pointer items-center space-x-2 text-nowrap peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:(me,te)=>{var Se=Ss(),J=C(Se),re=i(J);const he=p(()=>F(g())),ke=p(()=>S(g()));ma(re,{get initialColor(){return e(he)},get initialAlpha(){return e(ke)},onChange:(c,_)=>P(g(),c,_),children:(c,_)=>{var ce=Cs();de(I=>_a(ce,I),[()=>{var I,Q;return`
|
|
2
|
+
border-color: ${((I=e(k)[g()])==null?void 0:I.borderColor)??mt(g()).color};
|
|
3
|
+
background-color: ${((Q=e(k)[g()])==null?void 0:Q.backgroundColor)??mt(g(),pe()?1:.4).color};
|
|
4
|
+
`}]),s(c,ce)},$$slots:{default:!0}}),o(J);var $e=r(J,2),Te=i($e,!0);o($e);var Fe=r($e,2),m=i(Fe);o(Fe),de((c,_)=>{K(Te,g()),K(m,`${c??""} of ${_??""}`)},[()=>Qe(N()),()=>Qe(V())]),s(me,Se)},$$slots:{default:!0}}),o(we),de(()=>ga(we,"title",g())),s(j,we)}),o(x),s(b,x)},$$slots:{default:!0}}),Ne(),l()}const Is=async({dataset_id:d,tag_id:t,annotationIdsBody:a})=>{const l={data:void 0,error:void 0};try{const n=await lt.POST("/api/datasets/{dataset_id}/tags/{tag_id}/add/annotations",{params:{path:{dataset_id:d,tag_id:t}},body:a});if(n.error)throw new Error(JSON.stringify(n.error,null,2));if(!n.data)throw new Error("No data");l.data=n.data}catch(n){l.error="Error assigning annotationIds to a tag: "+String(n)}return l},Es=d=>["/api/datasets/{dataset_id}/tags",d],As=async({dataset_id:d,tag_id:t,sampleIdsBody:a})=>{const l={data:void 0,error:void 0};try{const n=await lt.POST("/api/datasets/{dataset_id}/tags/{tag_id}/add/samples",{params:{path:{dataset_id:d,tag_id:t}},body:a});if(n.error)throw new Error(JSON.stringify(n.error,null,2));if(!n.data)throw new Error("No data");l.data=n.data}catch(n){l.error="Error assigning sampleIds to tag: "+String(n)}return l},Fs=async({dataset_id:d,tagInputBody:t})=>{const a={data:void 0,error:void 0};try{const l=await lt.POST("/api/datasets/{dataset_id}/tags",{params:{path:{dataset_id:d}},body:t});if(l.error)throw new Error(JSON.stringify(l.error,null,2));if(!l.data)throw new Error("No data");a.data=l.data}catch(l){a.error="Error creating tag: "+String(l)}return a};var Ms=$("<!> Create new Tags",1),Os=$("<!> <!>",1),Ns=$('<div class="flex space-x-2 py-1"><!></div>'),Ds=$('<!> <!> <div class="grid gap-4"><!></div> <div><!> <!></div> <!>',1),Ls=$('<div class="flex space-x-1"><!> <!></div> <!>',1);function zs(d,t){Oe(t,!0);const[a,l]=Ke(),n=()=>L(S,"$selectedSampleIds",a),u=()=>L(k,"$selectedSampleAnnotationCropIds",a),v=()=>L(e(P),"$tags",a),y=()=>L(e(j),"$itemsSelected",a),W=()=>L(te,"$submitTagAndMutate",a);let E=p(()=>t.gridType==="samples"?"sample":"annotation");const A=p(()=>Et({dataset_id:t.datasetId,kind:[e(E)]})),P=p(()=>e(A).tags),F=p(()=>e(A).loadTags),{selectedSampleIds:S,selectedSampleAnnotationCropIds:k,clearSelectedSampleAnnotationCrops:b,clearSelectedSamples:f}=it(),x=p(()=>t.gridType==="samples"?f:b),j=p(()=>t.gridType==="samples"?S:k);let Y=Be(!1);const g=p(()=>n().size>0&&t.gridType==="samples"||u().size>0&&t.gridType==="annotations");let N=Be(""),V=Be(Re([])),pe=()=>{e(V).push(e(N)),T.add(e(N)),M(N,"")};const we=p(()=>[...e(V).map(c=>({tag_id:c,name:c,kind:e(E)})),...v()].filter(c=>c.name.includes(e(N))));let T=Re(new It);const Ce=c=>{T.has(c)?(T.delete(c),e(V).splice(e(V).indexOf(c),1)):T.add(c)};let Pe=Be(null);const De=async()=>{await Promise.all([...e(V)].map(async c=>{var ce;const _=await Fs({dataset_id:t.datasetId,tagInputBody:{name:c,description:`${c} description`,kind:e(E)}});if(_.error)throw _.error;return(ce=_.data)!=null&&ce.tag_id&&(T.delete(c),T.add(_.data.tag_id)),_})),await Promise.all([...T].map(async c=>{const _=e(E)==="sample"?await As({dataset_id:t.datasetId,tag_id:c,sampleIdsBody:{sample_ids:[...y()]}}):await Is({dataset_id:t.datasetId,tag_id:c,annotationIdsBody:{annotation_ids:[...y()]}});if(_.error)throw _.error;return _}))},me=La(),te=ha({mutationFn:async()=>{await De()},onError:c=>{M(Pe,Re(c))},onSuccess:()=>{me.invalidateQueries({queryKey:Es({dataset_id:t.datasetId})}),e(F)(),e(x)(),Se(!1)}}),Se=c=>{M(Y,Re(c)),M(Pe,null),M(N,""),M(V,Re([])),T.clear()},J=p(()=>T.size>0||e(V).length>0);var re=Ls(),he=C(re),ke=i(he);const $e=p(()=>!e(g));je(ke,{variant:"outline",get disabled(){return e($e)},class:"flex-1",onclick:()=>M(Y,!0),"data-testid":"tag-create-dialog-button",children:(c,_)=>{var ce=Ms(),I=C(ce);es(I,{}),X(),s(c,ce)},$$slots:{default:!0}});var Te=r(ke,2);const Fe=p(()=>!e(g));je(Te,{variant:"outline",get disabled(){return e(Fe)},size:"icon",title:"Clear selection",get onclick(){return e(x)},children:(c,_)=>{Xa(c,{})},$$slots:{default:!0}}),o(he);var m=r(he,2);ve(m,()=>Ca,(c,_)=>{_(c,{onOpenChange:Se,get open(){return e(Y)},children:(ce,I)=>{var Q=U(),B=C(Q);ve(B,()=>$a,(xe,ne)=>{ne(xe,{class:"sm:max-w-[425px]",children:(q,z)=>{var oe=Ds(),ie=C(oe);ve(ie,()=>xa,(G,le)=>{le(G,{children:(Ie,_e)=>{var ge=Os(),be=C(ge);ve(be,()=>ba,(ae,ye)=>{ye(ae,{children:(ze,Ee)=>{X();var Le=fe();de(()=>K(Le,`Add the selected ${e(E)??""} to a tag`)),s(ze,Le)},$$slots:{default:!0}})});var ee=r(be,2);ve(ee,()=>ya,(ae,ye)=>{ye(ae,{children:(ze,Ee)=>{X();var Le=fe();de(()=>K(Le,`Add the selected ${y().size??""}
|
|
5
|
+
${e(E)??""} to an new or existing tag. Tags can later be exported.`)),s(ze,Le)},$$slots:{default:!0}})}),s(Ie,ge)},$$slots:{default:!0}})});var Z=r(ie,2);{var Me=G=>{At(G,{title:"Error occured",children:(le,Ie)=>{X();var _e=fe();de(()=>K(_e,e(Pe))),s(le,_e)}})};se(Z,G=>{e(Pe)&&G(Me)})}var h=r(Z,2),R=i(h);Ft(R,{type:"text",placeholder:"Create or search tags",autofocus:!0,"data-testid":"tag-create-dialog-input",get value(){return e(N)},set value(G){M(N,Re(G))}}),o(h);var w=r(h,2),H=i(w);Je(H,17,()=>e(we),G=>G.tag_id,(G,le)=>{var Ie=Ns(),_e=i(Ie);const ge=p(()=>`tagCreateDialog-tag-${e(le).tag_id}`),be=p(()=>T.has(e(le).tag_id));Gt(_e,{get name(){return e(ge)},get isChecked(){return e(be)},get label(){return e(le).name},onCheckedChange:()=>Ce(e(le).tag_id)}),o(Ie),s(G,Ie)});var O=r(H,2);{var D=G=>{const le=p(()=>ot("",...Sa({variant:"outline"})));je(G,{type:"button",variant:"outline",get class(){return e(le)},onclick:pe,"data-testid":"tag-create-dialog-create",children:(Ie,_e)=>{X();var ge=fe();de(()=>K(ge,`Create tag "${e(N)??""}"`)),s(Ie,ge)},$$slots:{default:!0}})};se(O,G=>{e(N)&&G(D)})}o(w);var ue=r(w,2);ve(ue,()=>wa,(G,le)=>{le(G,{children:(Ie,_e)=>{var ge=U(),be=C(ge);{var ee=ae=>{je(ae,{type:"submit",onclick:()=>W().mutate(),"data-testid":"tag-create-dialog-save",children:(ye,ze)=>{X();var Ee=fe("Save changes");s(ye,Ee)},$$slots:{default:!0}})};se(be,ae=>{e(J)&&ae(ee)})}s(Ie,ge)},$$slots:{default:!0}})}),s(q,oe)},$$slots:{default:!0}})}),s(ce,Q)},$$slots:{default:!0}})}),s(d,re),Ne(),l()}var Rs=$('<div class="flex items-center space-x-2 py-1" data-testid="tag-menu-item"><!></div>'),js=$("<p>No tag, create a tag</p>"),Bs=$('<div class="mb-3 w-full space-y-2"></div>');function Vs(d,t){Oe(t,!0);const[a,l]=Ke(),n=()=>L(e(y),"$tags",a),u=()=>L(e(W),"$tagsSelected",a),v=p(()=>Et({dataset_id:t.dataset_id,kind:[t.gridType==="annotations"?"annotation":"sample"]})),y=p(()=>e(v).tags),W=p(()=>e(v).tagsSelected),E=p(()=>e(v).tagSelectionToggle);ht(d,{title:"Tags",icon:Va,children:(A,P)=>{var F=Bs();Je(F,5,n,S=>S.tag_id,(S,k)=>{var b=Rs(),f=i(b);const x=p(()=>u().has(e(k).tag_id));Gt(f,{get name(){return e(k).tag_id},get isChecked(){return e(x)},get label(){return e(k).name},onCheckedChange:()=>e(E)(e(k).tag_id)}),o(b),s(S,b)},S=>{var k=js();s(S,k)}),o(F),s(A,F)}}),Ne(),l()}var qs=$(`<li>Once satisfied with the results, click "Commit Temporary Classifier"
|
|
6
|
+
to save permanently</li>`),Hs=$('<div class="flex w-80 flex-col rounded-[1vw] bg-card p-4"><div class="mb-5 mt-2 flex items-center justify-between"><div class="text-lg font-semibold"> </div> <!></div> <!> <div class="flex-1 space-y-6"><div class="space-y-4"><div><h3 class="mb-2 text-lg font-semibold">Refinement Instructions</h3> <p class="mb-4 text-sm text-muted-foreground">You are refining classifier: <span class="font-medium"> </span></p> <ol class="list-inside list-decimal space-y-2 text-sm text-muted-foreground"><li>Select positive examples from the samples</li> <li>Click "Refine Classifier" to retrain with your selections</li> <!></ol></div></div> <div class="space-y-4"><!> <!> <div class="flex items-center justify-between gap-4"><!> <!></div> <!></div></div></div>'),Gs=$('<div class="hidden"></div>');function Ks(d,t){Oe(t,!1);const[a,l]=Ke(),n=()=>L(S,"$isRefineClassifiersPanelOpen",a),u=()=>L(b,"$currentMode",a),v=()=>L(x,"$currentClassifierName",a),y=()=>L(Y,"$error",a),W=()=>L(f,"$currentClassifierId",a),E=()=>L(j,"$currentClassifierClasses",a),A=()=>L(F,"$showTrainingSamplesToggle",a),{clearSelectedSamples:P}=it(),F=Zt("refine_classifier_show_training_samples",!1),{isRefineClassifiersPanelOpen:S,closeRefineClassifiersPanel:k,currentMode:b,currentClassifierId:f,currentClassifierName:x,currentClassifierClasses:j}=Pa(),{error:Y,commitTempClassifier:g,refineClassifier:N,showClassifierTrainingSamples:V}=qt();let pe=He.params.dataset_id;function we(){P(),F.set(!1),k(),Ue(Ge.toSamples(pe))}Qt();var T=U(),Ce=C(T);{var Pe=me=>{var te=Hs(),Se=i(te),J=i(Se),re=i(J,!0);o(J);var he=r(J,2);je(he,{variant:"ghost",size:"icon",onclick:we,class:"h-8 w-8",children:(h,R)=>{X();var w=fe("✕");s(h,w)},$$slots:{default:!0}}),o(Se);var ke=r(Se,2);vt(ke,{class:"mb-4 bg-border-hard"});var $e=r(ke,2),Te=i($e),Fe=i(Te),m=r(i(Fe),2),c=r(i(m)),_=i(c,!0);o(c),o(m);var ce=r(m,2),I=r(i(ce),4);{var Q=h=>{var R=qs();s(h,R)};se(I,h=>{u()==="temp"&&h(Q)})}o(ce),o(Fe),o(Te);var B=r(Te,2),xe=i(B);{var ne=h=>{At(h,{title:"Error occured",children:(R,w)=>{X();var H=fe();de(()=>K(H,y())),s(R,H)}})};se(xe,h=>{y()&&h(ne)})}var q=r(xe,2);je(q,{variant:"default",class:"w-full",onclick:()=>{F.set(!1),N(W()||"",pe,E()||[])},children:(h,R)=>{X();var w=fe("Refine Classifier");s(h,w)},$$slots:{default:!0}});var z=r(q,2),oe=i(z);Ht(oe,{class:"text-foreground",children:(h,R)=>{X();var w=fe("Show All Training Samples");s(h,w)},$$slots:{default:!0}});var ie=r(oe,2);ka(ie,{class:"",get checked(){return A()},onCheckedChange:h=>{F.set(h),V(W()||"",pe,E()||[],h)}}),o(z);var Z=r(z,2);{var Me=h=>{je(h,{variant:"outline",class:"w-full",onclick:()=>{F.set(!1),g(W()||"",pe)},children:(R,w)=>{X();var H=fe("Commit Temporary Classifier");s(R,H)},$$slots:{default:!0}})};se(Z,h=>{u()==="temp"&&h(Me)})}o(B),o($e),o(te),de(()=>{K(re,u()==="temp"?"Refine Temporary Classifier":"Refine Classifier"),K(_,v())}),s(me,te)},De=me=>{var te=Gs();s(me,te)};se(Ce,me=>{n()?me(Pe):me(De,!1)})}s(d,T),Ne(),l()}const Ws=async({params:{dataset_id:d}})=>{const{data:t,error:a}=await ea(d);if(a||!t)throw ra(307,Ge.toHome());const l=it(),n=Vt(l.selectedAnnotationFilterIds,u=>Array.from(u));return{datasetId:d,dataset:t,globalStorage:l,selectedAnnotationFilterIds:n,sampleSize:l.sampleSize}},Ir=Object.freeze(Object.defineProperty({__proto__:null,load:Ws},Symbol.toStringTag,{value:"Module"})),Js=d=>{const{settingsStore:t}=Ta(),a=new Set,l=u=>{if(u.target instanceof HTMLInputElement||u.target instanceof HTMLTextAreaElement||u.target instanceof HTMLSelectElement)return;a.add(u.key);const v=Ze(Tt).url.pathname,y={hideAnnotations:Ze(t).key_hide_annotations||"v",goBack:Ze(t).key_go_back||"Escape"};Object.entries(d).forEach(([W,E])=>{const A=y[W]||E.key;if(u.key===A){if(E.requiredPath){if(typeof E.requiredPath=="function"){if(!E.requiredPath(v))return}else if(!E.requiredPath.test(v))return}E.action(u)}})},n=u=>{a.delete(u.key)};return Kt(()=>{window.addEventListener("keydown",l),window.addEventListener("keyup",n)}),Wt(()=>{window.removeEventListener("keydown",l),window.removeEventListener("keyup",n)}),{isKeyPressed:u=>a.has(u)}},Qs={goBack:{key:"Escape",description:"Go back from detail view to grid view",isConfigurable:!0,requiredPath:d=>/\/datasets\/[^/]+\/(samples|annotations)\/[^/]+/.test(d)||/\/samples\/[^/]+/.test(d),action:()=>{const d=Ze(Tt).url.pathname,t=Ze(Tt).params.dataset_id;if(/\/samples\/[^/]+/.test(d)&&!t){Ue("/");return}t&&(d.includes("/samples/")?Ue(Ge.toSamples(t)):d.includes("/annotations/")&&Ue(Ge.toAnnotations(t)))}}},Us=async({query_text:d="",model_id:t=""})=>{const a={data:[],error:void 0};try{const l=await lt.GET("/api/text_embedding/embed_text",{params:{query:{query_text:d,model_id:t}}});if(l.error)throw new Error(JSON.stringify(l.error,null,2));if(!l.data)throw new Error("No data");a.data=l.data}catch(l){a.error="Error creating text embedding: "+String(l)}return a},Ys=({datasetId:d,options:t})=>{var a,l,n,u;return za(Ra({path:{dataset_id:d},query:{...(t==null?void 0:t.filtered_labels)&&{filtered_labels:t.filtered_labels},...((a=t==null?void 0:t.dimensions)==null?void 0:a.min_width)&&{min_width:t.dimensions.min_width},...((l=t==null?void 0:t.dimensions)==null?void 0:l.max_width)&&{max_width:t.dimensions.max_width},...((n=t==null?void 0:t.dimensions)==null?void 0:n.min_height)&&{min_height:t.dimensions.min_height},...((u=t==null?void 0:t.dimensions)==null?void 0:u.max_height)&&{max_height:t.dimensions.max_height}}}))};var Xs=$("<div><!></div>"),Zs=$('<div class="space-y-2"><!> <!></div>'),er=$('<div class="flex w-80 flex-col space-y-6 rounded-[1vw] bg-card py-4"><div class="px-4"><!></div> <div class="min-h-0 flex-1 space-y-2 overflow-y-auto px-4 dark:[color-scheme:dark]"><div><!> <!></div> <!> <!></div></div>'),tr=$('<div class="relative"><!> <!></div>'),ar=$("<!> <!>",1),sr=$('<div class="flex h-full w-full space-x-4 px-4 pb-4"><!> <div class="flex1 flex flex-grow flex-col space-y-4 rounded-[1vw] bg-card p-4"><div class="my-2 flex items-center space-x-4"><div class="flex-1"><!></div> <div class="w-4/12"><!></div></div> <!> <div class="flex min-h-0 flex-1"><!></div></div> <!> <!></div>');function Er(d,t){Oe(t,!0);const[a,l]=Ke(),n=()=>L(F,"$textEmbedding",a),u=()=>L(g,"$featureFlags",a),v=()=>L(De,"$annotationFilterLabels",a),y=()=>L(k,"$selectedAnnotationFilterIds",a),W=()=>L(Ce,"$dimensionsValues",a),E=()=>L(e(Se),"$annotationCounts",a),{datasetId:A,globalStorage:{setTextEmbedding:P,textEmbedding:F,setLastGridType:S,selectedAnnotationFilterIds:k}}=t.data,{handleKeyEvent:b}=Ia();Kt(()=>{window.addEventListener("keydown",b),window.addEventListener("keyup",b)}),Wt(()=>{window.removeEventListener("keydown",b),window.removeEventListener("keyup",b)}),Js({goBack:Qs.goBack});let f=Be("samples");Dt(()=>{He.url.pathname===Ge.toAnnotations(A)?M(f,"annotations"):He.url.pathname===Ge.toClassifiers(A)?M(f,"classifiers"):M(f,"samples"),S(e(f))});let x=Be(Re(n()?n().queryText:""));async function j(){if(e(x).trim()!=="")try{return(await Us({query_text:e(x),model_id:void 0})).data}catch(m){he(m.message),console.error("Error during API call:",m)}}async function Y(m){if(m.key==="Enter"){const c=await j();P({queryText:e(x),embedding:c||[]})}}const{featureFlags:g}=Ba(),N=p(()=>u().some(m=>m==="embeddingSearchEnabled")),V=p(()=>u().some(m=>m==="fewShotClassifierEnabled")),pe=p(()=>ta(He.route.id)),we=p(()=>aa(He.route.id)),T=p(()=>sa(He.route.id)),{dimensionsValues:Ce}=Jt(A),Pe=Ea(),De=Vt(Pe,m=>m.data?m.data.reduce((c,_)=>({...c,[_.annotation_label_name]:_.annotation_label_id}),{}):{}),me=p(()=>{const m=v(),c=Array.from(y());return Object.entries(m).filter(([,_])=>c.includes(_)).map(([_])=>_)}),te=(m,c)=>m.map(_=>({..._,selected:c.includes(_.label_name)})),Se=p(()=>Ys({datasetId:A,options:{filtered_labels:e(me).length>0?e(me):void 0,dimensions:W()}})),J=ia([]);Dt(()=>{const m=E().data;if(m){const c=te(m,e(me));J.set(c)}});const re=m=>{const c=Ze(De)[m];c&&k.update(_=>(_.has(c)?_.delete(c):_.add(c),_))},he=m=>{Fa.error("Error",{description:m})};var ke=U(),$e=C(ke);{var Te=m=>{var c=U(),_=C(c);Ye(_,()=>t.children),s(m,c)},Fe=m=>{var c=sr(),_=i(c);{var ce=w=>{var H=er(),O=i(H),D=i(O);Ja(D,{datasetId:A,get gridType(){return e(f)}}),o(O);var ue=r(O,2),G=i(ue),le=i(G);Vs(le,{dataset_id:A,get gridType(){return e(f)}});var Ie=r(le,2);zs(Ie,{datasetId:A,get gridType(){return e(f)}}),o(G);var _e=r(G,2);{var ge=ee=>{var ae=Xs(),ye=i(ae);Ma(ye,{}),o(ae),s(ee,ae)};se(_e,ee=>{e(f)==="samples"&&e(N)&&e(V)&&ee(ge)})}var be=r(_e,2);ht(be,{title:"Filters",icon:ts,children:(ee,ae)=>{var ye=Zs(),ze=i(ye);Ts(ze,{annotationFilters:J,onToggleAnnotationFilter:re});var Ee=r(ze,2);{var Le=qe=>{Ya(qe,{})};se(Ee,qe=>{e(f)==="samples"&&qe(Le)})}o(ye),s(ee,ye)}}),o(ue),o(H),s(w,H)};se(_,w=>{(e(f)==="samples"||e(f)==="annotations")&&w(ce)})}var I=r(_,2),Q=i(I),B=i(Q),xe=i(B);{var ne=w=>{var H=tr(),O=i(H);Aa(O,{class:"absolute left-2 top-[50%] h-4 w-4 translate-y-[-50%] text-muted-foreground"});var D=r(O,2);Ft(D,{placeholder:"Search",class:"pl-8",onkeydown:Y,"data-testid":"text-embedding-search-input",get value(){return e(x)},set value(ue){M(x,Re(ue))}}),o(H),s(w,H)};se(xe,w=>{e(f)==="samples"&&e(N)&&w(ne)})}o(B);var q=r(B,2),z=i(q);ws(z,{}),o(q),o(Q);var oe=r(Q,2);vt(oe,{class:"mb-4 bg-border-hard"});var ie=r(oe,2),Z=i(ie);Ye(Z,()=>t.children),o(ie),o(I);var Me=r(I,2);{var h=w=>{var H=ar(),O=C(H);bs(O,{});var D=r(O,2);Ks(D,{}),s(w,H)};se(Me,w=>{e(f)==="classifiers"&&e(N)&&e(V)&&w(h)})}var R=r(Me,2);gs(R,{}),o(c),s(m,c)};se($e,m=>{e(pe)||e(we)||e(T)?m(Te):m(Fe,!1)})}s(d,ke),Ne(),l()}export{Er as component,Ir as universal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as a}from"../chunks/DIRAtgl0.js";import{L as d}from"../chunks/B9zumHo5.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as a}from"../chunks/D6su9Aln.js";import{u as l}from"../chunks/DIRAtgl0.js";import{u as m}from"../chunks/vC4nQVEB.js";import{L as b}from"../chunks/B9zumHo5.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 @@
|
|
|
1
|
+
import"../chunks/CWj6FrbW.js";import{p as V,f as _,n as Ae,a as Z,ax as xe,g as a,d as p,s as l,c as u,r as o,t as j,L as J,V as $e,$ as be,l as aa}from"../chunks/l7KrR96u.js";import{c as M,a as n,t as x,d as Se,n as Be}from"../chunks/Bu7uvVrG.js";import{i as D,a as W,s as He}from"../chunks/XO7A28GO.js";import{s as ee}from"../chunks/DIRAtgl0.js";import{p as le}from"../chunks/Bsi3UGy5.js";import{I as Ne,s as Te,u as ta,d as Ie,C as De,z as Le,S as sa,e as ce,B as na,p as we,D as ra,a as Ue,E as oa,F as Pe,H as la,c as da,i as ye,J as ia}from"../chunks/CvOmgdoc.js";import{u as Ee}from"../chunks/vC4nQVEB.js";import{a as ca,g as ma}from"../chunks/CxtLVaYz.js";import"../chunks/D6su9Aln.js";import"../chunks/Bx1xMsFy.js";import"../chunks/69_IOA4Y.js";import"../chunks/BJXwVxaE.js";import{e as Ce}from"../chunks/DjfY96ND.js";import{s as Me,r as Ve,a as ke}from"../chunks/D98V7j6A.js";import{S as Ze}from"../chunks/D5-A_Ffd.js";import{r as Y}from"../chunks/H7C68rOM.js";import{S as va}from"../chunks/B2FVR0s0.js";import{s as me}from"../chunks/D6RI2Zrd.js";import{B as ua,a as fa,b as X,c as de,H as pa,d as ie,D as ga,e as _a,u as ha,Z as xa,g as $a,S as ba}from"../chunks/nAHhluT7.js";import{T as Sa}from"../chunks/r64xT6ao.js";function Ia($,e){V(e,!0);let c=Ve(e,["$$slots","$$events","$$legacy"]);Ne($,Me({name:"file-image"},()=>c,{iconNode:[["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"}]],children:(t,h)=>{var f=M(),k=_(f);ee(k,()=>e.children??Ae),n(t,f)},$$slots:{default:!0}})),Z()}function wa($,e){V(e,!0);let c=Ve(e,["$$slots","$$events","$$legacy"]);Ne($,Me({name:"images"},()=>c,{iconNode:[["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"}]],children:(t,h)=>{var f=M(),k=_(f);ee(k,()=>e.children??Ae),n(t,f)},$$slots:{default:!0}})),Z()}var Pa=x('<!> <span class="hidden sm:inline">Home</span>',1),ya=x('<!> <span class="max-w-[150px] truncate"> </span>',1),Ca=x('<!> <span class="hidden sm:inline">Samples</span>',1),ka=x('<!> <span class="max-w-[200px] truncate"><!></span>',1),Aa=x("<!> <!> <!> <!> <!> <!> <!>",1);function Ba($,e){V(e,!0);const[c,S]=He(),t=()=>W(h,"$samplesTotalCount",c),{samplesTotalCount:h}=Ee();ua($,{class:"mb-2","data-testid":"sample-details-breadcrumb",children:(f,k)=>{fa(f,{children:(H,N)=>{var I=Aa(),A=_(I);X(A,{children:(g,L)=>{const d=p(()=>Y.toHome());de(g,{get href(){return a(d)},class:"flex items-center gap-2",children:(i,m)=>{var s=Pa(),v=_(s);pa(v,{class:"h-4 w-4"}),xe(2),n(i,s)},$$slots:{default:!0}})},$$slots:{default:!0}});var w=l(A,2);ie(w,{});var P=l(w,2);X(P,{children:(g,L)=>{const d=p(()=>Y.toSamples(e.dataset.dataset_id));de(g,{get href(){return a(d)},class:"flex items-center gap-2",get title(){return e.dataset.directory},children:(i,m)=>{var s=ya(),v=_(s);ga(v,{class:"h-4 w-4"});var C=l(v,2),z=u(C,!0);o(C),j(()=>{Te(C,"title",e.dataset.directory),me(z,e.dataset.name)}),n(i,s)},$$slots:{default:!0}})},$$slots:{default:!0}});var y=l(P,2);ie(y,{});var B=l(y,2);X(B,{children:(g,L)=>{const d=p(()=>Y.toSamples(e.dataset.dataset_id));de(g,{get href(){return a(d)},class:"flex items-center gap-2",children:(i,m)=>{var s=Ca(),v=_(s);wa(v,{class:"h-4 w-4"}),xe(2),n(i,s)},$$slots:{default:!0}})},$$slots:{default:!0}});var U=l(B,2);ie(U,{});var b=l(U,2);X(b,{children:(g,L)=>{_a(g,{class:"flex items-center gap-2",children:(d,i)=>{var m=ka(),s=_(m);Ia(s,{class:"h-4 w-4"});var v=l(s,2),C=u(v);{var z=T=>{var r=Se();j(()=>me(r,`Sample ${e.sampleIndex+1} of ${t()??""}`)),n(T,r)},ae=T=>{var r=Se("Sample");n(T,r)};D(C,T=>{e.sampleIndex!==void 0?T(z):T(ae,!1)})}o(v),n(d,m)},$$slots:{default:!0}})},$$slots:{default:!0}}),n(H,I)},$$slots:{default:!0}})},$$slots:{default:!0}}),Z(),S()}var Ha=Be("<g></g>"),Na=Be("<image></image><!>",1),Ta=x('<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=x('<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 La($,e){V(e,!0);const[c,S]=He(),t=()=>W(a(U),"$sample",c),h=()=>W(H,"$selectedSampleIds",c),f=()=>W(A,"$isHidden",c),k=()=>W(d,"$showAnnotationTextLabelsStore",c),{selectedSampleIds:H,toggleSampleSelection:N}=Ee(),I=e.dataset.dataset_id,{isHidden:A,handleKeyEvent:w}=ta(),{settingsStore:P}=Ie(),y=()=>{ma(Y.toSamples(I))},B=p(()=>ha({sampleId:e.sampleId,datasetId:I})),U=p(()=>a(B).sample),b=p(()=>a(B).refetch),g=r=>{switch(r.key){case aa(P).key_go_back:y();break;case" ":r.preventDefault(),N(e.sampleId);break}w(r)};let L=p(()=>$a(e.sampleId));const{showAnnotationTextLabelsStore:d}=Ie();let i=$e(void 0);ca(()=>{J(i,void 0),J(s,void 0)});const m=r=>{a(i)===r?J(i,void 0):J(i,ke(r))};let s=$e(void 0);const v=r=>{if(t().data.annotations){const E=t().data.annotations.find(F=>F.annotation_id===r);E&&J(s,ke(we(E)))}};var C=M();Ce("keydown",be,g),Ce("keyup",be,w);var z=_(C);{var ae=r=>{var E=Da(),F=u(E),ze=u(F);Ba(ze,{get dataset(){return e.dataset},get sampleIndex(){return e.sampleIndex}}),o(F);var ve=l(F,2);Ze(ve,{class:"mb-4 bg-border-hard"});var ue=l(ve,2),te=u(ue),Fe=u(te);De(Fe,{className:"h-full",children:(G,Fa)=>{Le(G,{className:"h-full",children:(Re,Ga)=>{var se=Ta(),pe=u(se),ne=u(pe),Je=u(ne);const We=p(()=>h().has(e.sampleId));sa(Je,{onSelect:()=>N(e.sampleId),get isSelected(){return a(We)}}),o(ne);var ge=l(ne,2);{var je=K=>{var re=M(),q=_(re);ee(q,()=>e.children),n(K,re)};D(ge,K=>{e.children&&K(je)})}var qe=l(ge,2);xa(qe,{get width(){return t().data.width},get height(){return t().data.height},get boundingBox(){return a(s)},children:(K,re)=>{var q=Na(),_e=_(q),Oe=l(_e);{var Qe=oe=>{var O=Ha();let he;ce(O,5,()=>ra(t().data),R=>R.annotation_id,(R,Q)=>{const Xe=p(()=>we(a(Q))),Ye=p(()=>a(Q).annotation_id===a(i));na(R,{get groupId(){return a(Q).annotation_id},onSelect:m,get box(){return a(Xe)},get isSelected(){return a(Ye)},children:(ea,Ka)=>{va(ea,{get annotation(){return a(Q)},get showLabel(){return k()},get imageWidth(){return t().data.width}})},$$slots:{default:!0}})}),o(O),j(R=>he=Ue(O,0,"",null,he,R),[()=>({invisible:f()})]),n(oe,O)};D(Oe,oe=>{t().data&&oe(Qe)})}j(()=>Te(_e,"href",a(L))),n(K,q)},$$slots:{default:!0}}),o(pe),o(se),n(Re,se)},$$slots:{default:!0}})},$$slots:{default:!0}}),o(te);var fe=l(te,2),Ge=u(fe);{var Ke=G=>{Za(G,{get sample(){return t().data},get selectedAnnotationId(){return a(i)},onAnnotationClick:m,onClickCenterIcon:v,get onUpdate(){return a(b)}})};D(Ge,G=>{t().data&&G(Ke)})}o(fe),o(ue),o(E),n(r,E)},T=r=>{oa(r,{})};D(z,r=>{t().data?r(ae):r(T,!1)})}n($,C),Z(),S()}var Ua=x("<div> </div>"),Ea=x('<div class="flex gap-1"></div>'),Ma=x('<div class="flex flex-col gap-2"></div>'),Va=x('<div class="flex-none"><div class="mb-2.5 text-lg font-semibold">Sample details</div> <!></div> <div class="flex h-full min-h-0 flex-col space-y-4 overflow-y-auto dark:[color-scheme:dark]"><!> <!> <!></div>',1);function Za($,e){V(e,!0);const c=e.sample.tags,S=p(()=>e.sample.annotations?[...e.sample.annotations].sort((t,h)=>t.annotation_label.annotation_label_name.localeCompare(h.annotation_label.annotation_label_name)):[]);De($,{className:"h-full",children:(t,h)=>{Le(t,{className:"h-full flex flex-col",children:(f,k)=>{var H=Va(),N=_(H),I=l(u(N),2);Ze(I,{class:"mb-4 bg-border-hard"}),o(N);var A=l(N,2),w=u(A);{var P=b=>{Pe(b,{title:"Tags",icon:Sa,children:(g,L)=>{var d=Ea();ce(d,21,()=>c,ye,(i,m)=>{var s=Ua(),v=u(s,!0);o(s),j(C=>{Ue(s,1,C),me(v,a(m).name)},[()=>la(da("inline rounded-lg bg-card px-2 py-2 text-xs"))]),n(i,s)}),o(d),n(g,d)}})};D(w,b=>{c&&c.length>0&&b(P)})}var y=l(w,2);{var B=b=>{Pe(b,{title:"Annotations",children:(g,L)=>{var d=Ma();ce(d,21,()=>a(S),ye,(i,m)=>{const s=p(()=>e.selectedAnnotationId===a(m).annotation_id);ia(i,{get annotation(){return a(m)},get isSelected(){return a(s)},onClick:()=>e.onAnnotationClick(a(m).annotation_id),onClickCenterIcon:v=>{v.stopPropagation(),e.onClickCenterIcon(a(m).annotation_id)},get onUpdate(){return e.onUpdate}})}),o(d),n(g,d)}})};D(y,b=>{a(S).length>0&&b(B)})}var U=l(y,2);ba(U,{get sample(){return e.sample}}),o(A),n(f,H)},$$slots:{default:!0}})},$$slots:{default:!0}}),Z()}var za=x('<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 vt($,e){V(e,!0);const c=p(()=>le.params.sampleId),S=le.data.dataset,t=p(()=>Number(le.params.sampleIndex));var h=za(),f=u(h),k=u(f);La(k,{get sampleId(){return a(c)},dataset:S,get sampleIndex(){return a(t)},children:(H,N)=>{var I=M(),A=_(I);{var w=P=>{var y=M(),B=_(y);ee(B,()=>e.children),n(P,y)};D(A,P=>{e.children&&P(w)})}n(H,I)},$$slots:{default:!0}}),o(f),o(h),n($,h),Z()}export{vt as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"../chunks/H7C68rOM.js";import{l as a}from"../chunks/BJXwVxaE.js";import{r as s}from"../chunks/B90CZVMX.js";const l=async()=>{const{data:t,error:o}=await a(),r=t==null?void 0:t.dataset_id;if(o||!r)throw o;s(307,e.toSamples(r))},p=Object.freeze(Object.defineProperty({__proto__:null,load:l},Symbol.toStringTag,{value:"Module"}));export{p as universal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../chunks/CWj6FrbW.js";import{p as f,u as $,a as h,g as o,d as r}from"../chunks/l7KrR96u.js";import{s as S,a as i}from"../chunks/XO7A28GO.js";import{A as T}from"../chunks/CvOmgdoc.js";import{u as _}from"../chunks/vC4nQVEB.js";import"../chunks/CxtLVaYz.js";import"../chunks/D6su9Aln.js";import"../chunks/Bx1xMsFy.js";import"../chunks/Bsi3UGy5.js";import"../chunks/69_IOA4Y.js";import{u as G}from"../chunks/DIRAtgl0.js";import"../chunks/BJXwVxaE.js";function k(p,t){f(t,!0);const[e,m]=S(),n=()=>i(l,"$lastGridType",e),s=()=>i(d,"$sampleSize",e),{datasetId:a,sampleSize:d,selectedAnnotationFilterIds:c}=t.data,{lastGridType:l}=_(),u=r(()=>G({dataset_id:a})),g=r(()=>o(u).clearTagsSelected);$(()=>{n()!=="annotations"&&o(g)()}),T(p,{get itemHeight(){return s().height},get itemWidth(){return s().width},dataset_id:a,selectedAnnotationFilterIds:c}),h(),m()}export{k as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as T,f as B,n as Et,a as j,w as bt,l as V,$ as ct,g as a,d,c as f,r as m,s as S,t as F,L as Dt,V as Tt,ax as gt}from"../chunks/l7KrR96u.js";import{c as jt}from"../chunks/BJXwVxaE.js";import"../chunks/CWj6FrbW.js";import{c as Z,a as _,t as k,n as Ht}from"../chunks/Bu7uvVrG.js";import{i as O,a as D,s as q}from"../chunks/XO7A28GO.js";import{e as ut}from"../chunks/DjfY96ND.js";import{I as Rt,s as J,K as Ut,L as at,M as Ft,N as Ot,O as zt,P as Gt,p as xt,F as Kt,e as Wt,l as qt,h as Vt,C as It,z as At,E as wt,u as Zt,d as Jt,S as Qt,Q as Yt,a as Xt}from"../chunks/CvOmgdoc.js";import{g as tt}from"../chunks/CxtLVaYz.js";import{u as St}from"../chunks/vC4nQVEB.js";import{f as ht,S as ta}from"../chunks/D5-A_Ffd.js";import{r as U}from"../chunks/H7C68rOM.js";import"../chunks/D6su9Aln.js";import"../chunks/Bx1xMsFy.js";import{p as z}from"../chunks/Bsi3UGy5.js";import"../chunks/69_IOA4Y.js";import{S as aa}from"../chunks/B2FVR0s0.js";import{S as na,B as ea,a as oa,b as X,c as lt,H as sa,d as dt,D as ra,e as ia,Z as la,g as da,u as ca}from"../chunks/nAHhluT7.js";import{S as ua}from"../chunks/BylOuP6i.js";import{s as va,r as ma,a as fa}from"../chunks/D98V7j6A.js";import{s as W}from"../chunks/D6RI2Zrd.js";import{C as _a}from"../chunks/CDnpyLsT.js";import{s as pa}from"../chunks/DIRAtgl0.js";function ga(v,t){T(t,!0);let r=ma(t,["$$slots","$$events","$$legacy"]);Rt(v,va({name:"square-dashed"},()=>r,{iconNode:[["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"}]],children:(n,o)=>{var s=Z(),p=B(s);pa(p,()=>t.children??Et),_(n,s)},$$slots:{default:!0}})),j()}const ha=async({dataset_id:v,cursor:t=0,limit:r=10,annotation_label_ids:i,tag_ids:n})=>{const o={data:[],error:void 0};try{const s=await jt.GET("/api/datasets/{dataset_id}/annotations",{params:{path:{dataset_id:v},query:{annotation_label_ids:i,tag_ids:n,cursor:t,limit:r}}});if(s.error)throw new Error(JSON.stringify(s.error,null,2));if(!s.data)throw new Error("No data");o.data=s.data.data}catch(s){o.error="Error loading annotations: "+String(s)}return o},ba=({annotationIndex:v,...t})=>{const r=bt({isLoading:!1});return(async()=>{r.update(n=>({...n,isLoading:!0}));try{const n=await ha({cursor:v>0?v-1:0,limit:3,...t}),o=n.data.findIndex(e=>e.annotation_id===t.currentAnnotationId),s=n.data[o+1],p=n.data[o-1];r.update(e=>({...e,isLoading:!1,error:n.error?String(n.error):void 0,data:n.error?void 0:{annotationNext:s,annotationPrevious:p}}))}catch(n){r.update(o=>({...o,isLoading:!1,error:String(n)}))}})(),r},xa=async({parent:v,params:{dataset_id:t,annotationId:r,annotationIndex:i}})=>{const{annotationsSelectedTagsIds:n,annotationsSelectedAnnotationLabelsIds:o,dataset:s}=await v(),p=parseInt(i,10),e=bt();if(!s)throw new Error("Dataset data not found");return ba({annotationIndex:p,dataset_id:t,currentAnnotationId:r,annotation_label_ids:Array.from(V(o)),tag_ids:Array.from(V(n))}).subscribe(({data:L})=>{e.set(L)}),{annotationAdjacents:e,annotationIndex:p,annotationId:r,dataset:s}},gn=Object.freeze(Object.defineProperty({__proto__:null,load:xa},Symbol.toStringTag,{value:"Module"}));function Ia(v,t){T(t,!0);const[r,i]=q(),n=()=>D(a(s),"$annotationAdjacents",r),o=d(()=>z.data.annotationIndex),s=d(()=>z.data.annotationAdjacents),p=()=>{n().annotationNext&&tt(U.toSampleWithAnnotation({datasetId:n().annotationNext.dataset_id,sampleId:n().annotationNext.sample_id,annotationId:n().annotationNext.annotation_id,annotationIndex:a(o)+1}))},e=()=>{n().annotationPrevious&&tt(U.toSampleWithAnnotation({datasetId:n().annotationPrevious.dataset_id,sampleId:n().annotationPrevious.sample_id,annotationId:n().annotationPrevious.annotation_id,annotationIndex:a(o)-1}))},L=g=>{switch(g.key){case"ArrowRight":p();break;case"ArrowLeft":e();break}};var x=Z();ut("keydown",ct,L);var $=B(x);{var I=g=>{const P=d(()=>!!n().annotationPrevious),y=d(()=>!!n().annotationNext);ua(g,{get hasPrevious(){return a(P)},get hasNext(){return a(y)},onPrevious:e,onNext:p})};O($,g=>{n()&&g(I)})}_(v,x),j(),i()}const Aa={object_detection:"Object Detection",bbox:"Bounding Box",instance_segmentation:"Instance Segmentation",semantic_segmentation:"Semantic Segmentation",classification:"Classification"};var wa=k('<span class="text-sm"> </span> <span class="break-all text-sm"> </span>',1);function Sa(v,t){var r=wa(),i=B(r),n=f(i,!0);m(i);var o=S(i,2),s=f(o,!0);m(o),F(()=>{W(n,t.label),J(o,"data-testid",`annotation-metadata-${t.id}`),W(s,t.value)}),_(v,r)}var $a=k('<span class="break-all text-sm"> </span>'),ya=k('<span class="text-sm"> </span> <!>',1);function ka(v,t){T(t,!0);const[r,i]=q(),n=()=>D(s,"$result",r),o=()=>D(t.isEditingMode,"$isEditingMode",r),s=Ut(),{updateAnnotation:p}=at({datasetId:t.datasetId,annotationId:t.annotationId,onUpdate:t.onUpdate}),e=d(()=>zt(n().data||[])),L=d(()=>{const A=a(e).find(c=>c.value===t.value);return A||{value:t.value,label:t.value}});var x=ya(),$=B(x),I=f($,!0);m($);var g=S($,2);{var P=A=>{Ft(A,{get items(){return a(e)},get value(){return a(L)},name:"annotation-label",placeholder:"Select a label",onSelect:l=>{p({annotation_id:t.annotationId,dataset_id:t.datasetId,label_name:l.value})},notFound:(l,u)=>{let h=()=>u==null?void 0:u().inputValue;Ot(l,{get label(){return h()}})},$$slots:{notFound:!0}})},y=A=>{var c=$a();J(c,"data-testid","annotation-metadata-label");var l=f(c,!0);m(c),F(()=>W(l,t.value)),_(A,c)};O(g,A=>{o()?A(P):A(y,!1)})}F(()=>W(I,t.label)),_(v,x),j(),i()}var Pa=k('<div class="flex flex-col gap-4"><div class="grid grid-cols-[6rem_1fr] gap-y-3 text-diffuse-foreground"></div></div>');function Ma(v,t){T(t,!0);const[r,i]=q(),n=()=>D(a(p),"$annotationResp",r),{datasetId:o}=z.data,s=d(()=>at({datasetId:o,annotationId:t.annotationId})),p=d(()=>a(s).annotation);let e=d(()=>n().data);const L=d(qt),x=d(()=>a(L).taskMap),$=d(()=>a(e)&&a(e).annotation_task_id&&V(a(x)).has(a(e).annotation_task_id)?V(a(x)).get(a(e).annotation_task_id).is_prediction:!1),I=d(()=>{var l,u;if(!a(e))return[];let c=[{id:"label",label:"Label:",value:(u=(l=a(e))==null?void 0:l.annotation_label)==null?void 0:u.annotation_label_name},{id:"type",label:"Type:",value:Aa[a(e).annotation_type]||"Unknown"},{id:"status",label:"Status:",value:a($)?"Prediction":"Ground Truth"}];if(a(e)&&!Gt(a(e))){const{height:h,width:M}=xt(a(e));c=[{id:"height",label:"Height:",value:ht(Math.round(h))+"px"},{id:"width",label:"Width:",value:ht(Math.round(M))+"px"},...c]}return c}),{isEditingMode:g}=z.data.globalStorage;var P=Z(),y=B(P);{var A=c=>{Kt(c,{title:"Annotation details",children:(l,u)=>{var h=Pa(),M=f(h);Wt(M,21,()=>a(I),({label:N,value:b,id:C})=>N,(N,b)=>{let C=()=>a(b).label,E=()=>a(b).value,H=()=>a(b).id;var G=Z(),nt=B(G);{var Q=w=>{ka(w,{get onUpdate(){return t.onUpdate},get annotationId(){return t.annotationId},datasetId:o,get label(){return C()},get value(){return E()},isEditingMode:g})},et=w=>{Sa(w,{get label(){return C()},get id(){return H()},get value(){return E()}})};O(nt,w=>{H()==="label"&&g?w(Q):w(et,!1)})}_(N,G)}),m(M),m(h),_(l,h)}})};O(y,c=>{a(I).length>0&&c(A)})}_(v,P),j(),i()}var Na=k('<!> <h2 class="py-2 text-lg font-semibold"><a>Check all sample annotations</a></h2>',1),Ca=k('<div class="flex h-full w-full items-center justify-center"><!></div>'),Ba=k('<div class="flex h-full min-h-0 flex-col space-y-4 overflow-hidden dark:[color-scheme:dark]"><!> <!></div>');function La(v,t){T(t,!0);const{datasetId:r}=z.data;let i=Tt(void 0);at({datasetId:r,annotationId:t.annotationId}).annotation.subscribe(e=>{e.isSuccess&&Dt(i,fa(e.data.sample))});const o=Vt(),[s,p]=o;It(v,{className:"h-full",children:(e,L)=>{At(e,{className:"h-full flex flex-col",children:(x,$)=>{var I=Ba(),g=f(I);Ma(g,{get annotationId(){return t.annotationId},get onUpdate(){return t.onUpdate}});var P=S(g,2);{var y=c=>{var l=Na(),u=B(l);na(u,{get sample(){return a(i)},showCustomMetadata:!1});var h=S(u,2),M=f(h);m(h),F(N=>J(M,"href",N),[()=>s(U.toSample({sampleId:a(i).sample_id,datasetId:a(i).dataset_id}),void 0)]),_(c,l)},A=c=>{var l=Ca(),u=f(l);wt(u,{size:"large",align:"center"}),m(l),_(c,l)};O(P,c=>{a(i)?c(y):c(A,!1)})}m(I),_(x,I)},$$slots:{default:!0}})},$$slots:{default:!0}}),j()}var Ea=k('<!> <span class="hidden sm:inline">Home</span>',1),Da=k('<!> <span class="max-w-[150px] truncate"> </span>',1),Ta=k('<!> <span class="hidden sm:inline">Annotations</span>',1),ja=k('<!> <span class="max-w-[200px] truncate"> </span>',1),Ha=k("<!> <!> <!> <!> <!> <!> <!>",1);function Ra(v,t){T(t,!0);const[r,i]=q(),n=()=>D(o,"$annotationsTotalCount",r),{annotationsTotalCount:o}=St();ea(v,{class:"mb-2",children:(s,p)=>{oa(s,{children:(e,L)=>{var x=Ha(),$=B(x);X($,{children:(l,u)=>{const h=d(()=>U.toHome());lt(l,{get href(){return a(h)},class:"flex items-center gap-2",children:(M,N)=>{var b=Ea(),C=B(b);sa(C,{class:"h-4 w-4"}),gt(2),_(M,b)},$$slots:{default:!0}})},$$slots:{default:!0}});var I=S($,2);dt(I,{});var g=S(I,2);X(g,{children:(l,u)=>{const h=d(()=>U.toAnnotations(t.dataset.dataset_id));lt(l,{get href(){return a(h)},class:"flex items-center gap-2",get title(){return t.dataset.directory},children:(M,N)=>{var b=Da(),C=B(b);ra(C,{class:"h-4 w-4"});var E=S(C,2),H=f(E,!0);m(E),F(()=>{J(E,"title",t.dataset.directory),W(H,t.dataset.name)}),_(M,b)},$$slots:{default:!0}})},$$slots:{default:!0}});var P=S(g,2);dt(P,{});var y=S(P,2);X(y,{children:(l,u)=>{const h=d(()=>U.toAnnotations(t.dataset.dataset_id));lt(l,{get href(){return a(h)},class:"flex items-center gap-2",children:(M,N)=>{var b=Ta(),C=B(b);_a(C,{class:"h-4 w-4"}),gt(2),_(M,b)},$$slots:{default:!0}})},$$slots:{default:!0}});var A=S(y,2);dt(A,{});var c=S(A,2);X(c,{children:(l,u)=>{ia(l,{class:"flex items-center gap-2",children:(h,M)=>{var N=ja(),b=B(N);ga(b,{class:"h-4 w-4"});var C=S(b,2),E=f(C);m(C),F(()=>W(E,`Annotation ${t.annotationIndex+1} of ${n()??""}`)),_(h,N)},$$slots:{default:!0}})},$$slots:{default:!0}}),_(e,x)},$$slots:{default:!0}})},$$slots:{default:!0}}),j(),i()}var Ua=Ht("<image></image><g><!></g>",1),Fa=k('<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>'),Oa=k('<div class="flex h-full w-full items-center justify-center"><!></div>'),za=k('<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 Ga(v,t){T(t,!0);const[r,i]=q(),n=()=>D(a(l),"$annotationResp",r),o=()=>D(e,"$selectedSampleAnnotationCropIds",r),s=()=>D(L,"$isHidden",r),{toggleSampleAnnotationCropSelection:p,selectedSampleAnnotationCropIds:e}=St(),{isHidden:L,handleKeyEvent:x}=Zt(),{settingsStore:$}=Jt(),I=" ",g=V($).key_go_back,P=()=>{var w;(w=t.sample)!=null&&w.dataset_id?tt(U.toAnnotations(t.sample.dataset_id)):tt("/")},y=w=>{switch(w.key){case g:P();break;case I:w.preventDefault(),p(t.annotationId);break}x(w)},A=z.data.datasetId,c=d(()=>at({datasetId:A,annotationId:t.annotationId})),l=d(()=>a(c).annotation);let u=d(()=>n().data),h=d(()=>{var w,ot;return da(((ot=(w=a(u))==null?void 0:w.sample)==null?void 0:ot.sample_id)||"")}),M=d(()=>a(u)?xt(a(u)):void 0);var N=za();ut("keydown",ct,y),ut("keyup",ct,x);var b=f(N),C=f(b);Ra(C,{get dataset(){return t.dataset},get annotationIndex(){return t.annotationIndex}}),m(b);var E=S(b,2);ta(E,{class:"mb-4 bg-border-hard"});var H=S(E,2),G=f(H),nt=f(G);It(nt,{className:"h-full",children:(w,ot)=>{At(w,{className:"h-full",children:($t,Wa)=>{var vt=Z(),yt=B(vt);{var kt=K=>{var R=Fa(),Y=f(R),st=f(Y),Mt=f(st);const Nt=d(()=>o().has(t.annotationId));Qt(Mt,{onSelect:()=>p(t.annotationId),get isSelected(){return a(Nt)}}),m(st);var mt=S(st,2);Ia(mt,{});var Ct=S(mt,2);la(Ct,{get width(){return a(u).sample.width},get height(){return a(u).sample.height},get boundingBox(){return a(M)},children:(Bt,qa)=>{var ft=Ua(),_t=B(ft),rt=S(_t);let pt;var Lt=f(rt);Yt(Lt,()=>a(u).annotation_id,it=>{aa(it,{get annotation(){return a(u)},showLabel:!0,get imageWidth(){return a(u).sample.width}})}),m(rt),F(it=>{J(_t,"href",a(h)),pt=Xt(rt,0,"",null,pt,it)},[()=>({invisible:s()})]),_(Bt,ft)},$$slots:{default:!0}}),m(Y),m(R),_(K,R)},Pt=K=>{var R=Oa(),Y=f(R);wt(Y,{size:"large",align:"center"}),m(R),_(K,R)};O(yt,K=>{a(u)?K(kt):K(Pt,!1)})}_($t,vt)},$$slots:{default:!0}})},$$slots:{default:!0}}),m(G);var Q=S(G,2),et=f(Q);La(et,{get annotationId(){return t.annotationId}}),m(Q),m(H),m(N),_(v,N),j(),i()}var Ka=k('<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 hn(v,t){T(t,!0);const[r,i]=q(),n=()=>D(a(x),"$sample",r),o=d(()=>t.data.annotationId),s=d(()=>t.data.dataset),p=d(()=>t.data.annotationIndex),{sampleId:e}=z.params,L=d(()=>ca({sampleId:e,datasetId:a(s).dataset_id})),x=d(()=>a(L).sample);var $=Ka(),I=f($),g=f(I);{var P=y=>{Ga(y,{get annotationId(){return a(o)},get annotationIndex(){return a(p)},get dataset(){return a(s)},get sample(){return n().data}})};O(g,y=>{n().data&&a(o)&&a(s)&&y(P)})}m(I),m($),_(v,$),j(),i()}export{hn as component,gn as universal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../chunks/CWj6FrbW.js";import{s as n,a as d}from"../chunks/XO7A28GO.js";import"../chunks/CvOmgdoc.js";import"../chunks/vC4nQVEB.js";import"../chunks/CxtLVaYz.js";import"../chunks/D6su9Aln.js";import"../chunks/Bx1xMsFy.js";import"../chunks/Bsi3UGy5.js";import"../chunks/69_IOA4Y.js";import"../chunks/BJXwVxaE.js";import{S as l}from"../chunks/CcaPhhk3.js";function I(e,o){const[s,i]=n(),t=()=>d(a,"$sampleSize",s),{datasetId:r,sampleSize:a,selectedAnnotationFilterIds:p,globalStorage:{textEmbedding:m}}=o.data;l(e,{get sampleHeight(){return t().height},get sampleWidth(){return t().width},textEmbedding:m,dataset_id:r,selectedAnnotationFilterIds:p}),i()}export{I as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"1756908241758"}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" dir="ltr" class="dark">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" href="/favicon.png" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
|
|
8
|
+
<link rel="modulepreload" href="/_app/immutable/entry/start.0o1H7wM9.js">
|
|
9
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/CxtLVaYz.js">
|
|
10
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/l7KrR96u.js">
|
|
11
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/DIeogL5L.js">
|
|
12
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/CYgJF_JY.js">
|
|
13
|
+
<link rel="modulepreload" href="/_app/immutable/entry/app.CjnvpsmS.js">
|
|
14
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/D98V7j6A.js">
|
|
15
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/XO7A28GO.js">
|
|
16
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/DOlTMNyt.js">
|
|
17
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/CWj6FrbW.js">
|
|
18
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/69_IOA4Y.js">
|
|
19
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/C8I8rFJQ.js">
|
|
20
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/D6RI2Zrd.js">
|
|
21
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/DjfY96ND.js">
|
|
22
|
+
<link rel="modulepreload" href="/_app/immutable/chunks/Bu7uvVrG.js">
|
|
23
|
+
</head>
|
|
24
|
+
<body data-sveltekit-preload-data="hover" class="flex h-screen w-screen flex-col dark:bg-black">
|
|
25
|
+
<div style="display: contents">
|
|
26
|
+
<script>
|
|
27
|
+
{
|
|
28
|
+
__sveltekit_vpwkcc = {
|
|
29
|
+
base: ""
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const element = document.currentScript.parentElement;
|
|
33
|
+
|
|
34
|
+
Promise.all([
|
|
35
|
+
import("/_app/immutable/entry/start.0o1H7wM9.js"),
|
|
36
|
+
import("/_app/immutable/entry/app.CjnvpsmS.js")
|
|
37
|
+
]).then(([kit, app]) => {
|
|
38
|
+
kit.start(app, element);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
</div>
|
|
43
|
+
</body>
|
|
44
|
+
</html>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Example of how to use the DatasetLoader class."""
|
|
2
|
+
|
|
3
|
+
from environs import Env
|
|
4
|
+
|
|
5
|
+
from lightly_studio import DatasetLoader
|
|
6
|
+
|
|
7
|
+
# Read environment variables
|
|
8
|
+
env = Env()
|
|
9
|
+
env.read_env()
|
|
10
|
+
|
|
11
|
+
# Create a DatasetLoader instance
|
|
12
|
+
loader = DatasetLoader()
|
|
13
|
+
|
|
14
|
+
# Define the path to the dataset (folder containing data.yaml)
|
|
15
|
+
dataset_path = env.path("DATASET_PATH", "/path/to/your/yolo/dataset/data.yaml")
|
|
16
|
+
|
|
17
|
+
# Load YOLO dataset using data.yaml path
|
|
18
|
+
loader.from_yolo(
|
|
19
|
+
str(dataset_path),
|
|
20
|
+
input_split=env.str("LIGHTLY_STUDIO_DATASET_SPLIT", "test"),
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
loader.start_gui()
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
"""Example script demonstrating metadata capabilities.
|
|
2
|
+
|
|
3
|
+
This script shows how to:
|
|
4
|
+
1. Load an existing dataset using DatasetLoader
|
|
5
|
+
2. Add metadata to all samples using bulk operations
|
|
6
|
+
3. Add metadata to individual samples
|
|
7
|
+
4. Filter samples using various metadata types
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import random
|
|
13
|
+
import time
|
|
14
|
+
from uuid import UUID
|
|
15
|
+
|
|
16
|
+
from environs import Env
|
|
17
|
+
from sqlmodel import Session
|
|
18
|
+
|
|
19
|
+
from lightly_studio import DatasetLoader
|
|
20
|
+
from lightly_studio.api.db import db_manager
|
|
21
|
+
from lightly_studio.metadata.gps_coordinate import GPSCoordinate
|
|
22
|
+
from lightly_studio.models.dataset import DatasetTable
|
|
23
|
+
from lightly_studio.resolvers import (
|
|
24
|
+
metadata_resolver,
|
|
25
|
+
sample_resolver,
|
|
26
|
+
)
|
|
27
|
+
from lightly_studio.resolvers.metadata_resolver.metadata_filter import Metadata
|
|
28
|
+
from lightly_studio.resolvers.samples_filter import SampleFilter
|
|
29
|
+
|
|
30
|
+
# Environment variables
|
|
31
|
+
env = Env()
|
|
32
|
+
env.read_env()
|
|
33
|
+
dataset_path = env.path("DATASET_PATH", "/path/to/your/yolo/dataset/data.yaml")
|
|
34
|
+
LIGHTLY_STUDIO_DATASET_SPLIT = env.str("LIGHTLY_STUDIO_DATASET_SPLIT", "test")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def load_existing_dataset() -> tuple[DatasetTable, list[UUID], DatasetLoader]:
|
|
38
|
+
"""Load an existing dataset using DatasetLoader.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
Tuple of (dataset, sample_ids, loader).
|
|
42
|
+
"""
|
|
43
|
+
print(" Loading existing dataset...")
|
|
44
|
+
|
|
45
|
+
loader = DatasetLoader()
|
|
46
|
+
dataset = loader.from_yolo(
|
|
47
|
+
str(dataset_path),
|
|
48
|
+
input_split=LIGHTLY_STUDIO_DATASET_SPLIT,
|
|
49
|
+
)
|
|
50
|
+
# Get all sample IDs from the dataset
|
|
51
|
+
samples = dataset.get_samples()
|
|
52
|
+
sample_ids = [s.sample_id for s in samples]
|
|
53
|
+
|
|
54
|
+
print(f"✅ Loaded dataset with {len(sample_ids)} samples")
|
|
55
|
+
return dataset, sample_ids, loader
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def add_bulk_metadata(session: Session, sample_ids: list[UUID]) -> None:
|
|
59
|
+
"""Add metadata to all samples using bulk operations."""
|
|
60
|
+
print("\n Adding bulk metadata to all samples...")
|
|
61
|
+
|
|
62
|
+
# Prepare bulk metadata with random values
|
|
63
|
+
sample_metadata = []
|
|
64
|
+
for sample_id in sample_ids:
|
|
65
|
+
# Generate random metadata
|
|
66
|
+
temp = random.randint(10, 40)
|
|
67
|
+
loc = random.choice(["city", "rural", "mountain", "coastal", "desert"])
|
|
68
|
+
lat = random.uniform(-90.0, 90.0)
|
|
69
|
+
lon = random.uniform(-180.0, 180.0)
|
|
70
|
+
gps_coord = GPSCoordinate(lat=lat, lon=lon)
|
|
71
|
+
confidence = random.uniform(0.5, 1.0)
|
|
72
|
+
is_processed = random.choice([True, False])
|
|
73
|
+
|
|
74
|
+
sample_metadata.append(
|
|
75
|
+
(
|
|
76
|
+
sample_id,
|
|
77
|
+
{
|
|
78
|
+
"temperature": temp,
|
|
79
|
+
"location": loc,
|
|
80
|
+
"gps_coordinates": gps_coord,
|
|
81
|
+
"confidence": confidence,
|
|
82
|
+
"is_processed": is_processed,
|
|
83
|
+
"batch_id": "bulk_001", # Mark as bulk-added
|
|
84
|
+
},
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# Bulk insert metadata
|
|
89
|
+
start_time = time.time()
|
|
90
|
+
metadata_resolver.bulk_set_metadata(session, sample_metadata)
|
|
91
|
+
elapsed_time = time.time() - start_time
|
|
92
|
+
|
|
93
|
+
print(f"✅ Added metadata to {len(sample_ids)} samples in {elapsed_time:.2f}s")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def add_individual_metadata(session: Session, sample_ids: list[UUID]) -> None:
|
|
97
|
+
"""Add metadata to individual samples."""
|
|
98
|
+
print("\n Adding individual metadata to specific samples...")
|
|
99
|
+
|
|
100
|
+
# Add metadata to first 5 samples individually
|
|
101
|
+
for i, sample_id in enumerate(sample_ids[:5]):
|
|
102
|
+
# Add some specific metadata
|
|
103
|
+
metadata_resolver.set_value_for_sample(
|
|
104
|
+
session=session,
|
|
105
|
+
sample_id=sample_id,
|
|
106
|
+
key="special_metadata",
|
|
107
|
+
value=f"sample_{i + 1}_special",
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
metadata_resolver.set_value_for_sample(
|
|
111
|
+
session=session,
|
|
112
|
+
sample_id=sample_id,
|
|
113
|
+
key="priority",
|
|
114
|
+
value=random.randint(1, 10),
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
metadata_resolver.set_value_for_sample(
|
|
118
|
+
session=session,
|
|
119
|
+
sample_id=sample_id,
|
|
120
|
+
key="list",
|
|
121
|
+
value=[1, 2, 3],
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
metadata_resolver.set_value_for_sample(
|
|
125
|
+
session=session,
|
|
126
|
+
sample_id=sample_id,
|
|
127
|
+
key="custom_gps",
|
|
128
|
+
value=GPSCoordinate(
|
|
129
|
+
lat=40.7128 + i * 0.1, # Slightly different coordinates
|
|
130
|
+
lon=-74.0060 + i * 0.1,
|
|
131
|
+
),
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
print(f"✅ Added individual metadata to {min(5, len(sample_ids))} samples")
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def demonstrate_bulk_metadata_filters(dataset: DatasetTable) -> None:
|
|
138
|
+
"""Demonstrate filtering with bulk-added metadata."""
|
|
139
|
+
print("\n Bulk Metadata Filters:")
|
|
140
|
+
print("=" * 50)
|
|
141
|
+
|
|
142
|
+
# Filter by temperature
|
|
143
|
+
print("\n1. Filter by temperature > 25:")
|
|
144
|
+
filter_temp = SampleFilter(metadata_filters=[Metadata("temperature") > 25]) # noqa PLR2004
|
|
145
|
+
samples = dataset.get_samples(filters=filter_temp)
|
|
146
|
+
print(f" Found {len(samples)} samples with temperature > 25")
|
|
147
|
+
for sample in samples[:3]: # Show first 3
|
|
148
|
+
print(f" {sample.file_name}: {sample['temperature']}")
|
|
149
|
+
|
|
150
|
+
# Filter by location
|
|
151
|
+
print("\n2. Filter by location == 'city':")
|
|
152
|
+
filter_location = SampleFilter(metadata_filters=[Metadata("location") == "city"])
|
|
153
|
+
samples = dataset.get_samples(filters=filter_location)
|
|
154
|
+
print(f" Found {len(samples)} samples from cities")
|
|
155
|
+
for sample in samples[:3]: # Show first 3
|
|
156
|
+
print(f" {sample.file_name}: {sample['location']}")
|
|
157
|
+
|
|
158
|
+
# Filter by GPS coordinates
|
|
159
|
+
print("\n3. Filter by latitude > 0° (Northern hemisphere):")
|
|
160
|
+
filter_lat = SampleFilter(metadata_filters=[Metadata("gps_coordinates.lat") > 0])
|
|
161
|
+
samples = dataset.get_samples(filters=filter_lat)
|
|
162
|
+
print(f" Found {len(samples)} samples in Northern hemisphere")
|
|
163
|
+
for sample in samples[:3]: # Show first 3
|
|
164
|
+
gps = sample["gps_coordinates"]
|
|
165
|
+
print(f" {sample.file_name}: lat={gps.lat:.4f}, lon={gps.lon:.4f}")
|
|
166
|
+
|
|
167
|
+
# Filter by confidence
|
|
168
|
+
print("\n4. Filter by high confidence (> 0.9):")
|
|
169
|
+
filter_confidence = SampleFilter(
|
|
170
|
+
metadata_filters=[Metadata("confidence") > 0.9] # noqa PLR2004
|
|
171
|
+
)
|
|
172
|
+
samples = dataset.get_samples(filters=filter_confidence)
|
|
173
|
+
print(f" Found {len(samples)} samples with confidence > 0.9")
|
|
174
|
+
for sample in samples[:3]: # Show first 3
|
|
175
|
+
print(f" 📸 {sample.file_name}: confidence={sample['confidence']:.3f}")
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def demonstrate_individual_metadata_filters(dataset: DatasetTable) -> None:
|
|
179
|
+
"""Demonstrate filtering with individually-added metadata."""
|
|
180
|
+
print("\n Individual Metadata Filters:")
|
|
181
|
+
print("=" * 50)
|
|
182
|
+
|
|
183
|
+
# Filter by special metadata
|
|
184
|
+
print("\n1. Filter by special metadata (individually added):")
|
|
185
|
+
filter_special = SampleFilter(
|
|
186
|
+
metadata_filters=[Metadata("special_metadata") == "sample_1_special"]
|
|
187
|
+
)
|
|
188
|
+
samples = dataset.get_samples(filters=filter_special)
|
|
189
|
+
print(f" Found {len(samples)} samples with special metadata")
|
|
190
|
+
for sample in samples:
|
|
191
|
+
print(f" {sample.file_name}: {sample['special_metadata']}")
|
|
192
|
+
|
|
193
|
+
# Filter by priority
|
|
194
|
+
print("\n2. Filter by high priority (> 7):")
|
|
195
|
+
filter_priority = SampleFilter(metadata_filters=[Metadata("priority") > 7]) # noqa PLR2004
|
|
196
|
+
samples = dataset.get_samples(filters=filter_priority)
|
|
197
|
+
print(f" Found {len(samples)} samples with priority > 7")
|
|
198
|
+
for sample in samples:
|
|
199
|
+
print(f" {sample.file_name}: priority={sample['priority']}")
|
|
200
|
+
|
|
201
|
+
# Filter by custom GPS
|
|
202
|
+
print("\n3. Filter by custom GPS coordinates:")
|
|
203
|
+
filter_custom_gps = SampleFilter(
|
|
204
|
+
metadata_filters=[Metadata("custom_gps.lat") > 40.8] # noqa PLR2004
|
|
205
|
+
)
|
|
206
|
+
samples = dataset.get_samples(filters=filter_custom_gps)
|
|
207
|
+
print(f" Found {len(samples)} samples with custom GPS lat > 40.8")
|
|
208
|
+
for sample in samples:
|
|
209
|
+
gps = sample["custom_gps"]
|
|
210
|
+
print(f" {sample.file_name}: lat={gps.lat:.4f}, lon={gps.lon:.4f}")
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def demonstrate_combined_filters(dataset: DatasetTable) -> None:
|
|
214
|
+
"""Demonstrate combining multiple filters."""
|
|
215
|
+
print("\n Combined Filters:")
|
|
216
|
+
print("=" * 50)
|
|
217
|
+
|
|
218
|
+
# Multiple conditions
|
|
219
|
+
print("\n1. Find high-confidence, processed, warm images:")
|
|
220
|
+
filter_combined = SampleFilter(
|
|
221
|
+
metadata_filters=[
|
|
222
|
+
Metadata("confidence") > 0.8, # noqa PLR2004
|
|
223
|
+
Metadata("is_processed") == True, # noqa E712
|
|
224
|
+
Metadata("temperature") > 25, # noqa PLR2004
|
|
225
|
+
]
|
|
226
|
+
)
|
|
227
|
+
samples = dataset.get_samples(filters=filter_combined)
|
|
228
|
+
print(f" Found {len(samples)} samples matching all criteria")
|
|
229
|
+
for sample in samples[:3]:
|
|
230
|
+
print(
|
|
231
|
+
f" {sample.file_name}: conf={sample['confidence']:.2f}, "
|
|
232
|
+
f"temp={sample['temperature']}, processed={sample['is_processed']}"
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
# Complex GPS + other filters
|
|
236
|
+
print("\n2. Find northern hemisphere, high-confidence images:")
|
|
237
|
+
filter_gps_combined = SampleFilter(
|
|
238
|
+
metadata_filters=[
|
|
239
|
+
Metadata("gps_coordinates.lat") > 0, # Northern hemisphere
|
|
240
|
+
Metadata("confidence") > 0.85, # noqa PLR2004
|
|
241
|
+
Metadata("location") == "city",
|
|
242
|
+
]
|
|
243
|
+
)
|
|
244
|
+
samples = dataset.get_samples(filters=filter_gps_combined)
|
|
245
|
+
print(f" Found {len(samples)} samples in northern hemisphere cities with high confidence")
|
|
246
|
+
for sample in samples[:3]:
|
|
247
|
+
gps = sample["gps_coordinates"]
|
|
248
|
+
print(f" {sample.file_name}: lat={gps.lat:.4f}, conf={sample['confidence']:.2f}")
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def demonstrate_dictionary_like_access(session: Session, sample_ids: list[UUID]) -> None:
|
|
252
|
+
"""Demonstrate adding metadata using dictionary-like access."""
|
|
253
|
+
print("\n Dictionary-like Metadata Access:")
|
|
254
|
+
print("=" * 50)
|
|
255
|
+
|
|
256
|
+
# Get the first few samples to demonstrate
|
|
257
|
+
samples = sample_resolver.get_many_by_id(session, sample_ids[:2])
|
|
258
|
+
|
|
259
|
+
print("\n1. Adding metadata using sample['key'] = value syntax:")
|
|
260
|
+
|
|
261
|
+
# Add different types of metadata to different samples
|
|
262
|
+
samples[0]["temperature"] = 25
|
|
263
|
+
samples[0]["location"] = "city"
|
|
264
|
+
samples[0]["is_processed"] = True
|
|
265
|
+
samples[0]["confidence"] = 0.95
|
|
266
|
+
print(
|
|
267
|
+
f" {samples[0].file_name}: temp={samples[0]['temperature']}°C, "
|
|
268
|
+
f"location={samples[0]['location']},"
|
|
269
|
+
f" processed={samples[0]['is_processed']}"
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
samples[1]["temperature"] = 15
|
|
273
|
+
samples[1]["location"] = "mountain"
|
|
274
|
+
samples[1]["gps_coordinates"] = GPSCoordinate(lat=40.7128, lon=-74.0060)
|
|
275
|
+
samples[1]["tags"] = ["outdoor", "nature", "landscape"]
|
|
276
|
+
print(
|
|
277
|
+
f" {samples[1].file_name}: temp={samples[1]['temperature']}°C, "
|
|
278
|
+
f"location={samples[1]['location']}, tags={samples[1]['tags']}"
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
# Demonstrate reading metadata
|
|
282
|
+
print("\n2. Reading metadata using sample['key'] syntax:")
|
|
283
|
+
for sample in samples:
|
|
284
|
+
print(f" {sample.file_name}:")
|
|
285
|
+
print(f" Temperature: {sample['temperature']}°C")
|
|
286
|
+
print(f" Location: {sample['location']}")
|
|
287
|
+
gps = sample["gps_coordinates"]
|
|
288
|
+
print(f" GPS: lat={gps.lat:.4f}, lon={gps.lon:.4f}")
|
|
289
|
+
print(f" Tags: {sample['tags']}")
|
|
290
|
+
|
|
291
|
+
# Demonstrate None return for missing keys
|
|
292
|
+
print(" Note: sample['key'] returns None for missing keys")
|
|
293
|
+
missing_value = samples[0]["nonexistent_key"]
|
|
294
|
+
if missing_value is None:
|
|
295
|
+
print(f" sample['nonexistent_key']: {missing_value}")
|
|
296
|
+
|
|
297
|
+
print(f"✅ Added metadata to {len(samples)} samples using dictionary-like access")
|
|
298
|
+
|
|
299
|
+
# Demonstrate schema presentation
|
|
300
|
+
try:
|
|
301
|
+
samples[0]["temperature"] = "string_value" # Invalid type for demonstration
|
|
302
|
+
print(f" ❌ This should not print: {missing_value}")
|
|
303
|
+
except ValueError:
|
|
304
|
+
print(" ✅ Correctly raised ValueError for invalid type")
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def main() -> None:
|
|
308
|
+
"""Main function to demonstrate metadata functionality."""
|
|
309
|
+
try:
|
|
310
|
+
# Load existing dataset
|
|
311
|
+
dataset, sample_ids, loader = load_existing_dataset()
|
|
312
|
+
|
|
313
|
+
with db_manager.session() as session:
|
|
314
|
+
# Add bulk metadata
|
|
315
|
+
add_bulk_metadata(session, sample_ids)
|
|
316
|
+
|
|
317
|
+
# Add individual metadata
|
|
318
|
+
add_individual_metadata(session, sample_ids)
|
|
319
|
+
|
|
320
|
+
# Demonstrate different types of filtering
|
|
321
|
+
demonstrate_bulk_metadata_filters(dataset)
|
|
322
|
+
demonstrate_individual_metadata_filters(dataset)
|
|
323
|
+
demonstrate_combined_filters(dataset)
|
|
324
|
+
demonstrate_dictionary_like_access(session, sample_ids)
|
|
325
|
+
|
|
326
|
+
loader.start_gui()
|
|
327
|
+
|
|
328
|
+
except ValueError as e:
|
|
329
|
+
print(f"❌ Error: {e}")
|
|
330
|
+
print("\n💡 Make sure to set the DATASET_PATH environment variable:")
|
|
331
|
+
print(" export DATASET_PATH=/path/to/your/yolo/dataset/data.yaml")
|
|
332
|
+
print(" export LIGHTLY_STUDIO_DATASET_SPLIT=test")
|
|
333
|
+
except Exception as e:
|
|
334
|
+
print(f"❌ Unexpected error: {e}")
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
if __name__ == "__main__":
|
|
338
|
+
main()
|