Lab 2: Rotations

Introduction

In this lab, you'll be creating a classifier to determine whether an image is rotated (not-rotated, left, right, or 180 degrees). This could be useful, for example, in a photo viewer to automatically rotate images that are not right-side-up.

The key to this lab is that properly labeled data is not provided. You'll need to be preparing the data.

Prepare data

Use the same data as was used for lab 1 (download).

The data has valid, train, and test folders. In order to have the most training data, train on the data in both the train and test folders. Use the data in the valid folder for validation.

Problems:

A solution is to: Useful methods when preparing data:

Train model

Now that you have your data, you can train a model. Use an existing pretrained model (like resnet34 or squeezenet1_1).

See how low you can get the validation loss. Get it to below 0.16.

Test model

What is the validation accuracy associated with the validation loss you achieved?

Which images in the validation set is the classifier least sure about? (You may find plot_top_losses useful—see fast.ai book chapter 2).

Suggestions

Challenge Instead of pre-rotating each image, create a transform that will randomly both do the rotation and change the label (y). Thus, your dataloader can just load all the unrotated images, and the transform will do the rotation on the fly as part of data augmentation.

Note that this is a difficult problem.

Challenge Turn this into a regression problem where you are predicting the numeric degrees of rotation given a rotated image. In this case, you'll want to support rotating with increments of less than 90 degrees. You'll need:

There may be other issues you'll need to solve as well.

Note that this is a difficult problem.

This completes the lab. Submit instructions

  1. Make sure that the output of all cells is up-to-date.
  2. Rename your notebook:
    1. Click on notebook name at the top of the window.
    2. Rename to "CS152Sp21Lab2 FirstName1/FirstName2" (using the correct lab number, along with your two first names). I need this naming so I can easily navigate through the large number of shared docs I will have by the end of the semester.
  3. Choose File/Save
  4. Share your notebook with me:
    1. Click on the Share button at the top-right of your notebook.
    2. Enter rhodes@g.hmc.edu as the email address.
    3. Click the pencil icon and select Can comment.
    4. Click on Done.
  5. Enter the URL of your colab notebook in this submittal form. Do not copy the URL from the address bar (which may contain an authuser parameter and which I will not be able to open). Instead, click Share and Copy link to obtain the correct link. Enter your names in alphabetical order.
  6. At this point, you and I will go back and forth until the lab is approved.
    1. I will provide inline comments as I evaluate the submission (Google should notify you of these comments via email).
    2. You will then need to address those comments. Please do not resolve or delete the comments. I will use them as a record of our conversation. You can respond to them ("Fixed" perhaps).
    3. Once you have addressed all the comments in this round, fill out the submittal form again.
    4. Once I am completely satisifed with your lab, I will add a LGTM (Looks Good to Me) comment
    5. At that point, setup an office hour appointment with me. Ill meet with you and your partner and we'll have a short discussiona about the lab. Both of you should be able to answer questions about any part of the lab.

'