HenriquesLab / ZeroCostDL4Mic

ZeroCostDL4Mic: A Google Colab based no-cost toolbox to explore Deep-Learning in Microscopy
MIT License
553 stars 129 forks source link

3D unet: Problem with Section 5.4, cannot download model as bioImage #288

Open jing00011 opened 1 year ago

jing00011 commented 1 year ago

Hi, I am trying out the 3D unet using the provided sample data (the mitochondria electron microscope image provided in the link). I finished the training and wanted to download the model as bioImage Model zoo to be used in FIJI in section 5.4. However, I keep getting this error message and have no idea what it's saying...


ValueError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/tifffile/tifffile.py in enumarg(enum, arg) 23590 try:

23591 return enum(arg) 23592 except Exception:

9 frames /usr/lib/python3.10/enum.py in call(cls, value, names, module, qualname, type, start) 384 if names is None: # simple value lookup --> 385 return cls.new(cls, value) 386 # otherwise, functional API: we're creating a new Enum type

/usr/lib/python3.10/enum.py in new(cls, value) 709 if result is None and exc is None: --> 710 raise ve_exc 711 elif exc is None:

ValueError: 1.25 is not a valid RESUNIT

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/tifffile/tifffile.py in enumarg(enum, arg) 23593 try:

23594 return enum[arg.upper()] 23595 except Exception as exc:

AttributeError: 'float' object has no attribute 'upper'

The above exception was the direct cause of the following exception:

ValueError Traceback (most recent call last) in <cell line: 205>() 203 204 # export the model with keras weights --> 205 build_model( 206 weight_uri=weight_path, 207 test_inputs=[test_in_path],

/usr/local/lib/python3.10/dist-packages/bioimageio/core/build_spec/build_model.py in build_model(weight_uri, test_inputs, test_outputs, input_axes, output_axes, name, description, authors, tags, documentation, cite, output_path, architecture, model_kwargs, weight_type, sample_inputs, sample_outputs, input_names, input_step, input_min_shape, input_data_range, output_names, output_reference, output_scale, output_offset, output_data_range, halo, preprocessing, postprocessing, pixel_sizes, maintainers, license, covers, git_repo, attachments, packaged_by, run_mode, parent, config, dependencies, links, training_data, root, add_deepimagej_config, tensorflow_version, opset_version, pytorch_version, weight_attachments) 829 if add_deepimagej_config: 830 if sample_inputs is None: --> 831 sample_inputs, sample_outputs = _write_sample_data( 832 test_inputs, test_outputs, input_axes, output_axes, pixel_sizes, root 833 )

/usr/local/lib/python3.10/dist-packages/bioimageio/core/build_spec/build_model.py in _write_sample_data(input_paths, output_paths, input_axes, output_axes, pixel_sizes, export_folder) 451 sample_in_path = export_folder / f"sampleinput{i}.tif" 452 pixel_size = None if pixel_sizes is None else pixel_sizes[i] --> 453 write_im(sample_in_path, inp, axes, pixel_size) 454 sample_in_paths.append(sample_in_path) 455

/usr/local/lib/python3.10/dist-packages/bioimageio/core/build_spec/build_model.py in write_im(path, im, axes, pixel_size) 444 if np.dtype(im.dtype) == np.dtype("float64"): 445 im = im.astype("float32") --> 446 tifffile.imwrite(path, im, imagej=True, resolution=resolution) 447 448 sample_in_paths = []

/usr/local/lib/python3.10/dist-packages/tifffile/tifffile.py in imwrite(file, data, bigtiff, byteorder, imagej, ome, shaped, append, shape, dtype, photometric, planarconfig, extrasamples, volumetric, tile, rowsperstrip, bitspersample, compression, compressionargs, predictor, subsampling, jpegtables, colormap, description, datetime, resolution, resolutionunit, subfiletype, software, metadata, extratags, contiguous, truncate, align, maxworkers, returnoffset) 1249 shaped=shaped, 1250 ) as tif: -> 1251 result = tif.write( 1252 data, 1253 shape=shape,

/usr/local/lib/python3.10/dist-packages/tifffile/tifffile.py in write(failed resolving arguments) 2853 unit = resolution[2] # type: ignore 2854 if unit is not None: -> 2855 resolutionunit = enumarg(RESUNIT, unit) 2856 addtag(tags, 296, 3, 1, resolutionunit) # ResolutionUnit 2857 else:

/usr/local/lib/python3.10/dist-packages/tifffile/tifffile.py in enumarg(enum, arg) 23594 return enum[arg.upper()] 23595 except Exception as exc:

23596 raise ValueError(f'invalid argument {arg!r}') from exc 23597 23598

ValueError: invalid argument 1.25

I am using OS: iOS and Chrome, would truly appreciate any help on this! Thank you !!

esgomezm commented 11 months ago

Hi @jing00011

Thank you! To confirm, is this the output of section 5.4? @mariana-gferreira could you please try to reproduce it?

jinxsfe commented 8 months ago

I also meet same problem

jinxsfe commented 8 months ago

@esgomezm

mariana-gferreira commented 7 months ago

Hi,

This error is due to the calibration voxel values given for the example image. Replace the default values with 1 and you will be able to save the model.

Screenshot 2024-01-12 at 16 19 02

Please be aware that this will result in the example image being uncalibrated and the pixel size values in the rdf.yaml being 1. These can be edited for the correct values after the model has been exported.

jinxsfe commented 7 months ago

I had replace but still can not be save for model, please seehttps://github.com/HenriquesLab/DL4MicEverywhere/issues/25

jinxsfe commented 7 months ago

image image even I change the pixel size

jinxsfe commented 7 months ago

image

jinxsfe commented 7 months ago

@mariana-gferreira