IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Python知识库 -> centos7下安装pycocotools -> 正文阅读

[Python知识库]centos7下安装pycocotools

1.进入虚拟环境??

我用的 python3.6.8

[pei@hlly ~]$ workon blog
(blog) [pei@hlly ~]$ pip list
Package ? ?Version
---------- -------
pip ? ? ? ?21.2.2
setuptools 57.4.0
wheel ? ? ?0.36.2

2. 先安装cpython

pip install cython

3 下载?pycocotools 源码

https://github.com/cocodataset/cocoapi.git

Windows上下载完成后 拷贝到服务器上??cocoapi-master.zip

unzip cocoapi-master.zip?? ?# 解压

4. 安装前确保 已安装 numpy

pip install numpy==1.19
?

5. 安装?

cd cocoapi-master/PythonAPI/

make install

示例

from pycocotools.coco import COCO

coco = COCO(os.path.join(self.root_dir, 'annotations', 'instances_' + self.set_name + '.json'))
image_ids =coco.getImgIds()?
>>[391895, 522418, 184613, 318219, 554625, 574769, 60623, 309022, 5802, 222564,...]
categories = coco.loadCats(coco.getCatIds())
>>[{'supercategory': 'person', 'id': 1, 'name': 'person'}, {'supercategory': 'vehicle', 'id': 2, 'name': 'bicycle'}, {'supercategory': 'vehicle', 'id': 3, 'name': 'car'}, {'supercategory': 'vehicle', 'id': 4, 'name': 'motorcycle'}, {'supercategory': 'vehicle', 'id': 5, 'name': 'airplane'}, {'supercategory': 'vehicle', 'id': 6, 'name': 'bus'}, {'supercategory': 'vehicle', 'id': 7, 'name': 'train'}, {'supercategory': 'vehicle', 'id': 8, 'name': 'truck'}, {'supercategory': 'vehicle', 'id': 9, 'name': 'boat'}, {'supercategory': 'outdoor', 'id': 10, 'name': 'traffic light'}]
coco.loadImgs(image_ids[0])
>>[{'license': 3, 'file_name': '000000391895.jpg', 'coco_url': 'http://images.cocodataset.org/train2017/000000391895.jpg', 'height': 360, 'width': 640, 'date_captured': '2013-11-14 11:18:45', 'flickr_url': 'http://farm9.staticflickr.com/8186/8119368305_4e622c8349_z.jpg', 'id': 391895}]
annotations_ids=coco.getAnnIds(imgIds=image_ids[0], iscrowd=False)
>>[151091, 202758, 1260346, 1766676]
coco_annotations =coco.loadAnns(annotations_ids)
>>[{'segmentation': [[376.97, 176.91, 398.81, 176.91, 396.38, 147.78, 447.35, 146.17, 448.16, 172.05, 448.16, 178.53, 464.34, 186.62, 464.34, 192.28, 448.97, 195.51, 447.35, 235.96, 441.69, 258.62, 454.63, 268.32, 462.72, 276.41, 471.62, 290.98, 456.25, 298.26, 439.26, 292.59, 431.98, 308.77, 442.49, 313.63, 436.02, 316.86, 429.55, 322.53, 419.84, 354.89, 402.04, 359.74, 401.24, 312.82, 370.49, 303.92, 391.53, 299.87, 391.53, 280.46, 385.06, 278.84, 381.01, 278.84, 359.17, 269.13, 373.73, 261.85, 374.54, 256.19, 378.58, 231.11, 383.44, 205.22, 385.87, 192.28, 373.73, 184.19]], 'area': 12190.44565, 'iscrowd': 0, 'image_id': 391895, 'bbox': [359.17, 146.17, 112.45, 213.57], 'category_id': 4, 'id': 151091},?
? ? ? {'segmentation': [[352.55, 146.82, 353.61, 137.66, 356.07, 112.66, 357.13, 94.7, 357.13, 84.49, 363.12, 73.92, 370.16, 68.64, 370.16, 66.53, 368.4, 63.71, 368.05, 54.56, 361.0, 53.85, 356.07, 50.33, 356.43, 46.46, 364.17, 42.23, 369.1, 35.89, 371.22, 30.96, 376.85, 26.39, 383.54, 22.16, 391.29, 23.22, 400.79, 27.79, 402.2, 30.61, 404.32, 34.84, 406.08, 38.71, 406.08, 41.53, 406.08, 47.87, 407.84, 54.91, 408.89, 59.84, 408.89, 61.25, 408.89, 63.36, 422.28, 67.94, 432.13, 72.52, 445.87, 81.32, 446.57, 84.14, 446.57, 99.2, 451.15, 118.22, 453.26, 128.39, 453.61, 131.92, 453.61, 133.68, 451.5, 137.55, 451.5, 139.31, 455.38, 144.24, 455.38, 153.04, 455.73, 155.16, 461.01, 162.85, 462.07, 166.37, 459.95, 170.6, 459.6, 176.58, 459.95, 178.69, 459.95, 180.1, 448.33, 180.45, 447.98, 177.64, 446.57, 172.36, 447.63, 166.37, 449.74, 160.38, 450.09, 157.57, 448.68, 152.28, 445.16, 147.71, 441.29, 143.48, 435.66, 142.78, 428.26, 141.37, 420.87, 141.37, 418.75, 141.37, 411.71, 144.19, 404.32, 145.24, 396.57, 150.52, 395.87, 152.64, 391.29, 157.92, 391.99, 164.26, 389.53, 172.0, 389.53, 176.23, 376.85, 174.82, 375.09, 177.29, 374.03, 188.55, 381.08, 192.78, 384.6, 194.19, 384.95, 198.41, 383.19, 203.34, 380.02, 210.03, 378.61, 218.84, 375.79, 220.95, 373.68, 223.42, 368.05, 245.56, 368.05, 256.48, 368.05, 259.3, 360.65, 261.06, 361.71, 266.34, 361.36, 268.8, 358.19, 271.62, 353.26, 274.09, 349.74, 275.49, 341.28, 273.03, 339.88, 270.21, 343.05, 263.52, 347.62, 259.65, 351.5, 253.31, 352.9, 250.84, 356.07, 244.86, 359.24, 235.35, 357.83, 214.58, 357.13, 204.36, 358.89, 196.97, 361.71, 183.94, 365.93, 175.14, 371.92, 169.15, 376.15, 164.22, 377.2, 160.35, 378.61, 151.9, 377.55, 145.56, 375.79, 131.82, 375.09, 131.82, 373.33, 139.22, 370.16, 143.8, 369.1, 148.02, 365.93, 155.42, 361.0, 158.59, 358.89, 159.99, 358.89, 161.76, 361.71, 163.87, 363.12, 165.98, 363.12, 168.8, 362.06, 170.21, 360.3, 170.56, 358.54, 170.56, 355.02, 168.45, 352.2, 163.52, 351.14, 161.05, 351.14, 156.83, 352.2, 154.36, 353.26, 152.25, 353.61, 152.25, 353.26, 149.43], [450.45, 196.54, 461.71, 195.13, 466.29, 209.22, 469.11, 227.88, 475.09, 241.62, 479.32, 249.01, 482.49, 262.04, 482.84, 279.96, 485.66, 303.87, 492.7, 307.04, 493.76, 309.5, 491.29, 318.66, 490.59, 321.83, 485.66, 322.89, 480.02, 322.89, 475.45, 317.96, 474.74, 310.91, 470.87, 304.57, 470.87, 294.71, 467.7, 282.34, 463.47, 276.7, 461.71, 272.83, 459.25, 270.01, 454.32, 268.25, 450.09, 259.82, 450.09, 252.07, 445.52, 234.11, 449.04, 229.57, 448.33, 199.29]], 'area': 14107.271300000002, 'iscrowd': 0, 'image_id': 391895, 'bbox': [339.88, 22.16, 153.88, 300.73], 'category_id': 1, 'id': 202758},
? ? ? {'segmentation': [[477.41, 217.71, 475.06, 212.15, 473.78, 208.95, 473.78, 203.39, 473.78, 200.4, 473.35, 196.76, 472.07, 192.49, 471.64, 189.49, 471.64, 186.71, 472.28, 184.36, 473.14, 183.29, 473.14, 179.87, 473.35, 178.16, 474.85, 176.67, 475.92, 175.38, 477.63, 173.46, 479.98, 172.82, 484.04, 175.6, 484.47, 178.16, 484.9, 178.8, 492.38, 180.3, 499.43, 181.16, 506.06, 180.94, 507.34, 182.22, 507.56, 183.51, 506.06, 184.58, 503.28, 185.64, 499.22, 185.86, 493.23, 186.5, 489.17, 186.71, 490.67, 192.06, 490.24, 193.77, 488.74, 194.41, 488.1, 196.98, 488.32, 197.62, 487.03, 198.69, 485.97, 203.17, 486.82, 204.03, 488.53, 204.89, 486.39, 207.88, 485.75, 214.29, 486.39, 218.35, 482.55, 218.57, 481.48, 220.92, 479.77, 220.06, 478.27, 218.57]], 'area': 708.2605500000001, 'iscrowd': 0, 'image_id': 391895, 'bbox': [471.64, 172.82, 35.92, 48.1], 'category_id': 1, 'id': 1260346}, \
? ? ? {'segmentation': [[486.01, 217.92, 486.01, 211.11, 487.71, 206.57, 489.6, 204.11, 487.71, 201.84, 488.66, 198.63, 489.98, 196.55, 489.04, 193.52, 495.46, 190.88, 496.22, 190.12, 494.52, 187.28, 497.36, 186.72, 501.33, 187.66, 509.08, 183.88, 513.81, 183.31, 513.99, 183.31, 516.64, 187.28, 515.89, 188.04, 508.51, 188.42, 508.89, 189.93, 511.54, 191.25, 511.16, 194.09, 507.57, 197.68, 507.94, 204.3, 508.7, 208.46, 507.0, 214.89, 506.62, 216.02, 503.6, 216.21, 500.95, 216.21, 495.65, 217.92, 489.79, 218.29]], 'area': 626.9852500000001, 'iscrowd': 0, 'image_id': 391895, 'bbox': [486.01, 183.31, 30.63, 34.98], 'category_id': 2, 'id': 1766676}]

  Python知识库 最新文章
Python中String模块
【Python】 14-CVS文件操作
python的panda库读写文件
使用Nordic的nrf52840实现蓝牙DFU过程
【Python学习记录】numpy数组用法整理
Python学习笔记
python字符串和列表
python如何从txt文件中解析出有效的数据
Python编程从入门到实践自学/3.1-3.2
python变量
上一篇文章      下一篇文章      查看所有文章
加:2021-08-10 13:22:40  更:2021-08-10 13:24:39 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/17 4:51:19-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码