SlideShare a Scribd company logo
COCO
COCO
segmentation
Bounding box
Keypoits
Captions
coco
COCO is a large-scale object detection, segmentation, and captioning dataset. COCO has
several features:
So powerful!!
$ sudo apt-get install aria2
$ aria2c -c http://msvocds.blob.core.windows.net/annotations-1-0-3/instances_train-
val2014.zip
$ aria2c -c http://msvocds.blob.core.windows.net/coco2014/train2014.zip
$ aria2c -c http://msvocds.blob.core.windows.net/coco2014/val2014.zip
$ aria2c -c http://msvocds.blob.core.windows.net/coco2014/test2014.zip
Download COCO dataset (2014)
Download COCO dataset (2017)
$ sudo apt-get install aria2
$ aria2c -c http://msvocds.blob.core.windows.net/annotations/instances_train-
val2017.zip
$ aria2c -c http://images.cocodataset.org/zips/train2017.zip
$ aria2c -c http://images.cocodataset.org/zips/val2017.zip
$ aria2c -c http://images.cocodataset.org/zips/test2017.zip
COCO annotations
Install cocoapi
https://github.com/cocodataset/cocoapi
Install cocoapi using command-line commands:
$ sudo pip3 install pycocotools
Test:
$ python3
>> import pycocotools
Install COCO API before using COCO dataset.
Use cocoapi
(instances)
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "person"
},…]
instances_val2017.json
['licenses', 'info', 'images', 'categories', 'annotations']
"images": [
{
"license": 4,
"file_name": "000000397133.jpg",
"coco_url":
"http://images.cocodataset.org/val2017/000000397133.jpg",
"height": 427,
"width": 640,
"date_captured": "2013-11-14 17:02:52",
"flickr_url":
"http://farm7.staticflickr.com/6116/6255196340_da26cf2c9e_z.jpg",
"id": 397133
},…]
"annotations": [
{
"segmentation": [
[
510.03,
423.01,
510.45,
423.01...]
],
"area": 702.10574,
"iscrowd": 0,
"image_id": 289343,
"bbox": [
473.07,
395.93,
38.65,
28.67
],
"category_id": 18,
"id": 1768
},…]
(2)
(1)
(3)
https://zhuanlan.zhihu.com/p/29393415
Use cocoapi (instances)
from matplotlib import pyplot as plt
from matplotlib.patches import Polygon
from skimage import io
from pycocotools.coco import COCO
import numpy as np
import os
annFile = "data/coco2017/annotations/instances_val2017.json"
root = "data/coco2017/val2017/"
coco = COCO(annFile)
catIds = coco.getCatIds(catNms=['person', 'dog', 'skateboard'])
imgIds = coco.getImgIds(catIds=catIds)
images = coco.loadImgs(imgIds[0:3])
Use cocoapi (instances)
for idx, image in enumerate(images, 1):
plt.subplot(1, 3, idx)
I = io.imread(image['coco_url'])
plt.axis('off')
plt.imshow(I)
plt.show()
Use cocoapi (instances)
for idx, image in enumerate(images, 1):
plt.subplot(1, 3, idx)
I = io.imread(image['coco_url'])
plt.axis('off')
plt.imshow(I)
annIds = coco.getAnnIds(imgIds=image['id'], catIds=catIds, iscrowd=None)
anns = coco.loadAnns(annIds)
coco.showAnns(anns)
plt.show()
Use cocoapi (instances)
for idx, image in enumerate(images, 1):
# image
ax = plt.subplot(1, 3, idx)
I = io.imread(image['coco_url'])
plt.imshow(I)
plt.axis('off')
# segment
annIds = coco.getAnnIds(imgIds=image['id'], catIds=catIds, iscrowd=None)
anns = coco.loadAnns(annIds)
coco.showAnns(anns)
# bbox
for ann in anns:
bbox_x, bbox_y, bbox_w, bbox_h = ann['bbox']
poly = [[bbox_x, bbox_y], [bbox_x, bbox_y+bbox_h],
[bbox_x+bbox_w, bbox_y+bbox_h], [bbox_x+bbox_w, bbox_y]]
np_poly = np.array(poly).reshape((4,2))
ax.add_patch(Polygon(np_poly, linestyle='--', facecolor='none', edgecolor="red", linewidth=2))
plt.show()
Use cocoapi (instances)
Use cocoapi
(keypoints)
person_keypoints_val2017.json
['licenses', 'info', 'images', 'categories', 'annotations']
"images": [
{
"license": 4,
"file_name": "000000397133.jpg",
"coco_url":
"http://images.cocodataset.org/val2017/000000397133.jpg",
"height": 427,
"width": 640,
"date_captured": "2013-11-14 17:02:52",
"flickr_url":
"http://farm7.staticflickr.com/6116/6255196340_da26cf2c9e_z.jpg",
"id": 397133
},…]
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "person"
},…]
"annotations": [
{
"segmentation": [
[
125.12,
539.69,...]
],
"num_keypoints": 10,
"area": 47803.27955,
"iscrowd": 0,
"keypoints": [
162,
551,
2,...],
"image_id": 425226,
"bbox": [
73.35,206.02,
300.58,372.5
],
"category_id": 1,
"id": 183126
},
Use cocoapi (keypoints)
• visibility == 0 that keypoint not in the image.
• visibility == 1 that keypoint is in the image BUT
not visible namely maybe behind of an object.
• visibility == 2 that keypoint looks clearly. not
hidden.
"annotations": [
{
"segmentation": [
[
125.12,
539.69,...]
],
"num_keypoints": 10,
"area": 47803.27955,
"iscrowd": 0,
"keypoints": [
162,
551,
2,...],
"image_id": 425226,
"bbox": [
73.35,206.02,
300.58,372.5
],
"category_id": 1,
"id": 183126
},
Use cocoapi (keypoints)
annFile = "data/coco2017/annotations/person_keypoints_val2017.json"
coco = COCO(annFile)
catIds = coco.getCatIds(catNms=['person']) # the images icludes all categories
imgIds = coco.getImgIds(catIds=catIds)
images = coco.loadImgs(imgIds[10])
image = images[0]
Use cocoapi (keypoints)
# image
ax = plt.gca()
I = io.imread(image['coco_url'])
plt.imshow(I)
plt.axis('off')
# keypoints/segmentation
annIds = coco.getAnnIds(imgIds=image['id'], catIds=catIds, iscrowd=None)
anns = coco.loadAnns(annIds)
coco.showAnns(anns)
# bbox
for ann in anns:
bbox_x, bbox_y, bbox_w, bbox_h = ann['bbox']
poly = [[bbox_x, bbox_y], [bbox_x, bbox_y+bbox_h],
[bbox_x+bbox_w, bbox_y+bbox_h], [bbox_x+bbox_w, bbox_y]]
np_poly = np.array(poly).reshape((4,2))
ax.add_patch(Polygon(np_poly, linestyle='--', facecolor='none', edgecolor="red", linewidth=2))
plt.show()
Use cocoapi (keypoints)
Use cocoapi (caption)
"annotations": [
{
"image_id": 179765,
"id": 38,
"caption": "A black Honda motorcycle parked in front of a garage."
},…]
captions_val2017.json
['licenses', 'info', 'images', 'annotations']
Use cocoapi (caption)
annFile = "data/coco2017/annotations/captions_val2017.json"
coco = COCO(annFile)
imgIds = coco.getImgIds()
images = coco.loadImgs(imgIds[0])
image = images[0]
# image
ax = plt.gca()
I = io.imread(image['coco_url'])
plt.imshow(I)
plt.axis('off')
# keypoints/annotations
annIds = coco.getAnnIds(imgIds=image['id'], iscrowd=None)
anns = coco.loadAnns(annIds)
coco.showAnns(anns)
plt.show()
Use cocoapi (caption)
A person kitesurfing over the waves of the ocean's shore.
a kite surfer is doing a flying trick over some water
A man is flying up in the air and having fun.
A guy is waterboarding in the ocean on a windy day.
A person kite boarding in rough seas near the shoreline.
Coco

More Related Content

Similar to Coco

CNCF Québec Meetup du 16 Novembre 2023
CNCF Québec Meetup du 16 Novembre 2023CNCF Québec Meetup du 16 Novembre 2023
CNCF Québec Meetup du 16 Novembre 2023
Anthony Dahanne
 
How to Dockerize your Sitecore module
How to Dockerize your Sitecore moduleHow to Dockerize your Sitecore module
How to Dockerize your Sitecore module
Mihály Árvai
 
TASK -1 MAJOR PROJECT.pptx
TASK -1  MAJOR PROJECT.pptxTASK -1  MAJOR PROJECT.pptx
TASK -1 MAJOR PROJECT.pptx
MEMESSTATION
 
HTML5 after the hype - JFokus2015
HTML5 after the hype - JFokus2015HTML5 after the hype - JFokus2015
HTML5 after the hype - JFokus2015
Christian Heilmann
 
Introduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript ConferenceIntroduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript Conference
Bo-Yi Wu
 
Catch a spider monkey
Catch a spider monkeyCatch a spider monkey
Catch a spider monkey
ChengHui Weng
 
Back to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDBBack to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDB
MongoDB
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!
Anthony Dahanne
 
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip CalçadoJustjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Paulo Silveira
 
Back to Basics Webinar 2 - Your First MongoDB Application
Back to  Basics Webinar 2 - Your First MongoDB ApplicationBack to  Basics Webinar 2 - Your First MongoDB Application
Back to Basics Webinar 2 - Your First MongoDB Application
Joe Drumgoole
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
D3.js: Data Visualization for the Web
D3.js: Data Visualization for the Web D3.js: Data Visualization for the Web
D3.js: Data Visualization for the Web
Outliers Collective
 
Browsers with Wings
Browsers with WingsBrowsers with Wings
Browsers with Wings
Remy Sharp
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
Remy Sharp
 
Seti 09
Seti 09Seti 09
Seti 09
bzanchet
 
Microsoft Azure News - May 2021
Microsoft Azure News - May 2021Microsoft Azure News - May 2021
Microsoft Azure News - May 2021
Daniel Toomey
 
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
MongoDB
 
I use drupal / 我是 OO 師,我用 Drupal
I use drupal / 我是 OO 師,我用 DrupalI use drupal / 我是 OO 師,我用 Drupal
I use drupal / 我是 OO 師,我用 Drupal
Chris Wu
 
Building Dojo in the Cloud
Building Dojo in the CloudBuilding Dojo in the Cloud
Building Dojo in the Cloud
James Thomas
 

Similar to Coco (20)

CNCF Québec Meetup du 16 Novembre 2023
CNCF Québec Meetup du 16 Novembre 2023CNCF Québec Meetup du 16 Novembre 2023
CNCF Québec Meetup du 16 Novembre 2023
 
How to Dockerize your Sitecore module
How to Dockerize your Sitecore moduleHow to Dockerize your Sitecore module
How to Dockerize your Sitecore module
 
TASK -1 MAJOR PROJECT.pptx
TASK -1  MAJOR PROJECT.pptxTASK -1  MAJOR PROJECT.pptx
TASK -1 MAJOR PROJECT.pptx
 
HTML5 after the hype - JFokus2015
HTML5 after the hype - JFokus2015HTML5 after the hype - JFokus2015
HTML5 after the hype - JFokus2015
 
Introduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript ConferenceIntroduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript Conference
 
Catch a spider monkey
Catch a spider monkeyCatch a spider monkey
Catch a spider monkey
 
Back to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDBBack to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDB
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!
 
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip CalçadoJustjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
 
Back to Basics Webinar 2 - Your First MongoDB Application
Back to  Basics Webinar 2 - Your First MongoDB ApplicationBack to  Basics Webinar 2 - Your First MongoDB Application
Back to Basics Webinar 2 - Your First MongoDB Application
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
 
D3.js: Data Visualization for the Web
D3.js: Data Visualization for the Web D3.js: Data Visualization for the Web
D3.js: Data Visualization for the Web
 
Browsers with Wings
Browsers with WingsBrowsers with Wings
Browsers with Wings
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
 
Seti 09
Seti 09Seti 09
Seti 09
 
Microsoft Azure News - May 2021
Microsoft Azure News - May 2021Microsoft Azure News - May 2021
Microsoft Azure News - May 2021
 
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
 
I use drupal / 我是 OO 師,我用 Drupal
I use drupal / 我是 OO 師,我用 DrupalI use drupal / 我是 OO 師,我用 Drupal
I use drupal / 我是 OO 師,我用 Drupal
 
Building Dojo in the Cloud
Building Dojo in the CloudBuilding Dojo in the Cloud
Building Dojo in the Cloud
 

Recently uploaded

Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 

Recently uploaded (20)

Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 

Coco

  • 2. COCO segmentation Bounding box Keypoits Captions coco COCO is a large-scale object detection, segmentation, and captioning dataset. COCO has several features: So powerful!!
  • 3. $ sudo apt-get install aria2 $ aria2c -c http://msvocds.blob.core.windows.net/annotations-1-0-3/instances_train- val2014.zip $ aria2c -c http://msvocds.blob.core.windows.net/coco2014/train2014.zip $ aria2c -c http://msvocds.blob.core.windows.net/coco2014/val2014.zip $ aria2c -c http://msvocds.blob.core.windows.net/coco2014/test2014.zip Download COCO dataset (2014)
  • 4. Download COCO dataset (2017) $ sudo apt-get install aria2 $ aria2c -c http://msvocds.blob.core.windows.net/annotations/instances_train- val2017.zip $ aria2c -c http://images.cocodataset.org/zips/train2017.zip $ aria2c -c http://images.cocodataset.org/zips/val2017.zip $ aria2c -c http://images.cocodataset.org/zips/test2017.zip
  • 6. Install cocoapi https://github.com/cocodataset/cocoapi Install cocoapi using command-line commands: $ sudo pip3 install pycocotools Test: $ python3 >> import pycocotools Install COCO API before using COCO dataset.
  • 7. Use cocoapi (instances) "categories": [ { "supercategory": "person", "id": 1, "name": "person" },…] instances_val2017.json ['licenses', 'info', 'images', 'categories', 'annotations'] "images": [ { "license": 4, "file_name": "000000397133.jpg", "coco_url": "http://images.cocodataset.org/val2017/000000397133.jpg", "height": 427, "width": 640, "date_captured": "2013-11-14 17:02:52", "flickr_url": "http://farm7.staticflickr.com/6116/6255196340_da26cf2c9e_z.jpg", "id": 397133 },…] "annotations": [ { "segmentation": [ [ 510.03, 423.01, 510.45, 423.01...] ], "area": 702.10574, "iscrowd": 0, "image_id": 289343, "bbox": [ 473.07, 395.93, 38.65, 28.67 ], "category_id": 18, "id": 1768 },…] (2) (1) (3) https://zhuanlan.zhihu.com/p/29393415
  • 8. Use cocoapi (instances) from matplotlib import pyplot as plt from matplotlib.patches import Polygon from skimage import io from pycocotools.coco import COCO import numpy as np import os annFile = "data/coco2017/annotations/instances_val2017.json" root = "data/coco2017/val2017/" coco = COCO(annFile) catIds = coco.getCatIds(catNms=['person', 'dog', 'skateboard']) imgIds = coco.getImgIds(catIds=catIds) images = coco.loadImgs(imgIds[0:3])
  • 9. Use cocoapi (instances) for idx, image in enumerate(images, 1): plt.subplot(1, 3, idx) I = io.imread(image['coco_url']) plt.axis('off') plt.imshow(I) plt.show()
  • 10. Use cocoapi (instances) for idx, image in enumerate(images, 1): plt.subplot(1, 3, idx) I = io.imread(image['coco_url']) plt.axis('off') plt.imshow(I) annIds = coco.getAnnIds(imgIds=image['id'], catIds=catIds, iscrowd=None) anns = coco.loadAnns(annIds) coco.showAnns(anns) plt.show()
  • 11. Use cocoapi (instances) for idx, image in enumerate(images, 1): # image ax = plt.subplot(1, 3, idx) I = io.imread(image['coco_url']) plt.imshow(I) plt.axis('off') # segment annIds = coco.getAnnIds(imgIds=image['id'], catIds=catIds, iscrowd=None) anns = coco.loadAnns(annIds) coco.showAnns(anns) # bbox for ann in anns: bbox_x, bbox_y, bbox_w, bbox_h = ann['bbox'] poly = [[bbox_x, bbox_y], [bbox_x, bbox_y+bbox_h], [bbox_x+bbox_w, bbox_y+bbox_h], [bbox_x+bbox_w, bbox_y]] np_poly = np.array(poly).reshape((4,2)) ax.add_patch(Polygon(np_poly, linestyle='--', facecolor='none', edgecolor="red", linewidth=2)) plt.show()
  • 13. Use cocoapi (keypoints) person_keypoints_val2017.json ['licenses', 'info', 'images', 'categories', 'annotations'] "images": [ { "license": 4, "file_name": "000000397133.jpg", "coco_url": "http://images.cocodataset.org/val2017/000000397133.jpg", "height": 427, "width": 640, "date_captured": "2013-11-14 17:02:52", "flickr_url": "http://farm7.staticflickr.com/6116/6255196340_da26cf2c9e_z.jpg", "id": 397133 },…] "categories": [ { "supercategory": "person", "id": 1, "name": "person" },…] "annotations": [ { "segmentation": [ [ 125.12, 539.69,...] ], "num_keypoints": 10, "area": 47803.27955, "iscrowd": 0, "keypoints": [ 162, 551, 2,...], "image_id": 425226, "bbox": [ 73.35,206.02, 300.58,372.5 ], "category_id": 1, "id": 183126 },
  • 14. Use cocoapi (keypoints) • visibility == 0 that keypoint not in the image. • visibility == 1 that keypoint is in the image BUT not visible namely maybe behind of an object. • visibility == 2 that keypoint looks clearly. not hidden. "annotations": [ { "segmentation": [ [ 125.12, 539.69,...] ], "num_keypoints": 10, "area": 47803.27955, "iscrowd": 0, "keypoints": [ 162, 551, 2,...], "image_id": 425226, "bbox": [ 73.35,206.02, 300.58,372.5 ], "category_id": 1, "id": 183126 },
  • 15. Use cocoapi (keypoints) annFile = "data/coco2017/annotations/person_keypoints_val2017.json" coco = COCO(annFile) catIds = coco.getCatIds(catNms=['person']) # the images icludes all categories imgIds = coco.getImgIds(catIds=catIds) images = coco.loadImgs(imgIds[10]) image = images[0]
  • 16. Use cocoapi (keypoints) # image ax = plt.gca() I = io.imread(image['coco_url']) plt.imshow(I) plt.axis('off') # keypoints/segmentation annIds = coco.getAnnIds(imgIds=image['id'], catIds=catIds, iscrowd=None) anns = coco.loadAnns(annIds) coco.showAnns(anns) # bbox for ann in anns: bbox_x, bbox_y, bbox_w, bbox_h = ann['bbox'] poly = [[bbox_x, bbox_y], [bbox_x, bbox_y+bbox_h], [bbox_x+bbox_w, bbox_y+bbox_h], [bbox_x+bbox_w, bbox_y]] np_poly = np.array(poly).reshape((4,2)) ax.add_patch(Polygon(np_poly, linestyle='--', facecolor='none', edgecolor="red", linewidth=2)) plt.show()
  • 18. Use cocoapi (caption) "annotations": [ { "image_id": 179765, "id": 38, "caption": "A black Honda motorcycle parked in front of a garage." },…] captions_val2017.json ['licenses', 'info', 'images', 'annotations']
  • 19. Use cocoapi (caption) annFile = "data/coco2017/annotations/captions_val2017.json" coco = COCO(annFile) imgIds = coco.getImgIds() images = coco.loadImgs(imgIds[0]) image = images[0] # image ax = plt.gca() I = io.imread(image['coco_url']) plt.imshow(I) plt.axis('off') # keypoints/annotations annIds = coco.getAnnIds(imgIds=image['id'], iscrowd=None) anns = coco.loadAnns(annIds) coco.showAnns(anns) plt.show()
  • 20. Use cocoapi (caption) A person kitesurfing over the waves of the ocean's shore. a kite surfer is doing a flying trick over some water A man is flying up in the air and having fun. A guy is waterboarding in the ocean on a windy day. A person kite boarding in rough seas near the shoreline.