No surprise, image classification would be a great addition to image but for some reason I can’t fathom, starting up Nx.Serving
is failing with:
06:30:13.408 [notice] Application image exited: exited in: Image.Application.start(:normal, [])
** (EXIT) exited in: GenServer.call(EXLA.Client, {:client, :host, [platform: :host]}, :infinity)
** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
Which suggests there is a failure starting EXLA.Client
.
If I don’t configure EXLA
then the app starts fine. But no surprise - the binary backend isn’t suited to this kind of work and I lose patience after 5 minutes of a test run 
Any help would be appreciated - I’m pretty sure this is a stupid user error. Here’s the relevant info: (Mac ARM, OTP 25, Elixir 1.14)
# Image.Application
defmodule Image.Application do
@moduledoc false
use Application
def start(_type, _args) do
Supervisor.start_link(
[
{Nx.Serving, serving: Image.Classification.serving(), name: Image.Serving, batch_timeout: 100}
],
strategy: :one_for_one
)
end
end
# Image.Classification
defmodule Image.Classification do
alias Vix.Vips.Image, as: Vimage
def serving(model \\ "microsoft/resnet-50", featurizer \\ "microsoft/resnet-50") do
{:ok, model_info} = Bumblebee.load_model({:hf, model})
{:ok, featurizer} = Bumblebee.load_featurizer({:hf, featurizer})
Bumblebee.Vision.image_classification(model_info, featurizer,
top_k: 1,
compile: [batch_size: 10],
defn_options: [compiler: EXLA]
)
end
def classify(%Vimage{} = image) do
with {:ok, binary} <- Image.to_nx(image) do
Nx.Serving.batched_run(Image.Serving, binary)
end
end
end
# mix.exs
defp deps do
[
...
# For NX interchange and
# Bumblebee for image classification
if(otp_release() >= 24, do: [
{:nx, "~> 0.4.1", optional: true},
{:bumblebee, "~> 0.1.0", optional: true},
{:exla, "~> 0.4.1", optional: true}
]),
...
]
|> List.flatten()
|> Enum.reject(&is_nil/1)
end
# dev.exs
config :nx,
default_backend: EXLA.Backend