# DeepLabV3+ in Julia

**URL:** <https://discourse.julialang.org/t/deeplabv3-in-julia/80863>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [May 11, 2022, 6:26am UTC](https://discourse.julialang.org/t/deeplabv3-in-julia/80863 "2022-05-11T06:26:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuji-github](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuji-github/32/36142_2.png) [@Yuji-github](https://discourse.julialang.org/u/Yuji-github)\
**Post date:** [May 11, 2022, 6:26am UTC](https://discourse.julialang.org/t/deeplabv3-in-julia/80863/1 "2022-05-11T06:26:26Z")

</div>

Assume input images are 128x128 (including segmentations) and extract layers from the backbone ResNet50.  
While calculating the loss values with Flux.dice\_coeff\_loss function, I got this error: “ERROR: MethodError: objects of type NTuple{4, Int64} are not callable.” Why did I get the error, and what does it mean?

ERROR: MethodError: objects of type NTuple{4, Int64} are not callable  
Stacktrace:  
[1] macro expansion  
@ ~/.julia/packages/Zygote/ytjqm/src/compiler/interface2.jl:0 [inlined]  
[2] \_pullback(ctx::Zygote.Context, f::NTuple{4, Int64}, args::Array{Float32, 4})  
@ Zygote ~/.julia/packages/Zygote/ytjqm/src/compiler/interface2.jl:9  
[3] macro expansion  
@ ~/.julia/packages/Flux/18YZE/src/layers/basic.jl:53 [inlined]  
[4] \_pullback  
@ ~/.julia/packages/Flux/18YZE/src/layers/basic.jl:53 [inlined]

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [May 11, 2022, 7:15am UTC](https://discourse.julialang.org/t/deeplabv3-in-julia/80863/2 "2022-05-11T07:15:15Z")

</div>

The error means that you are trying to call a tuple with four elements, something like this:

```julia
julia> x = (1, 1, 1, 1)
(1, 1, 1, 1)

julia> x("something")
ERROR: MethodError: objects of type NTuple{4, Int64} are not callable
Stacktrace:
 [1] top-level scope
   @ REPL[14]:1

```

Why you are getting this error is hard to say without an MWE.

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [May 11, 2022, 8:09am UTC](https://discourse.julialang.org/t/deeplabv3-in-julia/80863/3 "2022-05-11T08:09:57Z")

</div>

And, for info, MWE stands for “minimum working example”: if you want people to help, you should post a cut-down version of your program (the more, the better) that still exhibits the error you are reporting, so that whoever reads your post can track the error down to something precise.

---

<div class="post-metadata">

**Author:** ![Yuji-github](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuji-github/32/36142_2.png) [@Yuji-github](https://discourse.julialang.org/u/Yuji-github)\
**Post date:** [May 12, 2022, 3:43pm UTC](https://discourse.julialang.org/t/deeplabv3-in-julia/80863/4 "2022-05-12T15:43:58Z")

</div>

Thank you for helping me a lot.  
I am assuming that the concatenation is the cause of the issue.  
What do you think?

function ASPP(encode\_layer)

```
    pool_size = (encode_layer[1], encode_layer[2])         

    # --- Image Pooling ---- assume Encode_layer comes in

    image_pool = Flux.Chain(
        Flux.MeanPool(pool_size), 
        Flux.Conv((1, 1), 1024=>128, pad=(1, 1), bias=Zeros(128)), 
        Flux.BatchNorm(128, relu),
        Flux.Upsample(:bilinear, size = pool_size)
    )      

    # --- 1x1 Conv ----

    one = Flux.Chain(
        Flux.Conv((1, 1), 1024=>128, pad=(1, 1), bias=Zeros(128)), 
        Flux.BatchNorm(128, relu)
    )

    # --- 3x3 Conv Rate 6 ----

    rate6 = Flux.Chain(
        Flux.Conv((3, 3), 1024=>128, pad=(1, 1), dilation=6, bias=Zeros(128)), 
        Flux.BatchNorm(128, relu)
    )

    # --- 3x3 Conv Rate 12 ----

    rate12 = Flux.Chain(
        Flux.Conv((3, 3), 1024=>128, pad=(1, 1), dilation=12, bias=Zeros(128)),
        Flux.BatchNorm(128, relu)
    )

    # --- 3x3 Conv Rate 18 ----

    rate18 = Flux.Chain(
        Flux.Conv((3, 3), 1024=>128, pad=(1, 1), dilation=18, bias=Zeros(128)), 
        Flux.BatchNorm(128, relu)
    )

    # After ASPP Part  

    # --- Concatenate ----

    concatenate = Flux.Chain(encode_layer -> cat(

                        image_pool(encode_layer),

                        one(encode_layer),

                        rate6(encode_layer),

                        rate12(encode_layer),

                        rate18(encode_layer); dims=3

                        )       
                    )            

    # --- 1x1 Conv for UpSamling ----

    for_up = Flux.Chain(
                    concatenate,
                    Flux.Conv((1, 1), 640=>128, pad=(1, 1), bias=Zeros(128)),
                    Flux.BatchNorm(128, relu)
                    )       

    return for_up

```

---

<div class="post-metadata">

**Author:** ![Yuji-github](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuji-github/32/36142_2.png) [@Yuji-github](https://discourse.julialang.org/u/Yuji-github)\
**Post date:** [May 12, 2022, 3:44pm UTC](https://discourse.julialang.org/t/deeplabv3-in-julia/80863/5 "2022-05-12T15:44:55Z")

</div>

Thank you for your quick response first.  
I tried to fix the issues, but still, I cannot solve them.

---

<div class="post-metadata">

**Author:** ![Yuji-github](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuji-github/32/36142_2.png) [@Yuji-github](https://discourse.julialang.org/u/Yuji-github)\
**Post date:** [May 12, 2022, 3:45pm UTC](https://discourse.julialang.org/t/deeplabv3-in-julia/80863/6 "2022-05-12T15:45:55Z")

</div>

Thank you for your suggestion.  
I was not sure how to write the code on the post as it was my first-time post.
