Calculation results are fixed

Even if I change the input texture, a fixed value (885) will be returned.
I tried collecting other model data, but a fixed value was returned.
If there is no change in the return value, what part is most likely to be the cause?

I am experimenting by replacing the model of Unity’s official Sentis sample.

sentis:1.2.0-exp2

Model data: inception-v1-12

This is the code for the input part.

            // load the neural network model from the asset:
            Model model = ModelLoader.Load(mnistONNX);
            
            
            // create the neural network engine:
            engine = WorkerFactory.CreateWorker(backendType, model);
            
            
            
            ITensorAllocator allocator=new TensorCachingAllocator();

            // CreateOps allows direct operations on tensors.
            ops = WorkerFactory.CreateOps(backendType, allocator);

            //The camera which we'll be using to calculate the rays on the image:
            lookCamera = Camera.main;
            
            
            TensorShape shape = new TensorShape(3, 1, 3);
            
            // Convert the texture into a tensor, it has width=W, height=W, and channels=1:    

            int imageSize = 224;
            int imageChannel = 3;
            TextureTransform swizzleChannels = new TextureTransform()
                .SetDimensions(imageSize, imageSize, imageChannel)
                .SetTensorLayout(0,1,2,3);
            
            inputTensor = TextureConverter.ToTensor(drawableTexture,swizzleChannels);
            Dictionary<string, Tensor> inputTensors = new Dictionary<string, Tensor>()
            {
                { "data_0", inputTensor },
            };

Most likely that your input doesn’t change. Or you are not reading correctly from your output.
inception has a 1,1000 output tensor.
Which value doesn’t change?

It was written in a confusing way. sorry.

It seems that the 885th tensor is always the largest number.

I think the correct move is
I think that by changing from a landscape photo to a photo with people in it, the numbers other than 885th will become the largest.
I tried changing about 4 photos, but the 885th one ended up being the largest number.

I’m not sure.
Do you know what classes map to each output index?
Double check that.
Also make sure your input is in the correct range (0-1, 0-255…)

I think the returned value is a Float array.
I think the array is 1000 Float values.
The idea is that “the highest number in this array will be the closest one in this learning data.”

Regarding the data being passed,
I think it is converted into a tensor using the TextureConverter class and passed.
As for the order of the data to be passed, I am not sure if it is correct as I have tried and tried to ensure that there are no errors.

How to check if the data order is correct?
SetTensorLayout method of TextureTransform and
Should I check the README of the learning data or the information in the Inspector that is displayed when selecting the learning data on Unity?
No matter what order I use, the values returned are not likely to be correct and I don’t know.

I was mentioning regarding your model.
Does the model take in a texture with values in 0-255 or 0-1?
Also the class detected. Does it match the class in the image?

Does the model take in a texture with values in 0-255 or 0-1?
→What item should I look at to understand this?

That’s your model. Depends where you got it, what’s the training data…
I wouldn’t know

This is the training data reference.

As per my knowledge, I could not identify the range of input data.

The range of input data is
0~1
0~255
I thought it would be faster to try both patterns,
I couldn’t figure out how to convert the input data.
What is the best way to prepare input data in the range 0 to 1?
https://docs.unity3d.com/Packages/com.unity.sentis@1.2/manual/create-an-input-tensor.html

The issue is known internally as Task 191

Thank you so much for your response, it solved my problem too.

1 Like