当前位置:网站首页>Semantic segmentation learning notes (1)
Semantic segmentation learning notes (1)
2022-07-02 15:24:00 【Shallow thoughts 52】
List of articles
One 、 difference
Semantic segmentation : Each pixel is labeled ( This pixel is human , Trees , Background, etc ) Semantic segmentation only distinguishes categories , Do not distinguish specific units in the classification

Instance segmentation : Not only to distinguish categories , Also distinguish each individual in the category

Panoramic segmentation : It is equivalent to semantic segmentation plus instance segmentation

Two 、 The code demonstrates the original image and mask The fusion
from PIL import Image
import imgviz
import numpy as np
image_file=r'D:\aaa\envs\labelme\Scripts\2_3_json\img.png'
mask_file=r'D:\aaa\envs\labelme\Scripts\2_3_json\label.png'
image=Image.open(image_file)
mask=Image.open(mask_file)
mask_img=Image.blend(image.convert("RGBA"),
mask.convert("RGBA"),0.5)
mask_img.save("vis2.png")

3、 ... and 、 Data processing
take labelme Marked json convert to mask Images
import json
import os
import imgviz
import numpy as np
from PIL import Image
import cv2
import glob
def save_colored_mask(mask,image_file):
lbl_image=Image.fromarray(mask.astype(np.uint8),mode='P')
colormap=imgviz.label_colormap()
lbl_image.putpalette(colormap.flatten())
lbl_image.save(image_file)
json_files=r'E:\ desktop \ Information \ Semantic segmentation '
img_file=r'E:\ desktop \ Information \ Semantic segmentation \ picture '
json_l=glob.glob(os.path.join(json_files,'*.json'))
for json_ in json_l:
name=os.path.basename(json_)
img_name=name.replace('json','png')
fs=open(json_,encoding='utf-8')
dict_=json.load(fs)
# Get images wide , high
height = dict_['imageHeight']
width = dict_['imageWidth']
shapes = dict_["shapes"]
# Generate an all zero image
img = np.zeros((height, width), dtype=np.uint8)
label_color = {
"sheep": 1}
for shape in shapes:
# Analyze the coordinates of polygon contour points
points = shape['points']
# Parse polygon labels
label = shape['label']
points = np.array(points, dtype=np.int32)
# Draw the outline
cv2.polylines(img, [points], isClosed=True, color=(255), thickness=2)
# Fill polygon color
cv2.fillPoly(img, [points], color=label_color[label])
img_path=os.path.join(img_file,img_name)
print(img_path)
save_colored_mask(img, img_path)
边栏推荐
- GeoServer offline map service construction and layer Publishing
- Huffman tree: (1) input each character and its weight (2) construct Huffman tree (3) carry out Huffman coding (4) find hc[i], and get the Huffman coding of each character
- 做好抗“疫”之路的把关人——基于RK3568的红外热成像体温检测系统
- IE 浏览器正式退休
- 2021-2022學年編譯原理考試重點[華僑大學]
- 数据分析常见的英文缩写(一)
- Markdown tutorial
- 03_線性錶_鏈錶
- Solution of Queen n problem
- 数据库内容输出有问题怎么解决
猜你喜欢

基于RZ/G2L | OK-G2LD-C开发板存储读写速度与网络实测

vChain: Enabling Verifiable Boolean Range Queries over Blockchain Databases(sigmod‘2019)

20_Redis_哨兵模式

14_ Redis_ Optimistic lock

Mavn builds nexus private server

08_ 串

18_Redis_Redis主从复制&&集群搭建

10_ Redis_ geospatial_ command

List集合&UML图
![[C language] explain the initial and advanced levels of the pointer and points for attention (1)](/img/61/1619bd2e959bae1b769963f66bab4e.png)
[C language] explain the initial and advanced levels of the pointer and points for attention (1)
随机推荐
Leetcode - Search 2D matrix
Map介绍
05_ queue
Learn the method code example of converting timestamp to uppercase date using PHP
13_Redis_事务
. Net again! Happy 20th birthday
C RichTextBox controls the maximum number of lines displayed
记一次面试
Topology architecture of the minimum deployment of tidb cluster
The traversal methods of binary tree mainly include: first order traversal, middle order traversal, second order traversal, and hierarchical traversal. First order, middle order, and second order actu
Let your HMI have more advantages. Fet-g2ld-c core board is a good choice
Real estate market trend outlook in 2022
20_Redis_哨兵模式
Base64 coding can be understood this way
[solution] educational codeforces round 82
Table responsive layout tips
Mavn builds nexus private server
HUSTPC2022
Tidb cross data center deployment topology
数据分析思维分析方法和业务知识——业务指标