Fixing tests, adding h5py as dependency

This commit is contained in:
Caleb Robinson 2021-07-07 17:21:47 +00:00 коммит произвёл Adam J. Stewart
Родитель 2959f32ba6
Коммит 0668682112
4 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

@ -5,6 +5,7 @@ dependencies:
- gdal
- numpy
- pillow
- h5py
- setuptools>=42
- sphinx
- pytorch::pytorch>=1.7

Просмотреть файл

@ -16,3 +16,4 @@ setuptools>=42
sphinx
torch>=1.7
torchvision<0.10
h5py

Просмотреть файл

@ -44,6 +44,7 @@ datasets =
pycocotools
radiant-mlhub>=0.2.1
rarfile
h5py
# Optional developer requirements
docs =

Просмотреть файл

@ -1,16 +1,15 @@
import os
from typing import Callable, Dict, Optional
import h5py
import numpy as np
import torch
from torch import Tensor
from torchvision.datasets.utils import check_integrity
from .geo import GeoDataset
from .geo import VisionDataset
class So2Sat(GeoDataset):
class So2Sat(VisionDataset):
"""The `So2Sat <https://doi.org/10.1109/MGRS.2020.2964708>`_ dataset consists of
corresponding synthetic aperture radar and multispectral optical image data
acquired by the Sentinel-1 and Sentinel-2 remote sensing satellites, and a
@ -85,6 +84,7 @@ class So2Sat(GeoDataset):
AssertionError: if ``split`` argument is invalid
RuntimeError: if data is not found in ``root``, or checksums don't match
"""
import h5py
assert split in ["train", "validation", "test"]
self.root = root
@ -109,6 +109,8 @@ class So2Sat(GeoDataset):
Returns:
data and label at that index
"""
import h5py
with h5py.File(self.fn, "r") as f:
s1 = f["sen1"][index].astype(np.float64) # convert from <f8 to float64
s2 = f["sen2"][index].astype(np.float64) # convert from <f8 to float64