Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

non-classifier case in coremltools4.0+ #581

Open
Guanbin-Huang opened this issue Jun 29, 2020 · 28 comments
Open

non-classifier case in coremltools4.0+ #581

Guanbin-Huang opened this issue Jun 29, 2020 · 28 comments
Assignees
Labels
bug Unexpected behaviour that should be corrected (type)

Comments

@Guanbin-Huang
Copy link

❓Question

Is it possible to convert a pytorch model withtout classification layer into mlmodel? I don't know how to do it because in the example, I am asked to specify the label.

System Information

  • If applicable
@Guanbin-Huang Guanbin-Huang added the question Response providing clarification needed. Will not be assigned to a release. (type) label Jun 29, 2020
@aseemw
Copy link
Collaborator

aseemw commented Jun 29, 2020

Just don't provide the classifier_config argument to the ct.convert call, as shown here

@Guanbin-Huang
Copy link
Author

Hi, have you ever encountered this situation?
image
One day ago, I convert my pytorch model to onnx. It works well. But now I use your tool to do the conversion directly. It seems not good.

@Guanbin-Huang
Copy link
Author

This is the complete error.
TypeError: Input strides has type <class 'coremltools.converters.mil.mil.types.type_tensor.tensor..tensor'> not compatible with expected type IntTensorInputType

@Guanbin-Huang
Copy link
Author

it works well until the 7-th part
image

@Guanbin-Huang
Copy link
Author

I run the whole thing on colab.

@Guanbin-Huang
Copy link
Author

Guanbin-Huang commented Jun 29, 2020 via email

@aseemw
Copy link
Collaborator

aseemw commented Jun 29, 2020

@HuangGuanbin can you please provide the pytorch model, which can reproduce this error? Otherwise its hard to debug the error.

@Guanbin-Huang
Copy link
Author

Guanbin-Huang commented Jun 29, 2020 via email

@Guanbin-Huang
Copy link
Author

Guanbin-Huang commented Jun 29, 2020 via email

@Guanbin-Huang
Copy link
Author

If you encountered any issue to run my code, plz let me know ASAP. I will reply to you on time.

@aseemw
Copy link
Collaborator

aseemw commented Jun 29, 2020

The colab is not accessible...

@Guanbin-Huang
Copy link
Author

Guanbin-Huang commented Jun 29, 2020 via email

@Guanbin-Huang
Copy link
Author

Guanbin-Huang commented Jun 29, 2020 via email

@Guanbin-Huang
Copy link
Author

Guanbin-Huang commented Jun 29, 2020 via email

@aseemw aseemw added bug Unexpected behaviour that should be corrected (type) and removed question Response providing clarification needed. Will not be assigned to a release. (type) labels Jun 29, 2020
@Guanbin-Huang
Copy link
Author

I changed the link of zip file by mistake. If you want to download it again. use this one. https://drive.google.com/file/d/1ufh5kndXMdWfKPRT85dDtEwhZ1MXnPg7/view?usp=sharing

@Guanbin-Huang
Copy link
Author

Guanbin-Huang commented Jun 30, 2020 via email

@Guanbin-Huang
Copy link
Author

Guanbin-Huang commented Jun 30, 2020 via email

@JialeHu
Copy link

JialeHu commented Jun 30, 2020

I had the same issue (TypeError: Input strides has type <class
'coremltools.converters.mil.mil.types.type_tensor.tensor..tensor'> not
compatible with expected type IntTensorInputType).
I am wondering if it is the issue related compatibility between coreML tensor and torch Tensor?

@Guanbin-Huang
Copy link
Author

any progress?

@quangphap208
Copy link

i had same issue:
TypeError: Input strides has type <class 'coremltools.converters.mil.mil.types.type_tensor.tensor..tensor'> not compatible with expected type IntTensorInputType

@DawerG
Copy link
Collaborator

DawerG commented Jul 5, 2020

Seems like the error message for type mismatch of input tensors is not very descriptive.
@quangphap208 @JialeHu Which models are you hitting this error on? Since type mismatch can happen in any model for different reasons. Some of the them might be bugs but others might be genuine errors. Therefore, this needs to investigated on a model basis.

@DawerG
Copy link
Collaborator

DawerG commented Jul 5, 2020

@HuangGuanbin Can you please re-convert your model after incorporating this following change?

Replace this line
strides = inputs[2]
in https://github.com/apple/coremltools/blob/e87f1d0d6ca1dc9cd812f14f777ead0bba70bf43/coremltools/converters/mil/frontend/torch/ops.py#L1421

with following code snippet

    strides = inputs[2]
    if strides.op.op_type == "const"  and (not strides.val):
        strides = mb.const(val=kernel_sizes.val, name=strides.name)

@DawerG
Copy link
Collaborator

DawerG commented Jul 5, 2020

Since this issue is not related to ONNX. For PyTorch related issues in the future, please use coremltools repository https://github.com/apple/coremltools.

@DawerG
Copy link
Collaborator

DawerG commented Jul 8, 2020

@HuangGuanbin This PR apple/coremltools#769 fixes the reported issue. Please verify if it solves your problem.

@DawerG DawerG self-assigned this Jul 8, 2020
@JialeHu
Copy link

JialeHu commented Jul 13, 2020

@HuangGuanbin This PR apple/coremltools#769 fixes the reported issue. Please verify if it solves your problem.

This solves the issue for me. Thanks a lot.

@Guanbin-Huang
Copy link
Author

strides = inputs[2]
if strides.op.op_type == "const"  and (not strides.val):
    strides = mb.const(val=kernel_sizes.val, name=strides.name)

I tried what you said, but it is not working yet.

@Guanbin-Huang
Copy link
Author

I checked the latest notification. But I'm not sure what i should modify.

@Guanbin-Huang
Copy link
Author

@JialeHu

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Unexpected behaviour that should be corrected (type)
Projects
None yet
Development

No branches or pull requests

5 participants