Skip to content

Commit

Permalink
drop hdf5storage
Browse files Browse the repository at this point in the history
  • Loading branch information
felixdittrich92 committed Sep 25, 2024
1 parent 0d84464 commit 4fa913f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ contrib = [
testing = [
"pytest>=5.3.2",
"coverage[toml]>=4.5.4",
"hdf5storage>=0.1.18",
"onnxruntime>=1.11.0",
"requests>=2.20.0",
"psutil>=5.9.5"
Expand Down Expand Up @@ -112,7 +111,6 @@ dev = [
# Testing
"pytest>=5.3.2",
"coverage[toml]>=4.5.4",
"hdf5storage>=0.1.18",
"onnxruntime>=1.11.0",
"requests>=2.20.0",
"psutil>=5.9.5",
Expand Down
39 changes: 24 additions & 15 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from io import BytesIO

import cv2
import hdf5storage
import numpy as np
import pytest
import requests
Expand Down Expand Up @@ -257,24 +256,34 @@ def mock_imgur5k(tmpdir_factory, mock_image_stream):
def mock_svhn_dataset(tmpdir_factory, mock_image_stream):
root = tmpdir_factory.mktemp("datasets")
svhn_root = root.mkdir("svhn")
train_root = svhn_root.mkdir("train")
file = BytesIO(mock_image_stream)

# NOTE: hdf5storage seems not to be maintained anymore, ref.: https://github.com/frejanordsiek/hdf5storage/pull/134
# Instead we download the mocked data which was generated using the following code:
# ascii image names
first = np.array([[49], [46], [112], [110], [103]], dtype=np.int16) # 1.png
second = np.array([[50], [46], [112], [110], [103]], dtype=np.int16) # 2.png
third = np.array([[51], [46], [112], [110], [103]], dtype=np.int16) # 3.png
# first = np.array([[49], [46], [112], [110], [103]], dtype=np.int16) # 1.png
# second = np.array([[50], [46], [112], [110], [103]], dtype=np.int16) # 2.png
# third = np.array([[51], [46], [112], [110], [103]], dtype=np.int16) # 3.png
# labels: label is also ascii
label = {
"height": [35, 35, 35, 35],
"label": [1, 1, 3, 7],
"left": [116, 128, 137, 151],
"top": [27, 29, 29, 26],
"width": [15, 10, 17, 17],
}

matcontent = {"digitStruct": {"name": [first, second, third], "bbox": [label, label, label]}}
# label = {
# "height": [35, 35, 35, 35],
# "label": [1, 1, 3, 7],
# "left": [116, 128, 137, 151],
# "top": [27, 29, 29, 26],
# "width": [15, 10, 17, 17],
# }

# matcontent = {"digitStruct": {"name": [first, second, third], "bbox": [label, label, label]}}
# Mock train data
train_root = svhn_root.mkdir("train")
hdf5storage.write(matcontent, filename=train_root.join("digitStruct.mat"))
# hdf5storage.write(matcontent, filename=train_root.join("digitStruct.mat"))

# Downloading the mocked data
url = "https://github.com/mindee/doctr/releases/download/v0.9.0/digitStruct.mat"
response = requests.get(url)
with open(train_root.join("digitStruct.mat"), "wb") as f:
f.write(response.content)

for i in range(3):
fn = train_root.join(f"{i + 1}.png")
with open(fn, "wb") as f:
Expand Down

0 comments on commit 4fa913f

Please sign in to comment.