Py之pixellib:pixellib库的简介、安装、经典案例之详细攻略


钥匙称心
钥匙称心 2022-09-19 13:41:03 51823
分类专栏: 人才

Py之pixellib:pixellib库的简介、安装、经典案例之详细攻略

目录

pixellib库的简介

1、基础案例

pixellib库的安装

pixellib库的经典案例

1、使用pixellib进行语义分割


pixellib库的简介

        pixellib是一个库执行图像分割。它支持两种主要类型的图像分割:语义分割和实例分割,只需几行代码就可以实现语义分段和实例分段。特的特点如下:

  • 高质量反色矢量/光栅图形
  • 多像素格式:RGB, BGR, ARGB, ABGR, RGBA, BGRA 8 / 15 / 16 / 24 / 32深度
  • 重量轻100% C实现
  • MMX / SSE2图形优化

官网https://github.com/ayoolaolafenwa/PixelLib
案例https://github.com/skywind3000/pixellib
whl文件https://github.com/ayoolaolafenwa/PixelLib/releases/tag/0.1.0

1、基础案例

Image Transform
图像变换
Anti Aliasing
抗锯齿
Image Drawing
图像绘制
Geometry Render
几何渲染
Image Warp
图像扭曲
High Quality Render
高质量渲染

pixellib库的安装

  1. pip install pixellib
  2. pip install pixellib==0.1.0

20211129更新

pip install --upgrade pixellib
  1. C:\Users\Administrator>pip show pixellib
  2. Name: pixellib
  3. Version: 0.1.0
  4. Summary: PixelLib is a library for performing semantic and instance segmentation of images using few lines of code.
  5. Home-page: https://github.com/ayoolaolafenwa/PixelLib
  6. Author: Ayoola Olafenwa
  7. Author-email: UNKNOWN
  8. License: MIT
  9. Location: e:\program files\python\python36\lib\site-packages
  10. Requires:
  11. Required-by:
  12. E:\Program Files\Python>pip install --upgrade pixellib
  13. Requirement already satisfied: pixellib in e:\program files\python\python36\lib\site-packages (0.1.0)
  14. Collecting pixellib
  15. Downloading pixellib-0.7.1-py3-none-any.whl (430 kB)
  16. |████████████████████████████████| 430 kB 435 kB/s
  17. Requirement already satisfied: opencv-python in e:\program files\python\python36\lib\site-packages (from pixellib) (3.4.1.15)
  18. Requirement already satisfied: tabulate in e:\program files\python\python36\lib\site-packages (from pixellib) (0.8.6)
  19. Collecting iopath
  20. Downloading iopath-0.1.9-py3-none-any.whl (27 kB)
  21. Collecting labelme2coco
  22. Downloading labelme2coco-0.1.2-py3-none-any.whl (19 kB)
  23. Requirement already satisfied: dataclasses in e:\program files\python\python36\lib\site-packages (from pixellib) (0.8)
  24. Collecting pydot
  25. Downloading pydot-1.4.2-py2.py3-none-any.whl (21 kB)
  26. Requirement already satisfied: yacs in e:\program files\python\python36\lib\site-packages (from pixellib) (0.1.6)
  27. Requirement already satisfied: fvcore in e:\program files\python\python36\lib\site-packages\fvcore-0.1.dev200108-py3.6.egg (from pixellib) (0.1.dev200108)
  28. Requirement already satisfied: pillow in e:\program files\python\python36\lib\site-packages (from pixellib) (8.0.0)
  29. Collecting hydra-core
  30. Downloading hydra_core-1.1.1-py3-none-any.whl (145 kB)
  31. |████████████████████████████████| 145 kB 547 kB/s
  32. Collecting omegaconf
  33. Downloading omegaconf-2.1.1-py3-none-any.whl (74 kB)
  34. |████████████████████████████████| 74 kB 565 kB/s
  35. Requirement already satisfied: matplotlib in e:\program files\python\python36\lib\site-packages (from pixellib) (3.3.2)
  36. Requirement already satisfied: tqdm in e:\program files\python\python36\lib\site-packages (from pixellib) (4.51.0)
  37. Requirement already satisfied: future in e:\program files\python\python36\lib\site-packages (from pixellib) (0.16.0)
  38. Requirement already satisfied: scikit-image in e:\program files\python\python36\lib\site-packages (from pixellib) (0.16.2)
  39. Collecting imantics
  40. Downloading imantics-0.1.12.tar.gz (13 kB)
  41. Preparing metadata (setup.py) ... done
  42. Requirement already satisfied: imgaug in e:\program files\python\python36\lib\site-packages (from pixellib) (0.2.6)
  43. Requirement already satisfied: pyQt5 in e:\program files\python\python36\lib\site-packages (from pixellib) (5.15.6)
  44. Requirement already satisfied: termcolor in e:\program files\python\python36\lib\site-packages (from pixellib) (1.1.0)
  45. Collecting black
  46. Downloading black-21.11b1-py3-none-any.whl (155 kB)
  47. |████████████████████████████████| 155 kB 731 kB/s
  48. Requirement already satisfied: cloudpickle in e:\program files\python\python36\lib\site-packages\cloudpickle-1.2.2-py3.6.egg (from pixellib) (1.2.2)
  49. Requirement already satisfied: Cython in e:\program files\python\python36\lib\site-packages (from pixellib) (0.28.3)
  50. Requirement already satisfied: click>=7.1.2 in e:\program files\python\python36\lib\site-packages (from black->pixellib) (7.1.2)
  51. Collecting mypy-extensions>=0.4.3
  52. Downloading mypy_extensions-0.4.3-py2.py3-none-any.whl (4.5 kB)
  53. Collecting platformdirs>=2
  54. Downloading platformdirs-2.4.0-py3-none-any.whl (14 kB)
  55. Collecting regex>=2021.4.4
  56. Downloading regex-2021.11.10-cp36-cp36m-win_amd64.whl (272 kB)
  57. |████████████████████████████████| 272 kB 731 kB/s
  58. Requirement already satisfied: typing-extensions>=3.10.0.0 in e:\program files\python\python36\lib\site-packages (from black->pixellib) (3.10.0.2)
  59. Collecting tomli<2.0.0,>=0.2.6
  60. Downloading tomli-1.2.2-py3-none-any.whl (12 kB)
  61. Collecting pathspec<1,>=0.9.0
  62. Downloading pathspec-0.9.0-py2.py3-none-any.whl (31 kB)
  63. Collecting typed-ast>=1.4.2
  64. Downloading typed_ast-1.5.0-cp36-cp36m-win_amd64.whl (161 kB)
  65. |████████████████████████████████| 161 kB 819 kB/s
  66. Collecting pyyaml>=5.1
  67. Downloading PyYAML-6.0-cp36-cp36m-win_amd64.whl (153 kB)
  68. |████████████████████████████████| 153 kB 544 kB/s
  69. Requirement already satisfied: portalocker in e:\program files\python\python36\lib\site-packages (from fvcore->pixellib) (1.5.2)
  70. Collecting antlr4-python3-runtime==4.8
  71. Downloading antlr4-python3-runtime-4.8.tar.gz (112 kB)
  72. |████████████████████████████████| 112 kB 1.1 MB/s
  73. Preparing metadata (setup.py) ... done
  74. Requirement already satisfied: importlib-resources in e:\program files\python\python36\lib\site-packages (from hydra-core->pixellib) (1.0.2)
  75. Requirement already satisfied: numpy in e:\program files\python\python36\lib\site-packages (from imantics->pixellib) (1.19.0)
  76. Requirement already satisfied: lxml in e:\program files\python\python36\lib\site-packages (from imantics->pixellib) (4.5.2)
  77. Collecting xmljson
  78. Downloading xmljson-0.2.1-py2.py3-none-any.whl (10 kB)
  79. Requirement already satisfied: scipy in f:\program files\python\python36\lib\site-packages (from imgaug->pixellib) (1.4.1)
  80. Requirement already satisfied: six in e:\program files\python\python36\lib\site-packages (from imgaug->pixellib) (1.15.0)
  81. Requirement already satisfied: imageio>=2.3.0 in e:\program files\python\python36\lib\site-packages (from scikit-image->pixellib) (2.6.1)
  82. Requirement already satisfied: PyWavelets>=0.4.0 in e:\program files\python\python36\lib\site-packages (from scikit-image->pixellib) (0.5.2)
  83. Requirement already satisfied: networkx>=2.0 in e:\program files\python\python36\lib\site-packages (from scikit-image->pixellib) (2.5)
  84. Requirement already satisfied: certifi>=2020.06.20 in e:\program files\python\python36\lib\site-packages (from matplotlib->pixellib) (2020.6.20)
  85. Requirement already satisfied: kiwisolver>=1.0.1 in e:\program files\python\python36\lib\site-packages (from matplotlib->pixellib) (1.0.1)
  86. Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in e:\program files\python\python36\lib\site-packages (from matplotlib->pixellib) (2.2.0)
  87. Requirement already satisfied: cycler>=0.10 in e:\program files\python\python36\lib\site-packages (from matplotlib->pixellib) (0.10.0)
  88. Requirement already satisfied: python-dateutil>=2.1 in e:\program files\python\python36\lib\site-packages (from matplotlib->pixellib) (2.8.1)
  89. Requirement already satisfied: jsonschema>=2.6.0 in e:\program files\python\python36\lib\site-packages (from labelme2coco->pixellib) (2.6.0)
  90. Requirement already satisfied: PyQt5-Qt5>=5.15.2 in e:\program files\python\python36\lib\site-packages (from pyQt5->pixellib) (5.15.2)
  91. Requirement already satisfied: PyQt5-sip<13,>=12.8 in e:\program files\python\python36\lib\site-packages (from pyQt5->pixellib) (12.9.0)
  92. Requirement already satisfied: setuptools in f:\program files\python\python36\lib\site-packages (from kiwisolver>=1.0.1->matplotlib->pixellib) (59.3.0)
  93. Requirement already satisfied: decorator>=4.3.0 in e:\program files\python\python36\lib\site-packages (from networkx>=2.0->scikit-image->pixellib) (4.3.0)
  94. Requirement already satisfied: pywin32!=226 in e:\program files\python\python36\lib\site-packages (from portalocker->fvcore->pixellib) (223)
  95. Building wheels for collected packages: antlr4-python3-runtime, imantics
  96. Building wheel for antlr4-python3-runtime (setup.py) ... done
  97. Created wheel for antlr4-python3-runtime: filename=antlr4_python3_runtime-4.8-py3-none-any.whl size=142057 sha256=7b0051eda214a47b80d05d880c319d864cc75efe34a91532e25cc2476716e4f4
  98. Stored in directory: c:\users\administrator\appdata\local\pip\cache\wheels\a8\04\35\9449686f1c26ff16f6224dc942e108329f3782185802ec6b93
  99. Building wheel for imantics (setup.py) ... done
  100. Created wheel for imantics: filename=imantics-0.1.12-py3-none-any.whl size=17863 sha256=8300b54db38fc774543f10f78c2d582b3643c9f75997fd8e2cc333b93479b9ae
  101. Stored in directory: c:\users\administrator\appdata\local\pip\cache\wheels\3a\d0\b5\f483e166e98686953873e045c44c874139085d116cb1fba933
  102. Successfully built antlr4-python3-runtime imantics
  103. Installing collected packages: pyyaml, antlr4-python3-runtime, xmljson, typed-ast, tomli, regex, platformdirs, pathspec, omegaconf, mypy-extensions, pydot, labelme2coco, iopath, imantics, hydra-core, black, pixellib
  104. Attempting uninstall: pyyaml
  105. Found existing installation: PyYAML 3.12
  106. Uninstalling PyYAML-3.12:
  107. Successfully uninstalled PyYAML-3.12
  108. Attempting uninstall: pixellib
  109. Found existing installation: pixellib 0.1.0
  110. Uninstalling pixellib-0.1.0:
  111. Successfully uninstalled pixellib-0.1.0
  112. ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
  113. slowfast 1.0 requires av, which is not installed.
  114. slowfast 1.0 requires detectron2, which is not installed.
  115. paddlepaddle 1.6.3 requires matplotlib<=2.2.4, but you have matplotlib 3.3.2 which is incompatible.
  116. paddlepaddle 1.6.3 requires numpy<=1.16.4,>=1.12, but you have numpy 1.19.0 which is incompatible.
  117. paddlepaddle 1.6.3 requires scipy<=1.2.1,>=0.19.0, but you have scipy 1.4.1 which is incompatible.
  118. distributed 2020.12.0 requires cloudpickle>=1.5.0, but you have cloudpickle 1.2.2 which is incompatible.
  119. chatterbot-corpus 1.1.1 requires PyYAML<4.0,>=3.12, but you have pyyaml 6.0 which is incompatible.
  120. autokeras 0.2.19 requires keras==2.2.2, but you have keras 2.2.4 which is incompatible.
  121. autokeras 0.2.19 requires tensorflow==1.10.0, but you have tensorflow 1.11.0 which is incompatible.
  122. autokeras 0.2.19 requires torch==0.4.1, but you have torch 1.3.1 which is incompatible.
  123. autokeras 0.2.19 requires torchvision==0.2.1, but you have torchvision 0.4.1 which is incompatible.
  124. autokeras 0.2.19 requires tqdm==4.25.0, but you have tqdm 4.51.0 which is incompatible.
  125. albumentations 0.4.3 requires opencv-python>=4.1.1, but you have opencv-python 3.4.1.15 which is incompatible.
  126. Successfully installed antlr4-python3-runtime-4.8 black-21.11b1 hydra-core-1.1.1 imantics-0.1.12 iopath-0.1.9 labelme2coco-0.1.2 mypy-extensions-0.4.3 omegaconf-2.1.1 pathspec-0.9.0 pixellib-0.7.1 platformdirs-2.4.0 pydot-1.4.2 pyyaml-6.0 regex-2021.11.10 tomli-1.2.2 typed-ast-1.5.0 xmljson-0.2.1

升级后导致bug更多,重新降为pixellib==0.1.0

  1. C:\Users\Administrator>pip install pixellib==0.1.0
  2. Collecting pixellib==0.1.0
  3. Downloading pixellib-0.1.0-py3-none-any.whl (39 kB)
  4. Installing collected packages: pixellib
  5. Attempting uninstall: pixellib
  6. Found existing installation: pixellib 0.7.1
  7. Uninstalling pixellib-0.7.1:
  8. Successfully uninstalled pixellib-0.7.1
  9. Successfully installed pixellib-0.1.0

pixellib库的经典案例

1、使用pixellib进行语义分割

pixellib使用Deeplabv3+框架实现,实现语义分割。采用在pascalvoc上预训练的Xception模型进行语义切分。基于xception模型的语义分割在pascalvoc上进行预处理。

  • 用于执行语义分段的类是从pixellib导入的,我们创建了该类的一个实例。
  • 我们调用函数来加载在pascal voc上训练的xception模型。可以从这里下载xception模型。
  • 这是对图像执行分割的代码行,分割是在pascalvoc的颜色格式中完成的。这个函数有两个参数:   
    path_to_image:要设置的映像的路径。 
    path_to_output_image:保存输出图像的路径。映像将保存在当前工作目录中。
  1. import pixellib
  2. from pixellib.semantic import semantic_segmentation
  3. segment_image = semantic_segmentation()
  4. segment_image.load_pascalvoc_model("deeplabv3_xception_tf_dim_ordering_tf_kernels.h5")
  5. segment_image.segmentAsPascalvoc("path_to_image", output_image_name = "path_to_output_image")
文章知识点与官方知识档案匹配,可进一步学习相关知识
Python入门技能树预备知识Python简介123748 人正在系统学习中

网站声明:如果转载,请联系本站管理员。否则一切后果自行承担。

本文链接:https://www.xckfsq.com/news/show.html?id=2725
赞同 0
评论 0 条
钥匙称心L0
粉丝 0 发表 9 + 关注 私信
上周热门
如何使用 StarRocks 管理和优化数据湖中的数据?  2950
【软件正版化】软件正版化工作要点  2872
统信UOS试玩黑神话:悟空  2833
信刻光盘安全隔离与信息交换系统  2728
镜舟科技与中启乘数科技达成战略合作,共筑数据服务新生态  1261
grub引导程序无法找到指定设备和分区  1226
华为全联接大会2024丨软通动力分论坛精彩议程抢先看!  165
2024海洋能源产业融合发展论坛暨博览会同期活动-海洋能源与数字化智能化论坛成功举办  163
点击报名 | 京东2025校招进校行程预告  163
华为纯血鸿蒙正式版9月底见!但Mate 70的内情还得接着挖...  158
本周热议
我的信创开放社区兼职赚钱历程 40
今天你签到了吗? 27
如何玩转信创开放社区—从小白进阶到专家 15
信创开放社区邀请他人注册的具体步骤如下 15
方德桌面操作系统 14
用抖音玩法闯信创开放社区——用平台宣传企业产品服务 13
我有15积分有什么用? 13
如何让你先人一步获得悬赏问题信息?(创作者必看) 12
2024中国信创产业发展大会暨中国信息科技创新与应用博览会 9
中央国家机关政府采购中心:应当将CPU、操作系统符合安全可靠测评要求纳入采购需求 8

加入交流群

请使用微信扫一扫!