0% found this document useful (0 votes)
3 views2 pages

YOLOv8 Mask Detection Setup Guide

The document outlines a process for extracting a dataset from a zip file in Google Colab and training a YOLOv8 model using the extracted data. It includes steps for mounting Google Drive, installing necessary packages, training the model for 60 epochs, and predicting results on a test image. Additionally, it demonstrates how to display the predicted image using OpenCV.

Uploaded by

Esron Romiansa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

YOLOv8 Mask Detection Setup Guide

The document outlines a process for extracting a dataset from a zip file in Google Colab and training a YOLOv8 model using the extracted data. It includes steps for mounting Google Drive, installing necessary packages, training the model for 60 epochs, and predicting results on a test image. Additionally, it demonstrates how to display the predicted image using OpenCV.

Uploaded by

Esron Romiansa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1. from google.

colab import drive

[Link]('/content/drive')

2. import zipfile

zip_path = "/content/drive/MyDrive/[Link]"

extract_to = "/content/dataset"

with [Link](zip_path, 'r') as zip_ref:

zip_ref.extractall(extract_to)

print("Dataset berhasil diekstrak!")

3. !pip install ultralytics

4. from ultralytics import YOLO

model = YOLO('[Link]')

[Link](

data="/content/dataset/[Link]",

epochs=60,

batch=16,

imgsz=480

5. from [Link] import Image, display

import [Link] as plt

import cv2

import os

from [Link] import cv2_imshow

results = [Link](source="/content/dataset/test/images/masker-18-
_jpg.[Link]", save=True)

save_dir = [Link].save_dir

result_image_name = "masker-18-_jpg.[Link]"

result_image_path = [Link](save_dir, result_image_name)

if not [Link](result_image_path):

print(f"Error: Image file not found at {result_image_path}")

else:

image = [Link](result_image_path)
if image is not None:

print("Menampilkan gambar menggunakan cv2_imshow:")

cv2_imshow(image)

else:

print(f"Error: Could not read image file at {result_image_path}")

You might also like