Software/hardware covered in the book |
OS requirements |
Minimum 128 GB storage |
Windows, Linux, and macOS |
Python 3.6 and above |
Windows, Linux, and macOS |
PyTorch 1.7 |
Windows, Linux, and macOS |
Google Colab (can run in any browser) |
Windows, Linux, and macOS |
Do note that almost all the code in the book can be run using Google Colab by clicking the Open Colab button in each of the notebooks for the chapters on GitHub.
If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
Download the example code files
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Modern-Computer-Vision-with-PyTorch. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Download the color images
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781839213472_ColorImages.pdf.
Conventions used
There are a number of text conventions used throughout this book.
CodeInText: Indicates code words in the text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "We are creating an object of the FMNISTDataset class named val, in addition to the train object that we saw earlier."
A block of code is set as follows:
# Crop image
img = img[50:250,40:240]
# Convert image to grayscale
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Show image
plt.imshow(img_gray, cmap='gray')
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
def accuracy(x, y, model):
model.eval() # <- let's wait till we get to dropout section
# get the prediction matrix for a tensor of `x` images
prediction = model(x)
# compute if the location of maximum in each row coincides
# with ground truth
max_values, argmaxes = prediction.max(-1)
is_correct = argmaxes == y
return is_correct.cpu().numpy().tolist()
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "We will apply gradient descent (after a feedforward pass) using one batch at a
time until we exhaust all data points within one epoch of training."