0
0
PyTorchml~10 mins

YOLO concept in PyTorch - Interactive Code Practice

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

Complete the code to import the YOLO model from the ultralytics package.

PyTorch
from ultralytics import [1]
Drag options to blanks, or click blank then click option'
Acv2
Btorch
CYOLO
Dnumpy
Attempts:
3 left
💡 Hint
Common Mistakes
Importing torch instead of YOLO
Importing unrelated packages like cv2 or numpy
2fill in blank
medium

Complete the code to load a pre-trained YOLOv8n model.

PyTorch
model = YOLO([1])
Drag options to blanks, or click blank then click option'
A'yolov8n.pt'
B'model.pth'
C'yolov5s.pt'
D'resnet50.pth'
Attempts:
3 left
💡 Hint
Common Mistakes
Using weights from other models like YOLOv5 or ResNet
Using incorrect file extensions
3fill in blank
hard

Fix the error in the code to run inference on an image using the YOLO model.

PyTorch
results = model.[1]('image.jpg')
Drag options to blanks, or click blank then click option'
Aeval
Bpredict
Ctrain
Dinfer
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'train' which is for training the model
Using 'eval' or 'infer' which are not valid YOLO methods
4fill in blank
hard

Fill both blanks to extract bounding boxes and confidence scores from YOLO results.

PyTorch
boxes = results.[1].xyxy
confidences = results.[2].conf
Drag options to blanks, or click blank then click option'
Aboxes
Bmasks
Cpred
Dlabels
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pred' which is not an attribute of results
Using 'masks' which is for segmentation tasks
Using 'labels' which are not the correct attribute
5fill in blank
hard

Fill all three blanks to run training on a custom dataset with YOLO.

PyTorch
model.train(data=[1], epochs=[2], imgsz=[3])
Drag options to blanks, or click blank then click option'
A'custom.yaml'
B50
C640
D'yolov8n.pt'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the model weights file as data argument
Confusing epochs with image size
Using incorrect types for arguments