当前位置:网站首页>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)
边栏推荐
- Tidb cross data center deployment topology
- 数据库内容输出有问题怎么解决
- 学习使用php实现公历农历转换的方法代码
- How to avoid 7 common problems in mobile and network availability testing
- TiDB数据迁移工具概览
- Learn the method code of using PHP to realize the conversion of Gregorian calendar and lunar calendar
- List集合&UML图
- Tidb data migration scenario overview
- yolo格式数据集处理(xml转txt)
- 04_ 栈
猜你喜欢

Markdown tutorial
![[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)

List集合&UML图

16_ Redis_ Redis persistence

表格响应式布局小技巧

18_ Redis_ Redis master-slave replication & cluster building
![[noi simulation] Elis (greedy, simulation)](/img/a2/f8c8ab3bc8dd779327be3f76990976.png)
[noi simulation] Elis (greedy, simulation)

16_Redis_Redis持久化

07_ Hash

19_Redis_宕机后手动配置主机
随机推荐
I made an istio workshop. This is the first introduction
TiDB数据迁移场景综述
二叉树的遍历方式主要有:先序遍历、中序遍历、后序遍历、层次遍历。先序、中序、后序其实指的是父节点被访问的次序。若在遍历过程中,父节点先于它的子节点被访问,就是先序遍历;
LeetCode_ String_ Simple_ 412.Fizz Buzz
Facing the challenge of "lack of core", how can Feiling provide a stable and strong guarantee for customers' production capacity?
原则、语言、编译、解释
16_ Redis_ Redis persistence
Guangzhou Emergency Management Bureau issued a high temperature and high humidity chemical safety reminder in July
Map introduction
Tidb data migration scenario overview
C thread transfer parameters
MFC timer usage
Tidb data migration tool overview
TiDB 集群最小部署的拓扑架构
20_Redis_哨兵模式
Application of CDN in game field
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
Deploy tidb cluster with tiup
C RichTextBox controls the maximum number of lines displayed
18_ Redis_ Redis master-slave replication & cluster building