#
Wolfram Neural Net Repository

Immediate Computable Access to Neural Net Models

Detect and localize objects in an image

YOLO (You Only Look Once) Version 2 is an object detection model published by Joseph Redmon and Ali Farhadi in December 2016. It is a single-stage architecture that goes straight from image pixels to bounding box coordinates and class probabilities. Compared to its predecessor, it introduces batch normalization, raises the image resolution and switches from direct coordinate prediction to anchor boxes' offsets. On an NVIDIA Titan X, it processes images at 40-90 FPS.

Number of layers: 106 | Parameter count: 51,000,657 | Trained size: 205 MB

- MS-COCO 2014, a dataset for image recognition, object detection, segmentation and captioning, consisting of more than 300,000 images overall.

- This model achieves 48.1% mAP on the MS-COCO 2014 test-dev dataset.

Get the pre-trained net:

In[1]:= |

Out[1]= |

Write an evaluation function to scale the result to the input image size and suppress the least probable detections:

In[2]:= |

In[3]:= |

Define the label list for this model. Integers in the model’s output correspond to elements in the label list:

In[4]:= |

Obtain the detected bounding boxes with their corresponding classes and confidences for a given image:

In[5]:= |

In[6]:= |

Out[6]= |

Inspect which classes are detected:

In[7]:= |

Out[7]= |

In[8]:= |

Out[8]= |

Visualize the detection:

In[9]:= |

Out[9]= |

The network computes 845 bounding boxes, the probability of having an object in each box and the conditioned probability that the object is of any given class:

In[10]:= |

Out[10]= |

Visualize all the boxes predicted by the net scaled by their “objectness” measures:

In[11]:= |

In[12]:= |

Out[12]= |

Visualize all the boxes scaled by the probability that they contain a cat:

In[13]:= |

Out[13]= |

In[14]:= |

Out[14]= |

Superimpose the cat prediction on top of the scaled input received by the net:

In[15]:= |

Out[15]= |

Write a function to apply a custom styling to the result of the detection:

In[16]:= |

Visualize multiple objects, using a different color for each class:

In[17]:= |

In[18]:= |

Out[18]= |

Inspect the number of parameters of all arrays in the net:

In[19]:= |

Out[19]= |

Obtain the total number of parameters:

In[20]:= |

Out[20]= |

Obtain the layer type counts:

In[21]:= |

Out[21]= |

Display the summary graphic:

In[22]:= |

Out[22]= |

Wolfram Language 11.3 (March 2018) or above

- J. Redmon, A. Farhadi, "YOLO9000: Better, Faster, Stronger," arXiv:1612.08242 (2016)
- (available from https://pjreddie.com/darknet/yolov2)
- Rights: Unrestricted use