0
0
Computer Visionml~10 mins

Super-resolution basics in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load a low-resolution image using OpenCV.

Computer Vision
import cv2
low_res_img = cv2.imread([1])
print(low_res_img.shape)
Drag options to blanks, or click blank then click option'
A'low_res_image.jpg'
B'model.pth'
C'output.png'
D'high_res_image.jpg'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a high-resolution image filename instead of low-resolution.
2fill in blank
medium

Complete the code to resize the low-resolution image to a higher resolution using OpenCV.

Computer Vision
high_res_img = cv2.resize(low_res_img, [1], interpolation=cv2.INTER_CUBIC)
print(high_res_img.shape)
Drag options to blanks, or click blank then click option'
A(256, 256)
B(64, 64)
C(16, 16)
D(8, 8)
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing smaller or same size dimensions, which does not increase resolution.
3fill in blank
hard

Fix the error in the code to define a simple super-resolution model using PyTorch.

Computer Vision
import torch.nn as nn
class SimpleSR(nn.Module):
    def __init__(self):
        super(SimpleSR, self).__init__()
        self.conv1 = nn.Conv2d(3, 64, kernel_size=[1], padding=1)
    def forward(self, x):
        return self.conv1(x)
Drag options to blanks, or click blank then click option'
A1
B5
C3
D7
Attempts:
3 left
💡 Hint
Common Mistakes
Using kernel size 1 or 7 which changes feature extraction behavior.
4fill in blank
hard

Fill both blanks to complete the training loop snippet for super-resolution model.

Computer Vision
for epoch in range(num_epochs):
    for data in dataloader:
        inputs, targets = data
        optimizer.zero_grad()
        outputs = model([1])
        loss = criterion(outputs, [2])
        loss.backward()
        optimizer.step()
Drag options to blanks, or click blank then click option'
Ainputs
Btargets
Coutputs
Dinputs.detach()
Attempts:
3 left
💡 Hint
Common Mistakes
Passing targets to the model or comparing outputs with inputs.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps image names to their super-resolution outputs.

Computer Vision
sr_results = [1]: model(images[[2]].unsqueeze(0)) for [3] in images.keys()}
Drag options to blanks, or click blank then click option'
Aname
Dimg
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently causing errors.