首页 > 其他分享 >论文写作中不同模型输出对比

论文写作中不同模型输出对比

时间:2024-01-16 11:44:06浏览次数:24  
标签:case 输出 axs index 论文 mask 写作 path col

  • 需要自己提供,输入图像、以及对应mask还有不同模型的预测结果。
# 可视化图像、mask、不同模型的输出
import matplotlib.pyplot as plt
import cv2
from pathlib import Path
import os
from skimage import io, measure
import numpy as np

# network_name = ["CPFNet", "Deep", "Deepplus", "FPN", "LinkNet", "SegNet", "UNet", "swin", "PSPNet"]
network_name = ["CPFNet", "Deep", "Deepplus", "FPN", "swin", "PSPNet"]


# case = "wdus0000"
cases = ["wdus0000", "wdus0001", "wdus0007", "wdus0015", "wdus0016", "wdus0027",]
direction = "l1_120"
case_begin_index = 0
# case_begin_indexs = [0, 1]

image_root_path = r"/home/chaochen/Rashid/task02/Trainset/images/"
mask_root_path = r"/home/chaochen/Rashid/task02/Trainset/masks/"
output_root_path = r"/home/chaochen/Rashid/task02/imgAndcode/outall"
seg_root_path = r"/home/chaochen/Rashid/task02/imgAndcode/"

linewidth = 5


image_coutour_out = os.path.join(output_root_path, "image", rf"{case}/{direction}/{case_begin_index}_image.png")
mask_coutour_out = os.path.join(output_root_path, "mask", rf"{case}/{direction}/{case_begin_index}_mask.png")

Path(os.path.join(output_root_path, rf"mask/{case}/{direction}")).mkdir(parents=True, exist_ok=True)
Path(os.path.join(output_root_path, rf"image/{case}/{direction}")).mkdir(parents=True, exist_ok=True)

# 每一列第一行是输入图像,第二行是mask,之后每行分别是不同模型的输出

fig, axs = plt.subplots(8, 6, figsize=(80, 60), dpi=300)
for col_index in range(6):
    # case_begin_index = case_begin_indexs[col_index]
    case = cases[col_index]
    image_path = os.path.join(image_root_path, case, direction, f"{case_begin_index}.png")
    mask_path = os.path.join(mask_root_path, case, direction, f"{case_begin_index}.png")
    

    img = io.imread(image_path)
    mask = io.imread(mask_path)
    # plot image
    axs[0, col_index].imshow(img, cmap='gray')
    axs[0, col_index].axis("off")
    axs[0, col_index]
    # plot mask
    mask_contour = measure.find_contours(mask)[0]
    axs[1, col_index].imshow(mask, cmap='gray')
    axs[1, col_index].plot(mask_contour[:, 1], mask_contour[:, 0], linewidth=linewidth, color='red')
    axs[1, col_index].axis("off")


    for index, network in enumerate(network_name):
        # network = network_name[index-2]
        pred_path = os.path.join(seg_root_path, network, "test_result", case, direction, f"{case_begin_index}.png")
        pred_coutour_out = os.path.join(output_root_path, rf"{network}/{case}/{direction}/{case_begin_index}_pred.png")
        Path(os.path.join(output_root_path, rf"{network}/{case}/{direction}")).mkdir(parents=True, exist_ok=True)

        pred = io.imread(pred_path)
        mask = io.imread(mask_path)

        pred_coutour = measure.find_contours(pred)[0]
        mask_coutour = measure.find_contours(mask)[0]

        # 红色表示gt
        # 画mask 边界
        axs[index+2, col_index].plot(mask_coutour[:, 1], mask_coutour[:, 0], linewidth=linewidth, color='red')
        # # 显示mask
        # axs[index+2].imshow(mask, cmap="gray")
        # # 保存
        # axs[index+2].savefig(mask_coutour_out, bbox_inches='tight', pad_inches=0)

        # 黄色表示预测的mask
        # 画预测结果的边界
        axs[index+2, col_index].plot(pred_coutour[:, 1], pred_coutour[:, 0], linewidth=linewidth, color='yellow')
        # 显示mask
        axs[index+2, col_index].imshow(mask, cmap="gray")
        axs[index+2, col_index].axis("off")
        # axs[index+2].savefig(pred_coutour_out, bbox_inches='tight', pad_inches=0)
        # axs[index+2].clf()

plt.tight_layout()
plt.savefig('wdus0000_l1_120.png', dpi=300)
plt.show()

输出结果显示:

标签:case,输出,axs,index,论文,mask,写作,path,col
From: https://www.cnblogs.com/Flashcc/p/17967324

相关文章

  • linux下NTFS磁盘报错输入输出错误
    title:linux下NTFS磁盘报错输入输出错误banner_img:https://cdn.studyinglover.com/pic/2023/12/334c0c129076533308cbc7e03f8c55be.pngdate:2024-1-1522:50:00tags:-踩坑linux下NTFS磁盘报错输入输出错误简单来说就是我在linux下挂载了一个NTFS格式的移动硬盘,然后在......
  • Java运用构造方法,计算并输出两点间的距离
    importjava.util.Scanner;publicclassjavaTest{publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubdoublex1,y1,x2,y2;Scannersc=newScanner(System.in);while(sc.hasNext()){x1=sc.nextDo......
  • GPIO的输入与输出
    一.GPIO简介二.GPIO基本结构寄存器是特殊的存储器,内核可用通过APB2总线对寄存器进行读写,寄存器每一位对应一个引脚。输出寄存器写1,对应引脚输出高电平;输入寄存器写1,则证明对应端口为高电平。其中寄存器只负责存储数据,驱动器用来驱动。三.GPIO位结构左边三个为寄存器,中间......
  • python logging 禁止日志输出
    1只会禁用特定日志记录器,其他日志记录器仍可以将消息输出到控制台格式:logging.getLogger("某日志记录器").disabled=True例:logging.getLogger("tornado").disabled=True2阻止这些日志记录器将日志消息传播到更高级别的父级记录器,从而不会显示在控制台上;请注意,其他日志......
  • ICLR 2022: Anomaly Transformer论文阅读笔记(2) 深度解析代码
    AnomalyTransformer是一个由Transformer:AttentionIsAllYouNeed启发出的检测时间序列异常点的无监督学习算法。在这一篇我会深度解析论文算法以及代码的一一对应,让人更方便能读懂和使用源代码。阅读笔记前篇:ICLR2022:AnomalyTransformer论文阅读笔记+代码复现阅读前提......
  • 基于SSM的论文投稿系统
    本文介绍了论文投稿系统的开发全过程。通过分析企业对于论文投稿系统的需求,创建了一个计算机管理论文投稿系统的方案。文章介绍了论文投稿系统的系统分析部分,包括可行性分析等,系统设计部分主要介绍了系统功能设计和数据库设计。本论文投稿系统有管理员和用户两个角色。用户功能有......
  • (△△△)开发一个坐标计算工具, A表示向左移动,D表示向右移动,W表示向上移动,S表示向下移动
    描述开发一个坐标计算工具,A表示向左移动,D表示向右移动,W表示向上移动,S表示向下移动。从(0,0)点开始移动,从输入字符串里面读取一些坐标,并将最终输入结果输出到输出文件里面。输入:合法坐标为A(或者D或者W或者S)+数字(两位以内)坐标之间以;分隔。非法坐标点需要进行丢弃。如AA10;......
  • 【论文阅读笔记】【OCR-End2End】 TextFormer: A Query-based End-to-End Text Spotte
    TextFormerarXiv:2306.03377读论文思考的问题论文试图解决什么问题?写作背景是什么?问题:如何设计一种更好的query-based的方法来同时实现端到端的场景文本检测能否利用弱监督数据(只有文本)进一步增强端到端模型的文本识别能力?背景:目前的端到端场景文本检测识别......
  • 领域泛化+异常检测相关论文阅读整理
    AnomalyDetectionunderDistributionShiftICCV2023用于异常检测的无监督方法。训练集仅使用sourcedistribution的normal数据。测试集使用source和targetdistribution的数据,包含normal和anomaly。认为在ADtask中,训练数据通常只有一类。目前用于分类、检测和分割的OOD......
  • 无涯教程-LISP - 输入&输出
    常见的LISP提供许多输入输出函数,我们已经使用了格式化函数和打印函数进行输出,在本节中,我们将研究LISP中提供的一些最常用的输入输出函数。Read函数下表提供了LISP最常用的输入函数-Sr.No.Function&描述1read&optionalinput-streameof-error-peof-valuerecursive-p......