-
大小: 4KB文件類型: .py金幣: 2下載: 1 次發布日期: 2021-01-10
- 語言: Python
- 標簽: 計算miou??tensorflow??miou代碼??
資源簡介
# 執行命令:
python miou.py --labels=D:/.../labels --pred=D:/../infer
# 其中 --labels 為標注圖片路徑 --pred 為預測出的圖片路徑
# 最終結果會打印輸出,也會在同級目錄下,生成一個txt文檔,保存各個類別 iou
# 操作極為簡單
代碼片段和文件信息
#?執行命令:
#?python?miou.py?--labels=D:/.../labels?--pred=D:/../infer
#?其中??--labels?為標注圖片路徑????--pred?為預測出的圖片路徑
#?會在同級目錄下,生成一個txt文檔,保存各個類別?iou
import?argparse
import?glob
import?imageio
import?numpy?as?np
import?os
import?tensorflow?as?tf
import?time
import?pandas?as?pd
import?seaborn?as?sn
import?matplotlib.pyplot?as?plt
from?matplotlib?import?gridspec
from?datetime?import?datetime
from?tensorflow.python.client?import?device_lib
from?socket?import?gethostname
import?itertools
def?_calc_metrics(predictions?labels?n_classes):
????with?tf.variable_scope(“metrics“):
????????mean_iou?mean_iou_op?=?tf.metrics.mean_iou(
????????????labels=labels
????????????predictions=predictions
????????????num_classes=n_classes
????????????name=‘my_miou‘)
????????conf_m
評論
共有 條評論