!pip install ultralytics
import ultralytics
ultralytics.checks()
from ultralytics import YOLO
from IPython.display import Image
!pip install roboflow
from roboflow import Roboflow
rf = Roboflow(api_key="R5OIUVXGw9WhBkN2T30D")
project = rf.workspace("alpaco5-f3woi").project("part-autolabeld")
version = project.version(5)
dataset = version.download("yolov11")
!yolo task=segment mode=train data={dataset.location}/data.yaml model="yolo11n-seg.pt" epochs=25 imgsz=640
Image("/content/runs/segment/train/confusion_matrix.png", width=600)
Image("/content/runs/segment/train/labels.jpg", width=600)
Image("/content/runs/segment/train/results.png", width=600)
Image("/content/runs/detect/train/train_batch0.jpg", width=600)
Image("/content/runs/detect/train/val_batch0_pred.jpg", width=600)
Image("/content/runs/detect/train/val_batch1_pred.jpg", width=600)
!yolo task=detect mode=val model="/content/runs/detect/train/weights/best.pt" data={dataset.location}/data.yaml
!yolo task=detect mode=predict model="/content/runs/detect/train/weights/best.pt" conf=0.25 source={dataset.location}/test/images save=True
import glob
import os
from IPython.display import Image as IPyImage, display
latest_folder = max(glob.glob('/content/runs/detect/predict*/'), key=os.path.getmtime)
for img in glob.glob(f'{latest_folder}/*.jpg')[1:4]:
display(IPyImage(filename=img, width=600))
print("\n")
!gdown "https://drive.google.com/uc?id=1ACZp9gmtjEdIY-SHp8K0xdR0D8Gjd3j3&confirm=t"
!yolo task=detect mode=predict model= "/content/runs/detect/train/weights/best.pt" conf=0.25 source=image2.jpg save=True
Image("/content/runs/detect/predict2/image2.jpg", width=600)
!gdown "https://drive.google.com/uc?id=1Nyl18zr7zOJHh8uHtSic3dsJSY4LI_t-&confirm=t"
!gdown "https://drive.google.com/uc?id=1SxcrDanPAr-PZfJjWBxoa2t8lUSM2dZn&confirm=t"
!yolo task=detect mode=predict model= "/content/runs/detect/train/weights/best.pt" conf=0.25 source="PPE_Part1.mp4" save=True
from IPython.display import HTML
from base64 import b64encode
import os
save_path = '/content/runs/detect/predict3/PPE_Part1.avi'
compressed_path = "/content/result_compressed.mp4"
os.system(f"ffmpeg -i {save_path} -vcodec libx264 {compressed_path}")
mp4 = open(compressed_path,'rb').read()
data_url = "data