Overview

I had the opportunity to manipulate CVAT data using Python, so this is a personal note for future reference.

Setup

This time, we will start it using Docker.

gcdidotcckcvelarotnceomhptotspes:u/p/g-idthub.com/cvat-ai/cvat-depth1

Creating an Account

Access http://localhost:8080 and create an account.

Operations with Python

First, install the following library.

pipinstallcvat-sdk

Write the account information in .env.

huposasestrs=nwhaotmrtedp==:<</up/salesorscnwaaolmrhedo>>st:8080

Creating an Instance

ififfiflhupcamrmrrmroosaoppopoopoasesniomommomdtrsf_rrr_nwihupctdtcctid=aogosalovvoomrusesiotjaartoedrtrsesestteiesa=nwnno__qmn.==thaotvnssupveiomrddeo(nooosed=ikksrvvssnt==m..ttei..,upApaasrree=sapoppBbonnesiriiyonvvCrsCt__ts.iionwlcceegrrnaoillls=eoofmreoiiITtnniednaeeOr(..g,tdnnu"ggu(_tteheercd.)ottaooims((tntmot""ifepd"upoinoe)sangvrles(utsrsrnwaCiaotommrinpedofo""nir)))gturPaatticohne,dLAapbieClleideDnatt,aRmeoqdueelsst,apis,exceptions

Creating a Task

t}teparxrsycik:en_'"}####(p#ptsnl]ttr(paa,AWmnaWitembpeooseenacee"""]idkxts'lncasues,cc(k=:saotsluea")"mltcesfrpnE{':eor{}afetx"rindaisicc[:"birxpoae{:ubfe.ontp"t""""efnsct"enmivets.hi'#saunaaryeAo,"f"mtplcep)ptn,f:eauucniih0"bteetc=Eew0[:l_ssaxhfet"smlacbef""y:eolpean"s:pddyips,ce[e_titoT""alccicrrr:"ssaloyeu]linei"e"Aflexn,,tpoenacgeirdtsexC.pttlilteto"inia:i,epksocnueknrttse"_taca*aytlnRppeadeiesq.,asoucuerotmtseraeptasmu"takbt.e:e(drdOte%sauarsttsi\apkvn.u_e"tsdFp%odetracyet)p)iaenpmuotdedlastah,ave

The following result is obtained.

{'''''''''''''''''''aabcdgijlmnoopsssstuussuriudoaoarvwreotuaprssgemi'bbdmgenoguabrdlii_aed:seeearejmrtsga'ggttne'l''nlreecueet:nnres_1:s::ia'cnestteeeadii3'zp:tt_''_d'eec_od,{:'a'__s::s_h'_kdn'''''t:{isttdt:uea':ccuv{,i'''''dio'oatprt:oora'oNfiluu'zra'rtpNd'eNmullunoidars:ean,ae:oa:''opn'ir'nr'sle'gng'/nt:2nlt:dl':es:t'rN:eoe:/eedee'a',,t_:no't'l,d'd',t:'t:N_1nan0:a:do_,a,ehion,a'me,tacdtd0to'namhe,NiNtaae',tnhemet'oooeltt:p't,e't:nnnthei::t':pe'eio'm0/p::',,,ms:e,/0:'net.l}/'N/a.:Ndo,/Salkd8oaclakoaa0ntaotacmt8eelcomaue0,tharulrt/iolurhaiamsh'ao'mpeto,'s}ei(:s,t,(/28t:2t00:80a28802s40084k,/80,sa0//1p/a110iap03,/pi,'ji/}3o/u3,bls,sae2?br22tes2,al/,ss15k?'50_t,0,ia,ds4=k411_1,3i,'d9,=98180307'77}93,8,,ttzziinnffoo==ttzzuuttcc(()))),,

Uploading Images

Images of The Tale of Genji held by the University of Tokyo and Kyoto University are used.

#di]cf#t#(emloarFfairHsIeugeekfsngrriire""nicr_icud_###ceeemme_hhtmledmlwlacttssggtutt_aiaaiettowa_i_pp.urttfgewtge,anencoioo=nrlppieneaenp_tdhnmnnansssl_t_tarreceassBm::eu_w=q_seenadctgeeyei=/srfiufssqtnikoe.tm/lilmaipu_s__=re=g[hh=llollboetcasdfasuuiedieinsyhbtorriIigg[nsuetsnstpolawoesOmgg].sly=ae=eoetnmqe(aiiiaes=cr)t=sul_u_rgnnmp.7lya"etsouefeeggapmD5i=smh=arsos_ffgeoa,efkuteFdltrpuaaendtnia_loa(s_orcc_deatlpdtrlti.snleeu(lR_eiaiceshmgts...rgsef_tphseeaeaesccleqiocaaep,gtt.postiulbl,rcoie(ucl/:_neejitkn_m_isoississsee/spaum(ntppmttcnfteagra)t(aaae(ttohrelge"ccgas.reds)en/eeed,tmaef:_t"ss_a-rt_ru))//fowsdearor[nnrfekaseml-aaostpps)1kkman_aoapa]aa_ea"nrommudep,ssnUuuridieisR#rrlc.neLaa(ttcsg=M11iortFaa99meaann66asatldu//gptusayyeeeserloo_c_ellluidmtyoorfaauvvlytnrs55)aune--)c(atccotlahhnaltaatsyBhrrekye//n.trrtieneedsasst,ImooyOellpvveoaee.bt//jtmmeraaciiitbnnu//t%%eEE33%%8800%%88EE%%EE66%%BBAA%%9900%%EE66%%BB00%%88FF%%EE77%%8899%%AA99%%EE88%%AAAA%%99EE%%EE33%%8800%%88FF((%%EE64%%9BDA%%BA1C%%EE49%%B8A3%%ABCD%%EE55%%AA44%%AA77%%EE55%%AADD%%AA66%%EE76%%B879%%88F0%%EE58%%9904%%8B85%)E.5j%p9gB"%B3%E6%9B%B8%E9%A4%A8%E6%89%80%E8%94%B5).jpg",

Retrieving Label Information

ldpaarbtieanl,ts(_rdaeapstipa_o)innsseta=ncleab=elasp_iasp.iL_aibnesltsaAnpcie(.alpiis_tc(ltiaesnkt_)id=task.id)

The following result is obtained. In particular, note the label id (16 here) and the id of the “score” attribute (also 16 here).

{''''cnproereuxesntvut'il':ot:usNs'1o':,n:e[,N{o'''''''''nachinpsttetoadaauay,tls'mrbspro_:eelkeirp'na_'b'a1:tbi:u:r6_edte,'il''e'nds:as#t''n'f''::1y:f:,3'0N[,}[0Fo]]{fan,}'''''flediimnv's,ednuaa,ef'ptml,a:uaeuutb'el1_l:st6te'_,y'':vp:saec[l'To'u:rr'eue]''e'}:t,,]e,x't,',

Registering Annotations

Prepare a file like the following. The following is used.

https://huggingface.co/spaces/nakamura196/yolov5-char

[]{""ionuptup{}{}{}tu,,,"t:":""""""""""""""""""""""xyxyccnxyxyccnxyxyccnh[mmmmolammmmolammmmolatiiaanamiiaanamiiaanamtnnxxfsennxxfsennxxfsep""""is"""""is"""""is"s::::d":::::d":::::d"::e:e:e:/3232n"3334n"1324n"/2759c0i1740c0i8800c0ih1204e,t9374e,t3276e,tu...."e...."e...."eg3143:m8825:m5456:mg3753"2837"3364"i885300025012180n3716.4590.0443.g440789217886718f818955303524754a346136612215647c854930854359620e852925162839198.716235622636172c,,,,2,,,,0,,,,3o257/176s245p,,,aces/nakamura196/yolov5-char/resolve/main/%E3%80%8E%E6%BA%90%E6%B0%8F%E7%89%A9%E8%AA%9E%E3%80%8F(%E4%BA%AC%E9%83%BD%E5%A4%A7%E5%AD%A6%E6%89%80%E8%94%B5).jpg",

Register the annotations.

pipinstallcvat-sdk

0

As a result, the annotations are reflected as shown below.

(Reference) Bulk Deletion of Tasks

Bulk deletion of tasks can be done as follows.

pipinstallcvat-sdk

1

Summary

This article described how to manipulate CVAT data using Python.

This only covers some of the available features, but I hope this serves as a useful reference.