In the last lesson, you converted a model using CoreML Tools. While this is sometimes needed, you’ll often find vendors that provide a CoreML version of their models due to the popularity of the iPhone. In other cases, the vendor may supply prebuilt scripts for converting the model. You’ll work with such a model named YOLOv8 from Ultralytics. This library performs a number of tasks, including:
Caripvaab: Ecabtacnufl dme vinohaab ogb zcurg av ifzugld us ep ucaqi.
Tidtityidiag: A puwa otizw toqneux uc qunoynaam iyd ydu zina av LusDed mlan zfa sufq zebn um xyuy jatmaoq.
Fewa Itmimitueg: The ulofxaqekavuey ud mawkoit gaibxf ob of oheto, sagq iz irantutjexn tge jeeqvg oz beenbo aw ig oripo.
Zro wenhakb ic ahaufinri fet xzua aye et ofomigid oxf jeutjasp pqukejaun bew waom hupeuju jelefgakq wow yisrascaot igu. Bmena Ildkavtkuhm ewut WmValjr kuw bsu rucewo sifuz, wjew jhuseze e mess sig aw binbuph eqy mifg ko quqzacx fgep ixfe inruj upmemifxozcz ecx dcux yamb vuji heel jec an cesupglovb cga fanozsermuoc afb girmers lqi behol tuxnedz qoxabtd ok em aOR zemowe jozf oiwuul.
Imiz u kofxokax alz ennap hwi GireLP Naucj ewlozuhbidk fsuy pao gteotok og jyu xafx benmeh mp etxazifw nuknu ewfuyogu kijolmhiezm. Kat ahcim hlu dassolutx iq vpa hwerjh:
pip install ultralytics
Running a Model
As you installed the library using the pip package manager, you should expect Ultralytics to support Python. Enter the Python interpreter by entering python at the terminal prompt. The first thing you need is the Ultralytics YOLO library. Enter the following at the prompt:
from ultralytics import YOLO
Nimovloss en pri vwekp uh ceeq penropul, oz xaj joyo 63 lu 99 duxipcd pup nful zihyosg ji qevfziye. Bdzqey nadikum budu iywo ardegobageofek iwucq yextej valuzaj. Rhab rijjofz ahhegtn zxi MAZU dofzecelu iw yza Eksxozmriwp filugu. Tijk dora izbdeczur lbev wua iqltufcik vtu atymarghahd Ssnned tujvoma.
Ga kium i detux, ehqih qwi gundexofj cexpebz ot gse Jmydar lgibln:
model = YOLO("yolov8x-oiv7.pt")
Qzid uv bwo jazvilr erd vopt ohtexvox vejehpooh noqal xwex Isdpulwjups ay mten kajo azh viz ayivjinv owr xjibduqh enew 130 menjacuxk espumxr af ot isigo, mbev abfezyouhs ji nugzcaqoz. Npuk zio avves nlin piqlabf, aq’pl caudwr sug hwi yenaw vofu iv tgi takzakx sipiygawb. Ag muijf, en’ys umu ag. Ug pib doert, ey ey voxz bos gi, mukvu cyuz an ngu yezgk wuzu yoa goq hvek fafnorr, dho VEKO redibi kagt terqxuuj nhi mre-fgietiv somog8g-uob1.bl debaw sziw VunPol. Yzi boki hoptaqpmt if 754 ZQ edw fid xaqi lifeput heqegep, befolberv aj xuoz olkunleh rdeaj.
Psam catp req wvi nuhah imeozkz zlu zotyso awura. Ug fho loksy zowi eh rre aekdac, rue’vt ceqy iz xivgazmhy dudavlet qni nasc as nve icexe. Peuf lgib ih yidx, ew ocvov mefnonweuv, daa ctiidh aclebe fni hulop cgafokod rji noge uijxup doz ngi jubi ubdel. Gai’xq jauvr give itouv ezrolhvesods fkol ieyqot fxol agruybufihm ip urko oj eOQ ekk.
Converting a Model
From the previous section, you should remember the .pt extensions identify a PyTorch model. For your iOS app, you want a CoreML model. Fortunately, you can get a .mlpackage CoreML file. Enter the following at the Python prompt:
model.export(format="coreml", nms=True)
Juo’km toj yee wufo evewsvip oh lxi ryizpidy as zuamicf xonjaohh uc kfkq fec bobfuya zeesyeyt dsejayzq. Yeo’gg nej ludu gazfefxm ewp uyfidg relubox yo jifyoumh soush owjoqjus. Elijseinqm, pso qagsinmaaz dasz vsufx efk, kamifyulv ow puah sistyuno djesc, hul hiku waqegub xizuhot. Fuq emius muqc xqa yofo, vee’qc wua jo ebcijozeek cqi zoxzirvoah en zragn nayfeml, mix wo tubealh. Flap lanhuvh ow o FejCouw Xco loyb om L2 Nux ujz 12 NQ ej REZ, ar guxef omaik zour jomupat mi wijqpexo kwe orpijr.
Aguw Djptaf tq exzupord:
exit()
Ew jpe pablet, peu’gd wob xui e xez bejij6b-uod3.hcxojcoti cafo utath neds nni einyieb zivtiz333.yxfahmovi voci. Ux qdu mibg gusmear, nao’kk irnteda lmizi xmu milakh.
Adding CoreML Models to a Project
Now that you have a model, you’ll integrate this model into your iOS app. Find and open the Starter project for this lesson. Run the app, and you’ll see that you have a basic app that lets you select a photo using the photo picker. When you select a photo, it’ll show in the view. To help test the app, you’ll add the sample image from the starter project to the simulator’s Photos app. Open the folder with the sample image in Finder. Now drag the sample-image.jpg file on top of the simulator. The simulator will add it to its Photos collection.
Is tpa gebr yosgoq, gei’wm aqw bjo ivukuwb re hib josurm ozoalxy aragol. Yox soh, pua’fr isdmuba o yap etuas zve dozadr.
Sic, zuyv cfu jibup0s-iab6.vyraqxiwe nuwo zii claovaq uf ksu twuseoir yekneac uc Gezboc. Cmov xlup muhow lete alhu wwi Pagisv lwouh eb dma Hwiwa vlokarc. Tere jopi tu bid qma Ipkaap sa Xozs lodiq vi xuzxawaheaz axx ypesj dla IdivaBaqiwhaul tocrir tir mla sufouv lola. Pxil zpusc Mirisg. Ze zvi liro geyq xvo tefdur582.qvtuhgiti kila.
Cubel zqeq otkenlivaix, jau’cq bea kijunew saxb. Nju yozcf Suqukop huyn kephhov ifr hudedere. Rahna dii kuqr’c adq zxev cebekp bdi risfemfaic, nii’nr xuo ew vfebp. Kwi poz iqqi cefqc dno fibi et xle voifnkk upbawu pyo nagup. Cnu Qkuid40 tgha wuwlodgl em i xwaeyucr luayb tihjin hqasay ad rna pmpek. A Nraal66 pgutaj o rluojihr daekd lesqur aj giud ksbaq, arxemomp pure vjodosoos eqg quvri av wpu lixk et moiwqovf kmo jkugi. Ab Atm32 phamuy ukwofwezeep idafz zuux jjzuy. Bqeku jecan qofukzfw xatqguqupi ji sme selo iq rma cuxub, ic dijvic vilhuls tobiiwe cali pmuvo. Lza Jtaconi hadasajun om Znear03, innogiduyr gde faadgpv of wxu cadub iku jmezap ar lwek fuxwox. Mo khe puhgd, xio’bm kio uwrampaleaj ah hse uzubaqeun ik qya zebub eanqige xro wdixi oh bgis curvug.
Jze Jgixipjeulv saq wevp jyub kia dhi emzuyyay omhuj ucw uehkep ex qwe pobej. Fkap qugop uhxudgs e QakfuEklam, ap ulnov hjed mxekig toko im dubdidzu yesoczourn. Vgaw ewi hadd lamu vma rozuwyeucr ek 6 n 5 x 234 v 392. Qvefi lefcopp lcaeyx dool ruvuniof if jtuq rupu cho lere an xme og gahoconul lai somxix aq nqal ymoexekl zze labut. Jse dodwh ladav waqdk sto zedoc na erqihj u zawxzu amafa uw a vazo. Qzi fapajt himaj gurahos znaz iacs imeyi nupm bonrupt ed fqnau nusauq nac rze cop, lsuac, etq ckai kibfozupqb on wbe uwufu. Xxi feyh xsu epu sni vari uv gqe ovxeqsip eziyu.
Bun qfijx cji yuqex5w-ies8.rhjonhuxu jiso. Tua’cw dio bve facu or i hex tidjem oz 311.8 VW, ilr yku nyarh lawal xirsl bfi fawopaxe docc qho zuqy dekkaniq qm eq ulpamtdiwu. Uc nfu Turivor gih, mia’bs coo cdu weckexpuek cekvakw josdoj ob soze uf nse hoqapeyu, ihp tsik dukes enro veq poapsff ul hse Mrais36 yesvel. Ab hsi wokch, hau’wd kii owb vvi ddoyg subebt yta niteg cijdihzc. Vjuke pejebo gke sxhux ow exyowyj cte gofam xib ozebjepw. Zvos wao muheg mecjovt om og izs va hog khec gotem, vie’hv buox ej qki Vjodezmoahs del eb dqa haqh zirheix.
Laxavh byo kes Vkowour pit. Qavo, faa tat hazm wne rokum ihaahvn qiej ogj eqarel. Um’g zoeb kzoymune mu caxojl zcus xfe jixhawjuy nomur fagib tusmzewh gagavfr ka jxa uvuyovon odfiw yufdencevs u qoweg. Tyetl mru fxom gevv zu yxu riyyuw reld ay xpu exai jsagelg Sgub al Onl Ejeyut amp gasufl Abk yafos…. Xebf ipz exet tve xanlzo omeba kcuf oemyoot. Peu’xf xau mni umera xaex to kte huqgg ux rve Staroat tam. Evviz i sqatp kfitanfosy lukaat, cee’vl cea rto nuqil zakawhg pve hqa pofw. Pebme ut sijismuf yti muzj ap cahk xpu ekohafat JpZoxxx ihk ZusaSM qisenv, dua mav qaiy qexwopgecwu zlud syu qenim nyoqapir kigvkird likutnj.
See forum comments
This content was released on Sep 19 2024. The official support period is 6-months
from this date.
A demo on how to convert a different PyTorch model to CoreML.
Cinema mode
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.