Model issue: Model(Flux) return same output every time in Genie.jl

I have been working on a real time speech recogniser system which can be used to play snakegame which uses Flux.jl, PortAudio.jl, GameZero.jl, Genie.jl and good amount of image and sound packages. But this genie model deployement(not a genie issue but still) is quite a issue that I am unable to fix, it must be something stupid I must be missing. Please help
API server code:

using Genie
using Genie.Router
using HTTP
import Genie.Renderer.Json: json
using Genie.Renderer.Json, Genie.Requests
using Genie.Renderer.Html
using Genie.Renderer
using Flux
using Flux.Data: DataLoader
using Flux.Optimise: Optimiser, WeightDecay
using Flux.Losses: logitcrossentropy
using BSON
using WAV
using SignalAnalysis
using Images
using Glob
using Flux: onehotbatch, onecold, normalise, Dropout
using ImageShow, ImageView
function ConvNet5(; imgsize=(28,28,1), nclasses=8) 
    out_conv_size = (imgsize[1]÷4 - 3, imgsize[2]÷4 - 3, 16)
    
    return Chain(
            normalise,
	        Conv((3, 3), imgsize[end]=>32, relu),
            Conv((3, 3), 32=>64, relu),
            MaxPool((2, 2)),
            Dropout(0.25),
            flatten,
            Dense(9216, 120, relu), 
            Dropout(0.5),
            Dense(120, nclasses)
          )
end

predictdict = Dict(0 =>  "no", 1 => "yes", 2 => "go", 3 => "left" , 4=> "right" ,  5=>"up" ,  6 => "down",7 => "stop" )

device = cpu
model = ConvNet5() |> device

BSON.@load "./src/model6.bson" model

function launchServer(port)

    Genie.config.run_as_server = true
    Genie.config.server_host = "0.0.0.0"
    Genie.config.server_port = port


    println("port set to $(port)")

    route("/") do
        "Hi there! This is server 1"
    end

    route("/digitreg", method = POST) do
        data = eval(Meta.parse(rawpayload()))
        
        data = reshape(data, (28,28,1))
    
        xtrain = zeros((28,28,1,1))
        xtrain[:,:,:,1] = data
        # println(xtrain)
        imshow(xtrain[:,:,:,1])
        results = model(xtrain)
        println(results)
        final = predictdict[findmax(results[:,1])[2]-1]
        return final
    end

    Genie.AppServer.startup(async = false)
end

# launchServer(parse(Int, ARGS[1]))
launchServer( 8002)


How does a model return same values each time when I sent different images each time

julia> include("src/app.jl")
Gtk-Message: 16:53:26.455: Failed to load module "canberra-gtk-module"
Gtk-Message: 16:53:26.456: Failed to load module "canberra-gtk-module"
port set to 8002
┌ Info: 
└ Web Server starting at http://0.0.0.0:8002 - press Ctrl/Cmd+C to stop the server. 
┌ Warning: Slow fallback implementation invoked for conv!  You probably don't want this; check your datatypes.
│   yT = Float64
│   T1 = Float64
│   T2 = Float32
└ @ NNlib ~/.julia/packages/NNlib/JZ1dF/src/conv.jl:291
[-0.04453937811644551; 0.15977026578759745; 0.20575298835973618; 0.09723831848733194; -0.3219437376378894; -0.426827062398888; -0.17557046043285066; -0.10186151602451143]
[ Info: POST /digitreg 200
[-0.04453937811644551; 0.15977026578759745; 0.20575298835973618; 0.09723831848733194; -0.3219437376378894; -0.426827062398888; -0.17557046043285066; -0.10186151602451143]
[ Info: POST /digitreg 200
[-0.04453937811644551; 0.15977026578759745; 0.20575298835973618; 0.09723831848733194; -0.3219437376378894; -0.426827062398888; -0.17557046043285066; -0.10186151602451143]
[ Info: POST /digitreg 200
[-0.04453937811644551; 0.15977026578759745; 0.20575298835973618; 0.09723831848733194; -0.3219437376378894; -0.426827062398888; -0.17557046043285066; -0.10186151602451143]
[ Info: POST /digitreg 200

I can see relatively different answers for my inputs in repl atleast but I can’t figure what am I missing here.

(@v1.6) pkg> activate .
  Activating environment at `~/sigil/sardor/Project.toml`

julia> using Flux, Images

julia> using WAV

julia> using SignalAnalysis

julia> using Plots


julia> 

julia> finalist = [
       "./mini_speech_commands/down/ffd2ba2f_nohash_4.wav", 
       "./mini_speech_commands/go/ffd2ba2f_nohash_3.wav", "./mini_speech_commands/left/ffd2ba2f_nohash_4.wav", "./mini_speech_commands/no/fffcabd1_nohash_0.wav", "./mini_speech_commands/right/ffd2ba2f_nohash_4.wav", "./mini_speech_commands/stop/fffcabd1_nohash_1.wav", "./mini_speech_commands/up/ffd2ba2f_nohash_3.wav", "./mini_speech_commands/yes/ffd2ba2f_nohash_2.wav"]
8-element Vector{String}:
 "./mini_speech_commands/down/ffd2ba2f_nohash_4.wav"
 "./mini_speech_commands/go/ffd2ba2f_nohash_3.wav"
 "./mini_speech_commands/left/ffd2ba2f_nohash_4.wav"
 ⋮
 "./mini_speech_commands/up/ffd2ba2f_nohash_3.wav"
 "./mini_speech_commands/yes/ffd2ba2f_nohash_2.wav"

julia> data = [wavread(i)[1] for i in finalist]
8-element Vector{Matrix{Float64}}:
 [-0.00027466658528397473; -0.0003357036042359691; … ; -0.00018311105685598315; -0.00027466658528397473]
 [-3.051850947599719e-5; -0.00018311105685598315; … ; -6.103701895199438e-5; -0.00012207403790398877]
 [-9.155552842799158e-5; -0.00021362956633198035; … ; 0.00018311105685598315; 0.00012207403790398877]
 ⋮
 [-0.0003051850947599719; -0.0004882961516159551; … ; 0.0003967406231879635; 0.0003051850947599719]
 [-3.051850947599719e-5; -3.051850947599719e-5; … ; 0.00021362956633198035; 0.0004272591326639607]

julia> function spectronew(val)
           test1 = tfd(val[:], SignalAnalysis.Spectrogram())
           png(
julia> function spectronew(val)
           test1 = tfd(val[:], SignalAnalysis.Spectrogram())
           png(
               plot(test1, legend = :none, ticks=false, xaxis =false, yaxis=false, margins = -1.0Plots.cm, size=(28,28)),
               "testcase",
           )
           img = load("testcase.png")
           img = imresize(img, (28,28))
           img = reshape(convert(Array{Float32}, Gray.(img)), (28, 28, 1));
           return img
       end
spectronew (generic function with 1 method)

julia> fs = 16000
16000

julia> spectrodata = [spectronew(i) for i in data]
8-element Vector{Array{Float32, 3}}:
 [0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0]
 [0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0]
 [0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0]
 ⋮
 [0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0]
 [0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0]

julia> function ConvNet5(; imgsize=(28,28,1), nclasses=8) 
           out_conv_size = (imgsize[1]÷4 - 3, imgsize[2]÷4 - 3, 16)
           
           return Chain(
                   Flux.normalise,
julia> function ConvNet5(; imgsize=(28,28,1), nclasses=8) 
           out_conv_size = (imgsize[1]÷4 - 3, imgsize[2]÷4 - 3, 16)
           
           return Chain(
                   Flux.normalise,
                   Conv((3, 3), imgsize[end]=>32, relu),
                   Conv((3, 3), 32=>64, relu),
                   MaxPool((2, 2)),
                   Dropout(0.25),
                   flatten,
                   Dense(9216, 120, relu), 
                   Dropout(0.5),
                   Dense(120, nclasses)
                 )
       end
ConvNet5 (generic function with 1 method)

julia> device = cpu
cpu (generic function with 1 method)

julia> model = ConvNet5() |> device
Chain(normalise, Conv((3, 3), 1=>32, relu), Conv((3, 3), 32=>64, relu), MaxPool((2, 2)), Dropout(0.25), flatten, Dense(9216, 120, relu), Dropout(0.5), Dense(120, 8))

julia> using BSON

julia> BSON.@load "model6.bson" model

julia> data1 = zeros(Float32, (28,28,1,8))
28×28×1×8 Array{Float32, 4}:
[:, :, 1, 1] =
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  …  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 ⋮                        ⋮         ⋱                 ⋮         
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0

[:, :, 1, 2] =
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  …  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 ⋮                        ⋮         ⋱                 ⋮         
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0

[:, :, 1, 3] =
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  …  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 ⋮                        ⋮         ⋱                 ⋮         
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0

[:, :, 1, 4] =
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  …  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 ⋮                        ⋮         ⋱                 ⋮         
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0

[:, :, 1, 5] =
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  …  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 ⋮                        ⋮         ⋱                 ⋮         
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0

[:, :, 1, 6] =
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  …  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 ⋮                        ⋮         ⋱                 ⋮         
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0

[:, :, 1, 7] =
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  …  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 ⋮                        ⋮         ⋱                 ⋮         
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0

[:, :, 1, 8] =
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  …  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 ⋮                        ⋮         ⋱                 ⋮         
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0

julia> for (num,i) in enumerate(spectrodata)
               data1[:,:,:,num] = i
       end

julia> labeldict = Dict("yes" => 1, "go" => 2, "left" => 3, "right" => 4, "up" => 5,  "down" => 6, "stop"=> 7, "no" => 0 )
Dict{String, Int64} with 8 entries:
  "left"  => 3
  "yes"   => 1
  "stop"  => 7
  "right" => 4
  "no"    => 0
  ⋮       => ⋮

julia> results = model(data1)
8×8 Matrix{Float32}:
  0.936356  -0.39013   -4.50234   3.97325  …    3.43349   -1.99782
 -2.83431    0.945991   2.52671  -2.8481      -10.8343    10.5577
  0.787459   1.14932   -3.0197    4.26748       4.73051   -3.02097
  ⋮                                        ⋱              
 -0.649594  -3.43609   -4.89584   4.35426       5.6695    -4.94898
 -2.54749   -1.80068   -1.25191  -0.28733       0.109317   1.48895

julia> results = model(data1)
8×8 Matrix{Float32}:
  0.936356   -0.39013   -4.50234    3.97325  …  -1.81333     3.43349   -1.99782
 -2.83431     0.945991   2.52671   -2.8481      -6.18262   -10.8343    10.5577
  0.787459    1.14932   -3.0197     4.26748     -0.379874    4.73051   -3.02097
 -0.0524796   1.90563    5.29881   -7.24859     -3.01265    -8.83725    1.26796
  2.77807     0.230436   0.620303  -3.83483     -0.978707   -9.49704   -7.31315
  0.657838    0.30525   -2.07681   -5.67655  …  -0.685956    2.24674    0.970657
 -0.649594   -3.43609   -4.89584    4.35426     -0.221228    5.6695    -4.94898
 -2.54749    -1.80068   -1.25191   -0.28733      7.22299     0.109317   1.48895

julia> predictdict = Dict(0 =>  "no", 1 => "yes", 2 => "go", 3 => "left" , 4=> "right" ,  5=>"up" ,  6 => "down",7 => "stop" )
Dict{Int64, String} with 8 entries:
  0 => "no"
  4 => "right"
  5 => "up"
  6 => "down"
  2 => "go"
  7 => "stop"
  3 => "left"
  1 => "yes"

julia> predictdict = Dict(0 =>  "no", 1 => "yes", 2 => "go", 3 => "left" , 4=> "right" ,  5=>"up" ,  6 => "down",7 => "stop" )
Dict{Int64, String} with 8 entries:
  0 => "no"
  4 => "right"
  5 => "up"
  6 => "down"
  2 => "go"
  7 => "stop"
  3 => "left"
  1 => "yes"

julia> mode = [" ","","","","","","",""]
8-element Vector{String}:
 " "
 ""
 ""
 ""
 ""
 ""
 ""
 ""

julia> for i in 1:8
               mode[i] = predictdict[findmax(results[:,i])[2]-1]
       end

julia> mode
8-element Vector{String}:
 "right"
 "left"
 "left"
 "down"
 "right"
 "stop"
 "down"
 "yes"

Use of HTTP to send requests:

julia> HTTP.post("http://localhost:8002/digitreg", [], string(spectrodata[8]))
HTTP.Messages.Response:
"""
HTTP/1.1 200 OK
Content-Type: */*
Server: Genie/Julia/1.6.1
Transfer-Encoding: chunked

go"""

julia> HTTP.post("http://localhost:8002/digitreg", [], string(spectrodata[2]))
HTTP.Messages.Response:
"""
HTTP/1.1 200 OK
Content-Type: */*
Server: Genie/Julia/1.6.1
Transfer-Encoding: chunked

go"""

Idk why this is but the issue fix itself when I changed my api server code to something like this:

using Genie
using Genie.Router
import Genie.Renderer.Json: json
using Genie.Renderer.Json, Genie.Requests
using Genie.Renderer.Html
using Genie.Renderer
using Flux
using BSON
using Flux: onehotbatch, onecold, normalise, Dropout

function ConvNet5(; imgsize=(28,28,1), nclasses=8) 
    return Chain(
            normalise,
	        Conv((3, 3), imgsize[end]=>32, relu),
            Conv((3, 3), 32=>64, relu),
            MaxPool((2, 2)),
            Dropout(0.25),
            flatten,
            Dense(9216, 120, relu), 
            Dropout(0.5),
            Dense(120, nclasses)
          )
end

predictdict = Dict(0 =>  "no", 1 => "yes", 2 => "go", 3 => "left" , 4=> "right" ,  5=>"up" ,  6 => "down",7 => "stop" )

device = cpu
model = ConvNet5() |> device

BSON.@load "./src/model6.bson" model

function launchServer(port)

    Genie.config.run_as_server = true
    Genie.config.server_host = "0.0.0.0"
    Genie.config.server_port = port


    println("port set to $(port)")

    route("/") do
        "Hi there! This is server 1"
    end

    route("/digitreg", method = POST) do
        data = eval(Meta.parse(rawpayload()))
        
        data = reshape(data, (28,28,1))
        
        xtrain = zeros(Float32, (28,28,1,2)) # I changed this only, 
        # Before input size:  (28,28,1,1)
        # Now input size: (28,28,1,2) # with a part of array as just zeroes, Idk why this works
        xtrain[:,:,:,1] = data
        results = model(xtrain)
        final = predictdict[findmax(results[:,1])[2]-1]
        return final
    end

    Genie.AppServer.startup(async = false)
end

launchServer( 8003)