Hi,
I am working through Tanmay Bakshi’s lovely book and get errors
when it gets really interesting (in the Machine Learning chapter).
I have Julia 1.3 on a mac, with Flux downgraded to 0.9 to have
the Metalhead compatibility. See also
https://discourse.julialang.org/t/julia-1-3-and-metalhead/3245
and the kind help from @ Syx_Pek
Here is the code I am trying to run:
using Metalhead: VGG19, preprocess, load, labels
using Flux: onecold
model = VGG19()
class_labels=labels(model)
print("Enter the name of your file: ")
user_image = preprocess(load(readline()))
model_prediction = model(user_image)
top_class = onecold(model_prediction)[1]
class_name = labels[top_class]
println("I think this image contains: $(class_name)")
(This is from pages 150-151 in the book.)
And here is the errors I get:
Enter the name of your file: test.jpg
ERROR: LoadError: MethodError: no method matching labels(::Int64)
Closest candidates are:
labels(!Matched::Type{#s17} where #s17<:Metalhead.ClassificationModel{Class}) where Class at /Users/bauschke/.julia/packages/Metalhead/tbYpP/src/model.jl:2
labels(!Matched::Metalhead.ClassificationModel{Class}) where Class at /Users/bauschke/.julia/packages/Metalhead/tbYpP/src/model.jl:3
labels(!Matched::Type{Metalhead.ImageNet.ImageNet1k}) at /Users/bauschke/.julia/packages/Metalhead/tbYpP/src/datasets/imagenet.jl:27
...
Stacktrace:
[1] top-level scope at /Users/bauschke/Documents/Julia/_JuliaForBeginners/imcla.jl:13
[2] include at ./boot.jl:328 [inlined]
[3] include_relative(::Module, ::String) at ./loading.jl:1105
[4] include(::Module, ::String) at ./Base.jl:31
[5] exec_options(::Base.JLOptions) at ./client.jl:287
[6] _start() at ./client.jl:460
in expression starting at /Users/bauschke/Documents/Julia/_JuliaForBeginners/imcla.jl:13
Added: I tried this also on CoCalc and it does not work there either.
Sadly, it does not even work on the PAID version of Juliabox - as the kernel keeps restarting…
Any help would be awesome!
Heinz.