christian-kardach / AllSkyAI-ASPNetCore

MIT License
3 stars 1 forks source link

Got invalid dimensions for input: input for the following indices index: 3 Got: 1 Expected: 3 Please fix either the inputs or the model #1

Open Mr-Groch opened 7 months ago

Mr-Groch commented 7 months ago

Hi

I'm trying to start my own AllSkyAI to relieve allskyai.com server, that I'm using to classify cloud cobver for my AllSky. But unfortunately I can't run it with downloaded onnx model from allskyai.com from my profile page. This exception occurs after trying to run classification:

info: AllSkyAI_ASPNetCore.Controllers.ClassifyController[0]
Downloading AllSkyImage: https://allsky.groch.cloud/image.jpg
Download done in 0.457s, classifying image...
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HMVL3NOKRHE9", Request id "0HMVL3NOKRHE9:00000004": An unhandled exception was thrown by the application.
      System.AggregateException: One or more errors occurred. ([ErrorCode:InvalidArgument] Got invalid dimensions for input: input for the following indices
       index: 3 Got: 1 Expected: 3
       Please fix either the inputs or the model.)
       ---> Microsoft.ML.OnnxRuntime.OnnxRuntimeException: [ErrorCode:InvalidArgument] Got invalid dimensions for input: input for the following indices
       index: 3 Got: 1 Expected: 3
       Please fix either the inputs or the model.
         at Microsoft.ML.OnnxRuntime.NativeApiStatus.VerifySuccess(IntPtr nativeStatus)
         at Microsoft.ML.OnnxRuntime.InferenceSession.RunImpl(RunOptions options, IntPtr[] inputNames, IntPtr[] inputValues, IntPtr[] outputNames, DisposableList`1 cleanupList)
         at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection`1 inputs, IReadOnlyCollection`1 outputNames, RunOptions options)
         at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection`1 inputs, IReadOnlyCollection`1 outputNames)
         at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection`1 inputs)
         at AllSkyAI_ASPNetCore.OnnxClassify.ClassifyImage(String url) in /source/AllSkyAI-ASPNetCore/OnnxClassify.cs:line 101
         at AllSkyAI_ASPNetCore.Controllers.ClassifyController.<Get>b__4_0() in /source/AllSkyAI-ASPNetCore/Controllers/ClassifyController.cs:line 25
         at System.Threading.Tasks.Task`1.InnerInvoke()
         at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
      --- End of stack trace from previous location ---
         at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
         --- End of inner exception stack trace ---
         at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
         at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
         at AllSkyAI_ASPNetCore.Controllers.ClassifyController.Get() in /source/AllSkyAI-ASPNetCore/Controllers/ClassifyController.cs:line 29
         at lambda_method12(Closure, Object, Object[])
         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
         at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
christian-kardach commented 7 months ago

Hi! Oh, it’s been a while since I tested that one myself and the image input changed a bit. Let me have a look and get back to you, sounds like a simple thing to fix!

Kind regards, Chris

On Tue, 5 Dec 2023 at 07:46, Mr-Groch @.***> wrote:

Hi

I'm trying to start my own AllSkyAI to relieve allskyai.com server, that I'm using to classify cloud cobver for my AllSky. But unfortunately I can't run it with downloaded onnx model from allskyai.com from my profile page. This exception occurs after trying to run classification:

info: AllSkyAI_ASPNetCore.Controllers.ClassifyController[0] Downloading AllSkyImage: https://allsky.groch.cloud/image.jpg Download done in 0.457s, classifying image... fail: Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HMVL3NOKRHE9", Request id "0HMVL3NOKRHE9:00000004": An unhandled exception was thrown by the application. System.AggregateException: One or more errors occurred. ([ErrorCode:InvalidArgument] Got invalid dimensions for input: input for the following indices index: 3 Got: 1 Expected: 3 Please fix either the inputs or the model.) ---> Microsoft.ML.OnnxRuntime.OnnxRuntimeException: [ErrorCode:InvalidArgument] Got invalid dimensions for input: input for the following indices index: 3 Got: 1 Expected: 3 Please fix either the inputs or the model. at Microsoft.ML.OnnxRuntime.NativeApiStatus.VerifySuccess(IntPtr nativeStatus) at Microsoft.ML.OnnxRuntime.InferenceSession.RunImpl(RunOptions options, IntPtr[] inputNames, IntPtr[] inputValues, IntPtr[] outputNames, DisposableList1 cleanupList) at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection1 inputs, IReadOnlyCollection1 outputNames, RunOptions options) at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection1 inputs, IReadOnlyCollection1 outputNames) at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection1 inputs) at AllSkyAI_ASPNetCore.OnnxClassify.ClassifyImage(String url) in /source/AllSkyAI-ASPNetCore/OnnxClassify.cs:line 101 at AllSkyAI_ASPNetCore.Controllers.ClassifyController.b4_0() in /source/AllSkyAI-ASPNetCore/Controllers/ClassifyController.cs:line 25 at System.Threading.Tasks.Task1.InnerInvoke() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at AllSkyAI_ASPNetCore.Controllers.ClassifyController.Get() in /source/AllSkyAI-ASPNetCore/Controllers/ClassifyController.cs:line 29 at lambda_method12(Closure, Object, Object[]) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

— Reply to this email directly, view it on GitHub https://github.com/christian-kardach/AllSkyAI-ASPNetCore/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABV2PLSD6ZF7QF37PA52WC3YH27LPAVCNFSM6AAAAABAHFEJDWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAZDKMZZHEYDKOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

christian-kardach commented 7 months ago

Yes, found the issues. I will fix tonight and push these fixes.

Thanks for reaching out!

Kind regards, Chris

On Tue, 5 Dec 2023 at 07:46, Mr-Groch @.***> wrote:

Hi

I'm trying to start my own AllSkyAI to relieve allskyai.com server, that I'm using to classify cloud cobver for my AllSky. But unfortunately I can't run it with downloaded onnx model from allskyai.com from my profile page. This exception occurs after trying to run classification:

info: AllSkyAI_ASPNetCore.Controllers.ClassifyController[0] Downloading AllSkyImage: https://allsky.groch.cloud/image.jpg Download done in 0.457s, classifying image... fail: Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HMVL3NOKRHE9", Request id "0HMVL3NOKRHE9:00000004": An unhandled exception was thrown by the application. System.AggregateException: One or more errors occurred. ([ErrorCode:InvalidArgument] Got invalid dimensions for input: input for the following indices index: 3 Got: 1 Expected: 3 Please fix either the inputs or the model.) ---> Microsoft.ML.OnnxRuntime.OnnxRuntimeException: [ErrorCode:InvalidArgument] Got invalid dimensions for input: input for the following indices index: 3 Got: 1 Expected: 3 Please fix either the inputs or the model. at Microsoft.ML.OnnxRuntime.NativeApiStatus.VerifySuccess(IntPtr nativeStatus) at Microsoft.ML.OnnxRuntime.InferenceSession.RunImpl(RunOptions options, IntPtr[] inputNames, IntPtr[] inputValues, IntPtr[] outputNames, DisposableList1 cleanupList) at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection1 inputs, IReadOnlyCollection1 outputNames, RunOptions options) at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection1 inputs, IReadOnlyCollection1 outputNames) at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection1 inputs) at AllSkyAI_ASPNetCore.OnnxClassify.ClassifyImage(String url) in /source/AllSkyAI-ASPNetCore/OnnxClassify.cs:line 101 at AllSkyAI_ASPNetCore.Controllers.ClassifyController.b4_0() in /source/AllSkyAI-ASPNetCore/Controllers/ClassifyController.cs:line 25 at System.Threading.Tasks.Task1.InnerInvoke() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at AllSkyAI_ASPNetCore.Controllers.ClassifyController.Get() in /source/AllSkyAI-ASPNetCore/Controllers/ClassifyController.cs:line 29 at lambda_method12(Closure, Object, Object[]) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

— Reply to this email directly, view it on GitHub https://github.com/christian-kardach/AllSkyAI-ASPNetCore/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABV2PLSD6ZF7QF37PA52WC3YH27LPAVCNFSM6AAAAABAHFEJDWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAZDKMZZHEYDKOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

christian-kardach commented 7 months ago

I pushed a few changes, please pull or download latest release and try it again! Also, you need to download the labels file from the site and place it in the same directory as the model and update the config.cfg file!

Kind regards, Chris

Mr-Groch commented 7 months ago

It is working now, thanks!

One more remark - I have linux server, and it was necessary to change all \\ in paths to / in Configuration.cs and OnnxClassify.cs. Don't know if that can be also changed for windows dotnet sdk so it can be multiplatform

christian-kardach commented 7 months ago

Hi, glad it worked! I've fixed the paths so they should work as expected. Also note, I will move all the AllSkyAI to a separate account, you can get the latest here: https://github.com/AllSkyAI/AllSkyAI-ASPNetCore

Regards, Chris