BiomedSciAI/histocartography

RuntimeError: unexpected EOF, expected 4530578 more bytes. The file might be corrupted.

yangyang117 opened this issue · 4 comments

from histocartography.preprocessing import (
VahadaneStainNormalizer, # stain normalizer
NucleiExtractor, # nuclei detector
DeepFeatureExtractor, # feature extractor
KNNGraphBuilder, # kNN graph builder
ColorMergedSuperpixelExtractor, # tissue detector
DeepFeatureExtractor, # feature extractor
RAGGraphBuilder, # build graph
AssignmnentMatrixBuilder # assignment matrix
)

nuclei_detector = NucleiExtractor()

when this code is running, the mistake is:

图片

File already downloaded.
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'histocartography.ml.models.hovernet.HoverNet' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'histocartography.ml.models.hovernet.Encoder' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'histocartography.ml.models.hovernet.Conv2dWithActivation' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'histocartography.ml.models.hovernet.BNReLU' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'torch.nn.modules.activation.ReLU' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'histocartography.ml.models.hovernet.ResidualBlock' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'histocartography.ml.models.hovernet.SamepaddingLayer' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'histocartography.ml.models.hovernet.Decoder' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'histocartography.ml.models.hovernet.Upsample2x' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'torch.nn.modules.upsampling.Upsample' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'histocartography.ml.models.hovernet.DenseBlock' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
Traceback (most recent call last):
File "", line 1, in
File "/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/histocartography/preprocessing/nuclei_extraction.py", line 82, in init
self._load_model_from_path(model_path)
File "/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/histocartography/preprocessing/nuclei_extraction.py", line 88, in _load_model_from_path
self.model = torch.load(model_path)
File "/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py", line 595, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/home/yyang3/anaconda3/envs/yy/lib/python3.6/site-packages/torch/serialization.py", line 781, in _legacy_load
deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: unexpected EOF, expected 4530578 more bytes. The file might be corrupted.

might be related to your pytorch version. Which one do you use?

I use the pytorch 1.7.0, which version do you recommend?

Can you try with:

  • torch==1.3.1
  • manually delete the files that have been downloaded -- it's possible that for some reason when previously downloading the nuclei detector model, an error occured, explaining why when trying to re-load it locally, it finds it corrupted