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

Request to export bioimage zoo format and transfer into image J #25

Open
jinxsfe opened this issue Nov 29, 2023 · 15 comments
Open

Request to export bioimage zoo format and transfer into image J #25

jinxsfe opened this issue Nov 29, 2023 · 15 comments
Assignees
Labels
bug Something isn't working

Comments

@jinxsfe
Copy link

jinxsfe commented Nov 29, 2023

Hi, I had trained several models and I want to export the trained model in bioimage zoo format, but I am not clear some parameter, even I fill it, but show the error report , for example,
Screenshot 2023-11-29 at 12 34 16 PM
Screenshot 2023-11-29 at 12 34 28 PM

It's necessary to provide training data ID? what ID is and what training data source I should to be provided? I’m
Screenshot 2023-11-29 at 12 35 49 PM
what is file'ID, can you help me export model in bio image zoo? I I want to transfer the model into image J via bio image Zoo.

But the model that I had trained is zerocost4mic unet 3D, so I just want put old model in that part, but failed with DL4mic and zerocost4mic at same time

That's why I need that. can you give me some ideas for what blank should I fill? my email is [email protected]. Appreciate your help

@jinxsfe jinxsfe added the bug Something isn't working label Nov 29, 2023
@jinxsfe
Copy link
Author

jinxsfe commented Nov 29, 2023

@esgomezm

@jinxsfe
Copy link
Author

jinxsfe commented Nov 29, 2023

Screenshot 2023-11-29 at 12 50 16 PM Screenshot 2023-11-29 at 12 54 07 PM to summary, I just don't have an idea for how to fill it all blank.

@esgomezm esgomezm assigned esgomezm and unassigned IvanHCenalmor Nov 30, 2023
@jinxsfe
Copy link
Author

jinxsfe commented Jan 8, 2024

HenriquesLab/ZeroCostDL4Mic#288

I try to use colab but also meet same issue, the issue page link is there

@jinxsfe
Copy link
Author

jinxsfe commented Jan 9, 2024

@esgomezm @IvanHCenalmor

@esgomezm
Copy link
Collaborator

Hi @jinxsfe
To help you we need the following information:

  • The notebook you are using to train, test and export the model.
  • Whether you were trying to export the model directly after training. From your error message, I can see that you are trying to load "pvol-224-25-0.7-50-0.25.hdf5" which is not the type of checkpoint exported neither in ZeroCostDL4Mic nor in DL4MicEverywhere, did you add any code to the notebook?
  • If not, please, try uploading the model following the steps in section 5. Does it compute directly the steps 5.1, 5.2 and 5.3? If not, can you please provide screenshots of all the errors in order?

@jinxsfe
Copy link
Author

jinxsfe commented Jan 10, 2024

Hi, after training. I save that he model on Google Drive, can I go through quality control steps and get LOU for final model from 5.1 to 5.4.
Screenshot 2024-01-10 at 1 49 24 PM
my email is [email protected], we can set a zoom to discuss if you would , appreciate @esgomezm

@jinxsfe
Copy link
Author

jinxsfe commented Jan 10, 2024

Whether you were trying to export the model directly after training, from your error message, I can see that you are trying to load "pvol-224-25-0.7-50-0.25.hdf5" which is not the type of checkpoint exported neither in ZeroCostDL4Mic nor in DL4MicEverywhere, did you add any code to the notebook? I don't add anything in the book, the pool-224-25-0.7-50-0.25 just like name for folder, instead of any real means

@jinxsfe
Copy link
Author

jinxsfe commented Jan 10, 2024

The notebook you are using to train, test and export the model.

I had trained for long times ago, and I keeped model in my google drive, and I just want to move they into bioimage.IO and go to image J or icy.

Whether you were trying to export the model directly after training. From your error message, I can see that you are trying to load "pvol-224-25-0.7-50-0.25.hdf5" which is not the type of checkpoint exported neither in ZeroCostDL4Mic nor in DL4MicEverywhere, did you add any code to the notebook?

after finish training, the model will be save the folder, the name is "pvol-224-25-0.7-50-0.25" is name for folder, hdf5 is training record I guess

If not, please, try uploading the model following the steps in section 5. Does it compute directly the steps 5.1, 5.2 and 5.3? If not, can you please provide screenshots of all the errors in order?

I can run smoothly for 5.1-5.3, but 5.4
@esgomezm

@esgomezm
Copy link
Collaborator

Can you please indicate what is the notebook and send us screenshots of what you wrote in section 5.1? The notebook is taking the folder name as the name of the model, rather the path to the model (e.g., weights_best.hdf5). It may be that something is missing in the parameters

@jinxsfe
Copy link
Author

jinxsfe commented Jan 10, 2024

notebook is UNET3D, below is 5.0 and 5.1
@esgomezm
Screenshot 2024-01-10 at 2 29 36 PM
Screenshot 2024-01-10 at 2 30 03 PM

@jinxsfe
Copy link
Author

jinxsfe commented Jan 10, 2024

Screenshot 2024-01-10 at 2 31 57 PM for another , I have not idea how to fill the blank, what is fileID and what is training data ID, I want to move into bioimage.IO zoo but what mean for "data from bioimage.IO", data is private data,

@jinxsfe
Copy link
Author

jinxsfe commented Jan 10, 2024

@esgomezm

@jinxsfe
Copy link
Author

jinxsfe commented Jan 11, 2024

Screenshot 2024-01-10 at 8 03 45 PM error message is Predicting from checkpoint: high_to_high_288.hdf5 /usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py:3103: UserWarning: You are saving your model as an HDF5 file via `model.save()`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')`. saving_api.save_model( WARNING:tensorflow:Compiled the loaded model, but the compiled metrics have yet to be built. `model.compile_metrics` will be empty until you train or evaluate the model. The model output is not thresholded WARNING:tensorflow:5 out of the last 13 calls to .predict_function at 0x7a108f6797e0> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has reduce_retracing=True option that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/guide/function#controlling_retracing and https://www.tensorflow.org/api_docs/python/tf/function for more details. 1/1 [==============================] - 0s 353ms/step --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/tifffile/tifffile.py in enumarg(enum, arg) 23873 try: > 23874 return enum(arg) 23875 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)
23876 try:

23877 return enum[arg.upper()]
23878 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 weihgts
--> 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"sample_input
{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, mode, 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, buffersize, returnoffset)
1278 shaped=shaped,
1279 ) as tif:
-> 1280 result = tif.write(
1281 data,
1282 shape=shape,

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

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

23879 raise ValueError(f'invalid argument {arg!r}') from exc
23880
23881

ValueError: invalid argument 1.25

@jinxsfe
Copy link
Author

jinxsfe commented Jan 11, 2024

Screenshot 2024-01-10 at 8 09 11 PM

@esgomezm
Copy link
Collaborator

esgomezm commented Feb 9, 2024

hi, please, indicate the name of the model in the qc_model_name and the path as described in the guidelines of the notebook.

To export the model, try first exporting the model with the parameters by default, especially for the pixel size. You can leave all the optional parameters such as URL to training data, blanck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants