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

raw_coordinates not in outputs #12

Open
martinazapletalova opened this issue May 9, 2024 · 1 comment
Open

raw_coordinates not in outputs #12

martinazapletalova opened this issue May 9, 2024 · 1 comment

Comments

@martinazapletalova
Copy link

Hi, I'm trying to use your code in the colab notebook to add postprocessing to coreML yolo model. But I'm running into issue:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
[<ipython-input-18-e52d81475349>](https://q3bkdlr8ah-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20240506-060112_RC00_630977236#) in <cell line: 1>()
----> 1 builder.set_output(output_names=["raw_confidence", "raw_coordinates"], output_dims=[
      2                     (25200, numberOfClassLabels), (25200, 4)])

[/usr/local/lib/python3.10/dist-packages/coremltools/models/neural_network/builder.py](https://q3bkdlr8ah-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20240506-060112_RC00_630977236#) in set_output(self, output_names, output_dims)
    522         spec = self.spec
    523         for idx, dim in enumerate(output_dims):
--> 524             spec.description.output[idx].type.multiArrayType.ClearField("shape")
    525             spec.description.output[idx].type.multiArrayType.shape.extend(dim)
    526             spec.description.output[

IndexError: list index (1) out of range

in step:

    builder.set_output(output_names=["raw_confidence", "raw_coordinates"], output_dims=[
                       (25200, numberOfClassLabels), (25200, 4)])

I've checked builder.spec.description.output and I can see only this:

 [name: "raw_confidence"
type {
  multiArrayType {
    shape: 25200
    shape: 80
    dataType: DOUBLE
  }
}
]

even though the layer with concat_coordinates is there b/c I'm getting ValueError: Layer with name "concat_coordinates" has already been added. Please use a unique name.

@martinazapletalova
Copy link
Author

martinazapletalova commented May 9, 2024

At the end I've found solution in your medium article in comments that I have to add:

builder.spec.description.output.add()
before

builder.set_output(output_names=["raw_confidence", "raw_coordinates"], output_dims=[
                       (25200, numberOfClassLabels), (25200, 4)])

but now I have different problem when predicting:
Error compiling model: "compiler error: Error reading protobuf spec. validator error: Layer 'concat_confidence' of type 980 has 1 inputs but expects at least 2.

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

No branches or pull requests

1 participant