spikezoo.pipeline

__init__(cfg, model_cfg, dataset_cfg)

pipeline 初始化函数,需要分别指定 pipeline, modeldataset 的配置参数

参数:
  • cfg -- 管线实例化参数

  • model -- 支持输入模型实例化参数或模型名称

  • dataset -- 支持输入数据集实例化参数或数据集名称

from spikezoo.pipeline import Pipeline, PipelineConfig
import spikezoo as sz
pipeline = Pipeline(
    cfg=PipelineConfig(save_folder="results",version="v023"),
    model_cfg=sz.METHOD.BASE,
    dataset_cfg=sz.DATASET.BASE
)
infer_from_dataset(self, idx=0)

直接从 pipeline 中给定的数据集进行推理,包含指标测试和性能指标计算两部分,结果保存在输出路径的 infer_from_dataset 文件夹下。

参数:

idx (int) -- 管线实例化参数

pipeline.infer_from_dataset(idx=0)
infer_from_file(self, file_path, height=-1, width=-1, rate=1, img_path=None, remove_head=False)

从给定输入脉冲文件进行推理,包含指标测试和性能指标计算两部分,结果保存在输出路径的 infer_from_file 文件夹下。

参数:
  • file_path (str) -- 输入脉冲文件路径

  • height (int) -- 输入脉冲的高度

  • width (int) -- 输入脉冲的宽度

  • rate (float) -- 脉冲转化系数,对重构图像亮度进行矫正, img = img / rate

  • img_path (str) -- 输入清晰图像的路径,用于脉冲重构图像的指标(如果不提供只会计算非参考指标)

  • remove_head (bool) -- 是否移除帧头(针对真实拍摄数据)

# without gt (for calculating psnr,ssim and lpips)
pipeline.infer_from_file(file_path='data/data.dat',width=400,height=250)
# with gt (only niqe and brisque)
pipeline.infer_from_file(file_path = 'data/data.dat',width = 400,height=250,img_path= "data/data.png",rate = 0.6)
# for real-captured data with frame index
pipeline.infer_from_file(file_path='realworld.dat',width=416,height=250,remove_head=True)
infer_from_spk(self, spike, rate=1, img=None)

利用给定输入脉冲进行推理,包含指标测试和性能指标计算两部分,结果保存在输出路径的 infer_from_spk 文件夹下。

参数:
  • spike (array or tensor) -- 输入脉冲

  • rate (float) -- 脉冲转化系数,对重构图像亮度进行矫正, img = img / rate

  • img (array) -- 输入清晰图像,用于脉冲重构图像的指标(如果不提供只会计算非参考指标)

import spikezoo as sz
import cv2
spike = sz.load_vidar_dat("data/data.dat",width=400,height=250)
img = cv2.imread("data/data.png")
# without gt (for calculating psnr,ssim,lpips,niqe and brisque)
pipeline.infer_from_spk(spike)

# with gt (only niqe and brisque)
pipeline.infer_from_spk(spike,img,rate = 0.6)