I’m having trouble adding pictures from my Google Drive to my Colab notebook. I know how to put in images from the internet using markdown. You just do  and it shows up. But when I try to use the same thing with a picture from my Drive, nothing happens.
I’ve looked at the Colab guide and they show an example like this:
An inline image: 
That works fine for online images. But how do I make it work with my own files in Drive? I’ve tried putting in the Drive link, but the image doesn’t show up. Is there a special way to reference Drive files in Colab markdown? Any help would be great!
hey there! i had the same prob before. try this: use the ‘files.upload()’ function to upload ur pic directly to colab. then use ‘’ in ur markdown. works like a charm for me. hope it helps!
I’ve found a reliable method for displaying Drive images in Colab markdown. First, mount your Google Drive using the code snippet provided by Colab. Then, use the following syntax:
from google.colab import files
from IPython.display import Markdown, display
import base64
def show_drive_image(path):
with open(path, 'rb') as image_file:
image_data = image_file.read()
encoded = base64.b64encode(image_data).decode()
return f''
display(Markdown(show_drive_image('/content/drive/My Drive/path/to/your/image.png')))
Replace the path with your image’s location. This approach embeds the image directly, avoiding sharing issues and ensuring it displays correctly in your notebook.
I’ve encountered this issue a few times in my own projects and discovered a workaround that has worked reliably in Colab notebooks. Instead of using your Drive link directly, first set your image file to be shareable by right-clicking it in Google Drive and choosing the option to get a link, making sure it’s set to ‘Anyone with the link can view’. After copying the link, change the part that says ‘view’ to ‘uc’. The markdown should then be formatted as: , replacing YOUR_FILE_ID with your actual file identifier.