当前位置:网站首页>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)
边栏推荐
- 二叉树的遍历方式主要有:先序遍历、中序遍历、后序遍历、层次遍历。先序、中序、后序其实指的是父节点被访问的次序。若在遍历过程中,父节点先于它的子节点被访问,就是先序遍历;
- Record an interview
- Case introduction and problem analysis of microservice
- Internet Explorer officially retired
- Base64 编码原来还可以这么理解
- 12_ Redis_ Bitmap_ command
- Mavn 搭建 Nexus 私服
- TiDB 集群最小部署的拓扑架构
- 学习使用php实现公历农历转换的方法代码
- 让您的HMI更具优势,FET-G2LD-C核心板是个好选择
猜你喜欢

16_ Redis_ Redis persistence

. Net core logging system

Kibana basic operation

yolo格式数据集处理(xml转txt)

FPGA - 7系列 FPGA内部结构之Clocking -03- 时钟管理模块(CMT)
![[noi Simulation Competition] scraping (dynamic planning)](/img/ee/27a07f80207a2925f5065e633eb39f.png)
[noi Simulation Competition] scraping (dynamic planning)
![[c voice] explain the advanced pointer and points for attention (2)](/img/fb/515e25899bd9a2905ee63cb041934a.png)
[c voice] explain the advanced pointer and points for attention (2)

Internet Explorer officially retired

FPGA - clock-03-clock management module (CMT) of internal structure of 7 Series FPGA

学习使用php将时间戳转换为大写日期的方法代码示例
随机推荐
05_ queue
Markdown tutorial
php获取数组中键值最大数组项的索引值的方法
学习使用php将时间戳转换为大写日期的方法代码示例
GeoServer offline map service construction and layer Publishing
Principles, language, compilation, interpretation
Application and practice of Jenkins pipeline
Kibana basic operation
14_ Redis_ Optimistic lock
Apprendre le Code de la méthode de conversion du calendrier lunaire grégorien en utilisant PHP
FPGA - 7系列 FPGA内部结构之Clocking -03- 时钟管理模块(CMT)
19_Redis_宕机后手动配置主机
基于RZ/G2L | OK-G2LD-C开发板存储读写速度与网络实测
03_线性表_链表
Deploy tidb cluster with tiup
18_ Redis_ Redis master-slave replication & cluster building
HUSTPC2022
17_Redis_Redis发布订阅
FPGA - clock-03-clock management module (CMT) of internal structure of 7 Series FPGA
05_队列