Skip to content

Previously working code has stopped to work with import error #375

Closed
@jhennies

Description

@jhennies

Hi all,

Due to my stuff not working anymore complaining about some pytorch internal issue and core-dumps, I re-installed my conda environment but still my previously working code won't work due to some import error (code and error below).

Is this a me-problem or might something be broken on the bioimage-io side?

This is what I have installed:

bioimageio.core           0.5.11             pyhd8ed1ab_0    conda-forge
bioimageio.spec           0.5.1              pyhd8ed1ab_0    conda-forge

Code:

def run_cebra_net(
        input_data
):

    # Set up the model
    try:
        rdf_path = os.path.join(
            get_repo_path(), 'models', 'cebranet-cellular-membranes-in-volume-sem_torchscript.zip'
        )
        print(f'rdf_path = {rdf_path}')
        model_resource = bioimageio.core.load_resource_description(rdf_path)
    except TypeError:
        rdf_doi = "10.5281/zenodo.7274275"
        model_resource = bioimageio.core.load_resource_description(rdf_doi)

    # Prepare the data
    input_array = xr.DataArray(input_data[None, None, :], dims=tuple(model_resource.inputs[0].axes))

    # Set up the prediction pipeline
    devices = None
    weight_format = None
    prediction_pipeline = bioimageio.core.create_prediction_pipeline(
        model_resource, devices=devices, weight_format=weight_format
    )

    # Make sure the input and output shapes match
    prediction_pipeline.input_specs[0].shape = prediction_pipeline.output_specs[0].shape
    tiling = True

    # Predict with tiling
    result = bioimageio.core.predict_with_tiling(prediction_pipeline, input_array, tiling=tiling, verbose=True)[0]

    return (result[0, 0, :] * 255).astype('uint8')

Error:

/home/julian/miniconda3/envs/cebra-em-all-env/lib/python3.9/site-packages/networkx/utils/backends.py:135: RuntimeWarning: networkx backend defined more than once: nx-loopback
  backends.update(_get_backends("networkx.backends"))
Traceback (most recent call last):
  File "/media/julian/Data/tmp/test_cebra_em/proj/.snakemake/scripts/tmpehogir6d.run_task.py", line 17, in <module>
    from cebra_em_core.bioimageio.cebra_net import run_cebra_net
  File "/media/julian/Data/src/github/jhennies/CebraEM/cebra-em-core/cebra_em_core/bioimageio/cebra_net.py", line 2, in <module>
    import bioimageio.core
  File "/home/julian/miniconda3/envs/cebra-em-all-env/lib/python3.9/site-packages/bioimageio/core/__init__.py", line 6, in <module>
    from .resource_io import (
  File "/home/julian/miniconda3/envs/cebra-em-all-env/lib/python3.9/site-packages/bioimageio/core/resource_io/__init__.py", line 2, in <module>
    from .io_ import (
  File "/home/julian/miniconda3/envs/cebra-em-all-env/lib/python3.9/site-packages/bioimageio/core/resource_io/io_.py", line 11, in <module>
    from bioimageio.core.resource_io.nodes import ResourceDescription
  File "/home/julian/miniconda3/envs/cebra-em-all-env/lib/python3.9/site-packages/bioimageio/core/resource_io/nodes.py", line 9, in <module>
    from bioimageio.spec.model import raw_nodes as model_raw_nodes
ImportError: cannot import name 'raw_nodes' from 'bioimageio.spec.model' (/home/julian/miniconda3/envs/cebra-em-all-env/lib/python3.9/site-packages/bioimageio/spec/model/__init__.py)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions