e-lab / LinkNet

168 stars 42 forks source link

Model input/output details? #13

Closed seantempesta closed 6 years ago

seantempesta commented 6 years ago

Hi,

I'm having a hell of a time trying to understand what the model is expecting in terms of input and output. I'm trying to use this model in an iOS project, so I need to convert the model to Apple's CoreML format.

Image input questions:

Prediction output:

So far I'm having the best luck with these specifications:

import torch
from torch2coreml import convert
from torch.utils.serialization import load_lua

model = load_lua("model-cs-IoU-cpu.net")

input_shape = (3, 512, 1024)
coreml_model = convert(
        model,
        [input_shape],
        input_names=['inputImage'],
        output_names=['outputImage'],
        image_input_names=['inputImage'],
        preprocessing_args={
            'image_scale': 2/255.0
        }
    )
coreml_model.save("/home/sean/Downloads/Final/model-cs-IoU.mlmodel")
codeAC29 commented 6 years ago

Input should be between 0-1 and it should be RGB. Shape of the output is # of classes, height, width. Predictions can be negative values too. You can pass it through a sigmoid if you want them to be between 0-1.

seantempesta commented 6 years ago

Thank you.