久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何下載 Coco Dataset 的特定部分?

How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
本文介紹了如何下載 Coco Dataset 的特定部分?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在開發一個對象檢測模型來使用 YOLO 檢測船舶.我想使用 COCO 數據集.有沒有辦法只下載帶有注釋的圖像?

I am developing an object detection model to detect ships using YOLO. I want to use the COCO dataset. Is there a way to download only the images that have ships with the annotations?

推薦答案

要下載特定類別的圖片,可以使用 COCO API.這是一個 demo 筆記本,通過這個和其他用法.整體流程如下:

To download images from a specific category, you can use the COCO API. Here's a demo notebook going through this and other usages. The overall process is as follows:

  • 安裝pycocotools
  • 從 COCO 數據集
  • 下載其中一個注釋 json
  • Install pycocotools
  • Download one of the annotations jsons from the COCO dataset

下面是一個示例,說明我們如何下載包含 person 的圖像子集并將其保存在本地文件中:

Now here's an example on how we could download a subset of the images containing a person and saving it in a local file:

from pycocotools.coco import COCO
import requests

# instantiate COCO specifying the annotations json path
coco = COCO('...path_to_annotations/instances_train2014.json')
# Specify a list of category names of interest
catIds = coco.getCatIds(catNms=['person'])
# Get the corresponding image ids and images using loadImgs
imgIds = coco.getImgIds(catIds=catIds)
images = coco.loadImgs(imgIds)

它返回一個字典列表,其中包含有關圖像及其 url 的基本信息.我們現在可以使用 requestsGET 圖像并將它們寫入本地文件夾:

Which returns a list of dictionaries with basic information on the images and its url. We can now use requests to GET the images and write them into a local folder:

# Save the images into a local folder
for im in images:
    img_data = requests.get(im['coco_url']).content
    with open('...path_saved_ims/coco_person/' + im['file_name'], 'wb') as handler:
        handler.write(img_data)

請注意,這將保存指定類別中的所有張圖片.因此,您可能希望將 images 列表切片為第一個 n.

Note that this will save all images from the specified category. So you might want to slice the images list to the first n.

這篇關于如何下載 Coco Dataset 的特定部分?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
Calculating percentage of Bounding box overlap, for image detector evaluation(計算邊界框重疊的百分比,用于圖像檢測器評估)
主站蜘蛛池模板: 欧美成人免费在线 | 国产成人在线一区 | 丝袜一区二区三区 | 亚洲3p| 一区二区三区国产精品 | 特级黄一级播放 | 成人不卡| 久久国产精品一区二区三区 | 欧美爱爱视频 | 欧美国产一区二区 | 四虎影音 | 国产精品久久一区二区三区 | 亚洲男人的天堂网站 | 天天狠狠 | 韩国电影久久 | 一区二区三区四区电影视频在线观看 | www.788.com色淫免费 | 亚洲综合二区 | 日韩一区二区在线播放 | 精品在线一区二区 | 欧美成人高清视频 | 二区中文| 91麻豆精品国产91久久久资源速度 | 成人精品一区二区 | 在线国产一区 | 亚洲精品一区二区二区 | 一级毛片中国 | 一二三区视频 | 欧美二区在线 | 伊人中文字幕 | 久久成人人人人精品欧 | 色婷婷综合久久久中字幕精品久久 | 麻豆久久久久 | 91免费高清视频 | 人人操日日干 | 99久久婷婷国产综合精品电影 | 欧美日韩一区二区三区不卡视频 | 国产欧美日韩一区二区三区 | 中文字幕av在线 | 色狠狠桃花综合 | 一二三在线视频 |