当前位置:网站首页>[paddleseg source code reading] paddleseg calculation dice
[paddleseg source code reading] paddleseg calculation dice
2022-07-04 03:37:00 【Master Fuwen】
D i c e Dice Dice Coefficient is a set similarity measure function , It is usually used to calculate the similarity of two sets , The value range is [ 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∣
∣ . ∣ |.| ∣.∣ Represents a function that takes the number of set elements
D i c e ( X , Y ) = two person hand over Set element plain Of individual Count × 2 two person element plain Count The amount And and Dice(X, Y) = \frac { The number of elements where the two intersect \times 2} { Sum of the two elements } Dice(X,Y)= two person element plain Count The amount And and two person hand over Set element plain Of individual Count ×2
PaddleSeg
In the implementation of :
def dice(intersect_area, pred_area, label_area):
""" Calculate DICE. Calculation DICE value . 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. """
# Transform the three into np.adarray
intersect_area = intersect_area.numpy()
pred_area = pred_area.numpy()
label_area = label_area.numpy()
# The number of two set elements
union = pred_area + label_area
class_dice = []
for i in range(len(intersect_area)): # Start iterating in each class
if union[i] == 0:
# If the molecule is 0, That is, the current image has no such elements
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
These three parameters are passed :
calculate_area(pred, label, num_classes, ignore_index=255)
Calculated , Follow up with a blog :
[PaddleSeg Source code reading ] PaddleSeg Calculation mIoU
边栏推荐
- 150 ppt! The most complete "fair perception machine learning and data mining" tutorial, Dr. AIST Toshihiro kamishima, Japan
- The 37 year old programmer was laid off, and he didn't find a job for 120 days. He had no choice but to go to a small company. As a result, he was confused
- National standard gb28181 protocol platform easygbs fails to start after replacing MySQL database. How to deal with it?
- Jenkins configures IP address access
- Practical multifunctional toolbox wechat applet source code / support traffic master
- Baijia forum the founding of the Eastern Han Dynasty
- Eh, the log time of MySQL server is less than 8h?
- Which product is better for 2022 annual gold insurance?
- Exercices de renforcement des déclarations SQL (MySQL 8.0 par exemple)
- @Scheduled scheduled tasks
猜你喜欢
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
SQL injection (1) -- determine whether there are SQL injection vulnerabilities
Zhihu million hot discussion: why can we only rely on job hopping for salary increase? Bosses would rather hire outsiders with a high salary than get a raise?
What kind of experience is it when the Institute earns 20000 yuan a month!
Why is it recommended that technologists write blogs?
选择排序与冒泡排序模板
Fudan released its first review paper on the construction and application of multimodal knowledge atlas, comprehensively describing the existing mmkg technology system and progress
How about the ratings of 2022 Spring Festival Gala in all provinces? Map analysis helps you show clearly!
Jenkins continuous integration environment construction V (Jenkins common construction triggers)
Objective-C description method and type method
随机推荐
Contest3145 - the 37th game of 2021 freshman individual training match_ J: Eat radish
System integration meets the three business needs of enterprises
1289_FreeRTOS中vTaskSuspend()接口实现分析
MySQL one master multiple slaves + linear replication
Objective-C string class, array class
Recursive structure
XSS prevention
What is cloud primordial?
Package details_ Four access control characters_ Two details of protected
Objective C attribute keyword
JSON string conversion in unity
Recent learning fragmentation (14)
Tsinghua University product: penalty gradient norm improves generalization of deep learning model
1day vulnerability pushback skills practice (3)
Defensive programming skills
Object oriented -- encapsulation, inheritance, polymorphism
How much does it cost to open a futures account in China? Where is it safe to open an account at present?
New year's first race, submit bug reward more!
MySQL is dirty
Value transfer communication between components (parent to child, child to parent, brother component to value)