Couldn't construct a DataBock

Hey, I am trying this Dehaze problem out. I am getting stuck at while making a DataBlock for this, while creating a block, we usually (I am at Pet_breeds section still)

block = (ImageBlock , CategoryBlock)

I tried this out, I know it shouldn’t be a CategoryBlock, I even tried MaskBlock but getting an error. And seems I gotta even learn Unet to get this done, anybody has come across this?

How to possibly construct a Datablock for dehaze ?

This is what I am trying to achieve Screenshot 2020-12-02 at 15.23.16

I never worked on an image-to-image task. But since your goal is to generate “dehazed” images from “hazy” images, it seems to me that you should be using ImageBlock both for your inputs and outputs. Also, in order to make debugging a bit easier, I would remove everything non-essential (splitter, tfms) and add them once the simplified DataBlock is working.

Yes, you need a model architecture that can generate a full-sized image. Unet is one option, but you could also have a look at the fastai implementation of GANs.

1 Like

I think Stefan is right, you should use two ImageBlocks, since both your input and output are images. Another thing to change is the get_y function, you don’t want a label (which label_func probably returns), but a filename or path to your dehazed image.

As for the model architecture, you can try a UNet, there is a convenient fastai function called unet_learner that dynamically creates a learner with a UNet from pretrained models :slight_smile:

1 Like

Actually yeah! I removed the get_y label function, turns out to be that was causing me the error. After removing it , I was able to print them but I don’t have a clue why the images are kinda repetitive


Absolutely you guys were right @stefan-ai and @johannesstutz, when I debugged my code I was able to find where it went wrong, lemme try the modeling thing for now. Thanks again, guys! Have a good day

1 Like