קורס יסודות בינה מלאוכתית – RB23-10
אימון בינה מלאכותית – זיהוי אובייקטים
תרגיל כיתה 1
- יש לעבוד לפי הסרטון שלב אחרי שלב .
- הסרטון הוא המשך של הרצאה RB23-09 RB23-08 שם מוספר שלב אחרי שלב של התקנת הסביבה פיתוח , תוספים
תרגיל כיתה 2
אימון רשת זיהוי טנק
https://colab.research.google.com/gist/RoboWild/19deff31306d95d2e315a9e1d331f156/yolo-train.ipynb
1 2 3 4 5 6 |
%pip install ultralytics import ultralytics ultralytics.checks() !pip install opencv-python-headless print (" **** done **** ") |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
!touch data.yaml # Open a new file called data.yaml in write mode with open('data.yaml', 'w') as file: # Write the specified content to the file file.write(""" train: /content/tanks/train val: /content/tanks/val nc: 4 names: ["tank", "car", "APC", "truck"] """) # Verify the content of the data.yaml file with open('data.yaml', 'r') as file: print(file.read()) |
1 |
!apt-get install -y unrar |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import os from google.colab import files # Upload the rar file uploaded = files.upload() # List the uploaded files uploaded_files = list(uploaded.keys()) print(f'Uploaded files: {uploaded_files}') # Assuming the rar file is the first (and only) uploaded file rar_file = uploaded_files[0] # Create a directory to extract the rar file extract_dir = rar_file.replace('.rar', '') os.makedirs(extract_dir, exist_ok=True) # Extract the rar file !unrar x {rar_file} {extract_dir} # List the contents of the extracted directory print(f'Contents of the extracted directory ({extract_dir}):') print(os.listdir(extract_dir)) |
1 2 3 4 5 |
from ultralytics import YOLO import ultralytics print(ultralytics.__version__) model=YOLO("yolov8m.pt") |
1 2 3 |
# train the a.i model to detect tanks model.train(data="/content/data.yaml",batch=16, epochs=10) |
1 |
pre=YOLO("/content/runs/detect/train3/weights/best.pt") |
1 |
pre.predict("/content/tanks/val/images/tanks-dessert-79.jpg",save=True, conf=0.3) |