Nbdev render only the last image with images having same name

Hello all,

I usually paste images directly from Clipboard to Notebook and Jupyter renders them all fine.

However, when I preview the nbdev page with nbdev_preview, the page replaces all images with the last image.

I dig into the notebook file and found out that all images have the same name - image.png (but in different Cells). When I manually replaced the image file name, nbdev_preview renders OK.

Do I need to manually replaces all file names or it is a bug ?

Here is the page ../../dhblog - Object Detection - SSD - fastai 2.7.8 (The first image is the one I rename myself and all images below is all similar)

Here is the repo: dhblog/SSD_base.ipynb at master · dienhoa/dhblog · GitHub



I have updated my notebook by manually renaming all images. The pages look fine now but would love to know if we have solution for this problem in the future. Thanks

1 Like

It’s a nice project, thanks for sharing.

1 Like

I created a minimal nbdev project and has these associated pages and was not able to reproduce the issue from cell attachments (copy and pasting from clipboard into markdown cell)

1 Like

Looking at the specific project next! stay tuned

Not able to reproduce this on the project either

Thanks for your help @hamelsmu . I mean the attachments image name. In your ntest18 project, if you open the notebook as an text editor, you can see that you have:

    "attachments": {                                                                                                                                                                                               
     "a8ab7d2c-e588-41d3-92a9-c1bb6b77c268.png": {   
      "image/png": "..."
    "attachments": {                                                                                                                                                                                               
     "08c717fe-833a-43cc-a762-f1a0baa357e6.png": {   
      "image/png": "..."

You have 2 files name different: a8ab7d2c-e588-41d3-92a9-c1bb6b77c268.png and 08c717fe-833a-43cc-a762-f1a0baa357e6.png

Sorry for not being clear. I’ve created a PR for ntest18 having the problem. The repo come from here: ntest18/00_core.ipynb at main · dienhoa/ntest18 · GitHub


Reposted from another thread

Based on your PR looks like you are using an older version of nbdev. We are no longer using the nbdev_filter in _quarto.yml

Also can you try this attachment thing on the latest Jupyter lab ?

I edited my earlier message as I replied to your message on the wrong thread

Thanks. I will try with the latest Jupyter lab and nbdev later today.

Oh, pasting image in jupyter-lab create an unique filename ID for example “a8ab7d2c-e588-41d3-92a9-c1bb6b77c268.png” but not in vanilla jupyter-notebook (which is always image.png)

:sweat_smile: Seems like I need to switch to jupyterlab

Thanks a lot Hamel

1 Like

@jeremy see above re: Classic vs Lab and cell attachments

@hamelsmu do you think there might be a way to make classic notebook work?

is it similar to this enhancement request from fastpages?
Use nbdev_detach to support copy/pasted images