Flux.jl: REST API for real-time prediction

Created on 27 Oct 2019  路  2Comments  路  Source: FluxML/Flux.jl

It's unclear how to deploy a Flux model in a production environment for online prediction. It would be useful to be able to deploy a model as an HTTP endpoint exposing a REST API for real-time scoring.

TensorFlow and PyTorch both support HTTP and gRPC APIs for batch and real-time scoring.

Most helpful comment

Or with https://github.com/JuliaWeb/HTTP.jl

function predict(req)
    io = IOBuffer(HTTP.payload(req))
    x = JSON3.read(io)
    y = model(x)
    HTTP.Response(200, JSON3.write(y))
end

router = HTTP.Router()
HTTP.@register(router, "POST", "predict", predict)
HTTP.serve(router, "0.0.0.0", port)

All 2 comments

Or with https://github.com/JuliaWeb/HTTP.jl

function predict(req)
    io = IOBuffer(HTTP.payload(req))
    x = JSON3.read(io)
    y = model(x)
    HTTP.Response(200, JSON3.write(y))
end

router = HTTP.Router()
HTTP.@register(router, "POST", "predict", predict)
HTTP.serve(router, "0.0.0.0", port)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

KristofferC picture KristofferC  路  4Comments

philip-bl picture philip-bl  路  3Comments

Sheemon7 picture Sheemon7  路  3Comments

jw3126 picture jw3126  路  6Comments

MikeInnes picture MikeInnes  路  6Comments