Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deserialization by applying RoiWrapper #56

Closed
wants to merge 5 commits into from

Conversation

JonasHell
Copy link
Contributor

Should fix the issue by applying the RoiWrapper while unpickling.
Sample Code:

import numpy as np
import pickle
from torch_em.data import RawDataset, SegmentationDataset

path = '/g/kreshuk/hellgoth/domain_adaptation/data/cremi/sample_A_20160501_copy.hdf5'
raw_key = 'volumes/raw' # (125, 1250, 1250)
label_key = 'volumes/labels/neuron_ids' # (125, 1250, 1250)

# RawDataset
ds_raw = RawDataset(
    raw_path=path,
    raw_key=raw_key,
    patch_shape=(32, 256, 256),
    roi=np.s_[:50, :1000, :1000]
)

print(ds_raw)
print(ds_raw.raw.shape) # (50, 1000, 1000)

with open('test_file', 'wb') as f:
    pickle.dump(ds_raw, f)

with open('test_file', 'rb') as f:
    ds_loaded_raw = pickle.load(f)

print(ds_loaded_raw)
print(ds_loaded_raw.raw.shape) # old behavior: (125, 1250, 1250), new behavior: (50, 1000, 1000)


# SegmentationDataset
ds_seg = SegmentationDataset(
    raw_path=path,
    raw_key=raw_key,
    label_path=path,
    label_key=label_key,
    patch_shape=(32, 256, 256),
    roi=np.s_[:50, :1000, :1000]
)

print(ds_seg)
print(ds_seg.raw.shape) # (50, 1000, 1000)
print(ds_seg.labels.shape) # (50, 1000, 1000)

with open('test_file2', 'wb') as f:
    pickle.dump(ds_seg, f)

with open('test_file2', 'rb') as f:
    ds_loaded_seg = pickle.load(f)

print(ds_loaded_seg)
print(ds_loaded_seg.raw.shape) # old behavior: (125, 1250, 1250), new behavior: (50, 1000, 1000)
print(ds_loaded_seg.labels.shape) # old behavior: (125, 1250, 1250), new behavior: (50, 1000, 1000)

@constantinpape
Copy link
Owner

Thanks for working on this, but already fixed in #55.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants