SlideShare a Scribd company logo
1 of 21
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 2023Anthony Dahanne
 
How to Dockerize your Sitecore module
How to Dockerize your Sitecore moduleHow to Dockerize your Sitecore module
How to Dockerize your Sitecore moduleMihály Árvai
 
TASK -1 MAJOR PROJECT.pptx
TASK -1  MAJOR PROJECT.pptxTASK -1  MAJOR PROJECT.pptx
TASK -1 MAJOR PROJECT.pptxMEMESSTATION
 
HTML5 after the hype - JFokus2015
HTML5 after the hype - JFokus2015HTML5 after the hype - JFokus2015
HTML5 after the hype - JFokus2015Christian 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 ConferenceBo-Yi Wu
 
Catch a spider monkey
Catch a spider monkeyCatch a spider monkey
Catch a spider monkeyChengHui 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 MongoDBMongoDB
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive 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çadoPaulo 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 ApplicationJoe 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 ApplicationMongoDB
 
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 WingsRemy 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 anymoreRemy Sharp
 
Microsoft Azure News - May 2021
Microsoft Azure News - May 2021Microsoft Azure News - May 2021
Microsoft Azure News - May 2021Daniel 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 師,我用 DrupalChris Wu
 
Building Dojo in the Cloud
Building Dojo in the CloudBuilding Dojo in the Cloud
Building Dojo in the CloudJames 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

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 

Recently uploaded (20)

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 

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.