Chapter 4: Dataloaders() vs DataBlock.dataloaders()

Hello.
I have recently started my journey with deep learning and ML in general by checking out fastai – lovely project!
But there is one problem I stumbled across. I the chapter 4 of the book a simple linear model is created step-by step, first by taking a list of filenames, converting them to tensors, unwrapping them so they are no longer square but one-dimensional vectors, stacked on top of each other, zipped with labels and then made into DataLoaders with a dls = DataLoaders(train_dl, valid_dl). Then vision_learner is created and calling .fit() on it works nicely – model trains fast and reaches good accuracy in barely 10 epochs.
Then I tried to modify that approach by adding a DataBlock call as in chapter 2 with the bear classifier. I know that I had to apply additional transformation to the images, because they are not made into one-dim vectors. I created the datablock:

def flatten(im:Image.Image):
       timg= tensor(im).float()/255
       return timg.view(1,28*28)

digits_db = DataBlock(
     blocks = (ImageBlock(cls=PILImageBW), CategoryBlock),
    get_items=get_image_files,
    splitter= GrandparentSplitter(),
    get_y = parent_label,
    item_tfms=(myflatten)
    )
dls = digits_db.dataloaders(path)
learner = Learner(dataloaders, linear1, opt_func=SGD,
                loss_func = mnist_loss, metrics=batch_accuracy)

all functions passed to Learner are the same as previously.
Unfortunately, problem arises upon calling .fit(): model is learning and trying to fit but first of all it takes way longer and second of all batch_accuracy is not improving after one or two passes – it stays around 0.5 suggesting totally random prediction behaviour. After making sure with datasets.summary() that in both cases data and labels are the same format, I have no further ideas as to why it is happening. And that is a question I would like to ask.