whaifree
82acfa83dc
- 新增dataprocessing.py脚本,实现图像数据处理功能,包括文件读取、格式转换、低对比度筛选等 - 新增H5Dataset类,用于加载和访问H5格式的图像数据集 - 在项目中配置远程服务器部署和代码自动上传 - 添加IDE配置文件,包括项目路径、模块管理、代码检查等设置
22 lines
629 B
Python
22 lines
629 B
Python
import torch.utils.data as Data
|
|
import h5py
|
|
import numpy as np
|
|
import torch
|
|
|
|
class H5Dataset(Data.Dataset):
|
|
def __init__(self, h5file_path):
|
|
self.h5file_path = h5file_path
|
|
h5f = h5py.File(h5file_path, 'r')
|
|
self.keys = list(h5f['ir_patchs'].keys())
|
|
h5f.close()
|
|
|
|
def __len__(self):
|
|
return len(self.keys)
|
|
|
|
def __getitem__(self, index):
|
|
h5f = h5py.File(self.h5file_path, 'r')
|
|
key = self.keys[index]
|
|
IR = np.array(h5f['ir_patchs'][key])
|
|
VIS = np.array(h5f['vis_patchs'][key])
|
|
h5f.close()
|
|
return torch.Tensor(VIS), torch.Tensor(IR) |