Chapter 2 Question

Hi John,

These lines of code really just serve as an example for downloading a single image and displaying it. Step-by-step it works as follows:

  • in dest you define a path where you want to save the downloaded image
  • download_url then carries out the job of downloading the image from the url specified in ims[0] and saving the image in the path specified in dest
  • Image.open(dest) loads the image from dest into your notebook
  • and im.to_thumb(128,128) displays your image using 128x128 pixels

So if you are applying the code from chapter 2 to another dataset, you would want to show an example from your own dataset. Depending on your classes you could change the directory in dest, but otherwise the code will run as is.

Note that cell [12] is optional here. After getting your 150 image urls in cell [16], ims[0] in cell [17] will pick the first item from that list, but you could also choose any other item.

1 Like