Image Classification looks like hanged

Just deployed the @kip https://hex.pm/packages/image in the staging server.

While testing the Image.Classification.classify hangs. Tried the followed command locally and staging server.

Staging - Ubuntu:

iex> predictions  = Image.Classification.classify(image)

Any idea what is going on? I work like a breeze locally…

Locally:

iex(8)> predictions = Image.Classification.classify(image)
%{
  predictions: [
    %{label: "cheetah, chetah, Acinonyx jubatus", score: 0.9999818801879883},
    %{
      label: "jaguar, panther, Panthera onca, Felis onca",
      score: 1.4970299844208057e-6
    },
    %{label: "leopard, Panthera pardus", score: 5.347766318664071e-7},
    %{label: "gazelle", score: 2.296157504133589e-7},
    %{
      label: "snow leopard, ounce, Panthera uncia",
      score: 1.9233111459016072e-7
    }
  ]
}

Sounds like the Nx is running on the default binary backend which is native Elixir and very slow. Check your config.exs has:

config :nx,
  default_backend: EXLA.Backend

Awesome it works now. thanks

I’ve added it to the runtime.exs. I think it should be fine there I suppose or it has to be in config.exs?

1 Like

If you never intend to change it, then config.exs would suffice. You use runtime.exs if you want to configure something at runtime, typically used to read environment variables.

Sure… thanks :slight_smile: