-
大小: 29KB文件类型: .py金币: 1下载: 0 次发布日期: 2021-05-06
- 语言: Python
- 标签: cityscapes class IoU categery
资源简介
修改了cityscapesscripts/evaluation/vevalPixelLevelSemanticLabeling.py文件,可以实现利用符合trainId的图像评估神经网络的IoU;另外可以评估更改了分辨率的预测图像。
代码片段和文件信息
#!/usr/bin/python
#
#by yly 20180820
# This is a modified version of evalPixelLevelSemanticLabeling.py which use trainID to eval IoU;
# 1. Change the dir of groundTruth file and predition file according to you dir
# 2. GroudTruthImg can be resized to match your prediction images if the resolution of your prediction images are not 2048x1024 please change the parameter of resize in the following text
# 3. Put this scrip under cityscripts/evaluation which can be downloaded from https://github.com/mcordts/cityscapesscripts
#The 3 channel png of the prediction results is converted single channel
# The evaluation script for pixel-level semantic labeling.
# We use this script to evaluate your approach on the test set.
# You can use the script to evaluate on the validation set.
#
# Please check the description of the “getPrediction“ method below
# and set the required environment variables as needed such that
# this script can locate your results.
# If the default implementation of the method works then it‘s most likely
# that our evaluation server will be able to process your results as well.
#
# Note that the script is a lot faster if you enable cython support.
# WARNING: Cython only tested for Ubuntu 64bit OS.
# To enable cython run
# setup.py build_ext --inplace
#
# To run this script make sure that your results are images
# where pixels encode the class IDs as defined in labels.py.
# Note that the regular ID is used not the train ID.
# Further note that many classes are ignored from evaluation.
# Thus authors are not expected to predict these classes and all
# pixels with a ground truth label that is ignored are ignored in
# evaluation.
# python imports
from __future__ import print_function
import os sys
import platform
import fnmatch
try:
from itertools import izip
except ImportError:
izip = zip
# Cityscapes imports
sys.path.append( os.path.normpath( os.path.join( os.path.dirname( __file__ ) ‘..‘ ‘helpers‘ ) ) )
from csHelpers import *
# C Support
# Enable the cython support for faster evaluation
# Only tested for Ubuntu 64bit OS
CSUPPORT = True
# Check if C-Support is available for better performance
if CSUPPORT:
try:
import addToConfusionMatrix
print(‘dd‘)
except:
CSUPPORT = False
###################################
# PLEASE READ THESE INSTRUCTIONS!!!
###################################
# Provide the prediction file for the given ground truth file.
#
# The current implementation expects the results to be in a certain root folder.
# This folder is one of the following with decreasing priority:
# - environment variable CITYSCAPES_RESULTS
# - environment variable CITYSCAPES_DATASET/results
# - ../../results/“
#
# Within the root folder a matching prediction file is recursively searched.
# A file matches if the filename follows the pattern
# _123456_123456*.png
# for a ground truth filename
# _123456_123456_gtFine_labelIds.png
def getPrediction( args groundTruthFile ):
- 上一篇:fire_finder.rar
- 下一篇:密码学重合指数计算python实现
评论
共有 条评论