--- title: "Object detection" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Object detection} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE,eval = FALSE,echo = T) ``` ## Intro The [fastai](https://github.com/fastai/fastai) library simplifies training fast and accurate neural nets using modern best practices. See the fastai website to get started. The library is based on research into deep learning best practices undertaken at ```fast.ai```, and includes "out of the box" support for ```vision```, ```text```, ```tabular```, and ```collab``` (collaborative filtering) models. Original demo by [Zachary](https://github.com/muellerzr/Practical-Deep-Learning-for-Coders-2.0/blob/master/Computer%20Vision/06_Object_Detection.ipynb) ## Dataset Grab data: ```{r} URLs_COCO_TINY() ``` Read ```json``` file and get annotations: ```{r} c(images, lbl_bbox) %<-% get_annotations('coco_tiny/train.json') names(lbl_bbox) = images img2bbox = lbl_bbox ``` ## Dataloader Prepare laoder object: ```{r} get_y = list(function(o) img2bbox[[o$name]][[1]], function(o) as.list(img2bbox[[o$name]][[2]])) coco = DataBlock(blocks = list(ImageBlock(), BBoxBlock(), BBoxLblBlock()), get_items = get_image_files(), splitter = RandomSplitter(), get_y = get_y, item_tfms = Resize(128), batch_tfms = aug_transforms(), n_inp = 1) dls = coco %>% dataloaders('coco_tiny/train') dls %>% show_batch(max_n = 12) ```