当前位置:网站首页>[PaddleSeg 源码阅读] PaddleSeg计算Dice
[PaddleSeg 源码阅读] PaddleSeg计算Dice
2022-07-04 03:32:00 【氵文大师】
D i c e Dice Dice 系数是一种集合相似度量函数,通常用于计算两个集合的相似度,取值范围是 [ 0 , 1 ] [0, 1] [0,1]:
D i c e ( X , Y ) = 2 ∣ X ∩ Y ∣ ∣ X ∣ + ∣ Y ∣ Dice(X, Y) = \frac {2 | X\cap Y|} { |X| + |Y| } Dice(X,Y)=∣X∣+∣Y∣2∣X∩Y∣
∣ . ∣ |.| ∣.∣ 表示取集合元素的数量函数
D i c e ( X , Y ) = 两 者 交 集 元 素 的 个 数 × 2 两 者 元 素 数 量 之 和 Dice(X, Y) = \frac {两者交集元素的个数 \times 2} {两者元素数量之和} Dice(X,Y)=两者元素数量之和两者交集元素的个数×2
PaddleSeg
中的实现:
def dice(intersect_area, pred_area, label_area):
""" Calculate DICE. 计算 DICE 值. Args: intersect_area (Tensor): The intersection area of prediction and ground truth on all classes. pred_area (Tensor): The prediction area on all classes. label_area (Tensor): The ground truth area on all classes. Returns: np.ndarray: DICE on all classes. float: mean DICE of all classes. """
# 将三者转化为 np.adarray
intersect_area = intersect_area.numpy()
pred_area = pred_area.numpy()
label_area = label_area.numpy()
# 两个集合元素的数量
union = pred_area + label_area
class_dice = []
for i in range(len(intersect_area)): # 在每一类中开始迭代
if union[i] == 0:
# 如果分子为 0,也就是当前图片没有该类元素
dice = 0
else:
dice = (2 * intersect_area[i]) / union[i]
class_dice.append(dice)
mdice = np.mean(class_dice)
return np.array(class_dice), mdice
intersect_area, pred_area, label_area
这三个参数是通过:
calculate_area(pred, label, num_classes, ignore_index=255)
来计算的,接上一篇博客:
[PaddleSeg 源码阅读] PaddleSeg计算 mIoU
边栏推荐
- The "two-way link" of pushing messages helps app quickly realize two-way communication capability
- GUI Graphical user interface programming (XIV) optionmenu - what do you want your girlfriend to wear on Valentine's day
- Defensive programming skills
- Zigzag scan
- Eh, the log time of MySQL server is less than 8h?
- PID of sunflower classic
- Pagoda SSL can't be accessed? 443 port occupied? resolvent
- Third party login initial version
- Hospital network planning and design document based on GLBP protocol + application form + task statement + opening report + interim examination + literature review + PPT + weekly progress + network to
- What are the virtual machine software? What are their respective functions?
猜你喜欢
Unity knapsack system (code to center and exchange items)
GUI Graphical user interface programming (XIV) optionmenu - what do you want your girlfriend to wear on Valentine's day
Stm32bug [stlink forced update prompt appears in keilmdk, but it cannot be updated]
Résumé: entropie, énergie libre, symétrie et dynamique dans le cerveau
3D game modeling is in full swing. Are you still confused about the future?
JVM family -- heap analysis
Unity controls the selection of the previous and next characters
Have you entered the workplace since the first 00???
Talking about custom conditions and handling errors in MySQL Foundation
Setting methods, usage methods and common usage scenarios of environment variables in postman
随机推荐
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
1day vulnerability pushback skills practice (3)
Base d'apprentissage de la machine: sélection de fonctionnalités avec lasso
Package and download 10 sets of Apple CMS templates / download the source code of Apple CMS video and film website
SQL injection (1) -- determine whether there are SQL injection vulnerabilities
PHP database connection succeeded, but data cannot be inserted
What kind of experience is it when the Institute earns 20000 yuan a month!
Management and thesis of job management system based on SSM
長文綜述:大腦中的熵、自由能、對稱性和動力學
7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages
Redis notes (I) Linux installation process of redis
3D game modeling is in full swing. Are you still confused about the future?
Consul of distributed service registration discovery and unified configuration management
Solve the problem that the tabbar navigation at the bottom of vantui does not correspond to the page (window.loading.hash)
New year's first race, submit bug reward more!
Handler source code analysis
Monitoring - Prometheus introduction
機器學習基礎:用 Lasso 做特征選擇
CSP drawing
There is no need to authorize the automatic dream weaving collection plug-in for dream weaving collection