Display images from Google Drive in Colab markdown cells

I’m having trouble showing pictures in Google Colab markdown cells when the images are stored in my Google Drive. I know how to use the standard markdown syntax ![Alt text](image_url) for web images, but when I try to use a Google Drive link instead of a regular web URL, nothing shows up. The Colab documentation demonstrates this with external images like ![Sample image](https://example.com/photo.jpg) and that works fine. However, when I substitute the web URL with a Google Drive file link, the image doesn’t render in the markdown cell. Has anyone figured out the correct way to reference Drive files in Colab markdown? I’ve tried different approaches but can’t get my stored images to display properly.

you can also upload directly to colab using the file upload widget. just run from google.colab import files and then files.upload() to select your image. reference them like ![pic](/content/yourimage.jpg) in markdown. gets a bit annoying with multiple files tho, especially when the runtime disconnects.

Google Drive share links won’t work directly in markdown - they’re not actual image URLs. Your typical Drive link looks like https://drive.google.com/file/d/FILE_ID/view?usp=sharing, but you need to convert it to https://drive.google.com/uc?id=FILE_ID instead. Just grab the FILE_ID from your original link and swap it into that format. Don’t forget to set your file permissions to ‘Anyone with the link can view’ or Colab can’t access it. I’ve used this trick for months in my research notebooks - works every time. Drop that converted URL into standard markdown image syntax and you’re good to go.

I’ve had way better luck mounting Drive than messing with URLs. Just use from google.colab import drive then drive.mount('/content/drive') and your images are right there in Colab. You can drop them into markdown cells with ![Description](/content/drive/MyDrive/folder/image.png) - no permission hassles since you’re already logged in, and the paths stay the same every time. Super handy for datasets with tons of images since you don’t have to create sharing links for every single file.