קורס יסודות בינה מלאכותית – RB23-06
CANVA בינה מאלכותית משנה תמונות – אז מה האמת ?
יצירת מוסיקה מטקטס
https://huggingface.co/spaces/facebook/MusicGen
רשות : העשרה
יצירת סרטון
https://www.youtube.com/watch?v=dwenyOgLZwg
שימוש במנוע בינה מלאכותית https://copilot.microsoft.com/
זיהוי אובייקטים :
https://colab.research.google.com/
1 2 3 4 5 6 |
%pip install ultralytics import ultralytics ultralytics.checks() !pip install opencv-python-headless print ("done") |
1 2 |
# Run YOLOv8 model on the specified image with a confidence threshold of 0.54 !yolo predict model=yolov8n.pt source='https://robotronix.co.il/wp-content/uploads/2024/05/3-300x199.jpg' conf=0.54 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from ultralytics import YOLO import cv2 # Load the YOLOv8 model pre-trained on COCO dataset model = YOLO('yolov8n.pt') # You can choose 'yolov8n', 'yolov8s', 'yolov8m', 'yolov8l', or 'yolov8x' # Load the image image_path = '2.jpg' image = cv2.imread(image_path) # Run inference on the image results = model(image_path) # Filter results to count only people people_count = 0 for result in results: for box in result.boxes: if box.cls == 0: # Class 0 corresponds to 'person' in the COCO dataset people_count += 1 # Display the number of people detected print(f"Number of people detected: {people_count}") |
במבוא לסקירפטים
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import cv2 import pytube from ultralytics import YOLO import matplotlib.pyplot as plt # Function to download the YouTube video def download_youtube_video(url, output_path='video.mp4'): yt = pytube.YouTube(url) stream = yt.streams.filter(file_extension='mp4').first() stream.download(filename=output_path) return output_path # Function to process the first 10 seconds of the video def process_video(video_path, seconds=10, fps=30): cap = cv2.VideoCapture(video_path) frames = [] frame_interval = fps # Extract one frame per second for i in range(seconds): cap.set(cv2.CAP_PROP_POS_FRAMES, i * frame_interval) ret, frame = cap.read() if not ret: break frames.append(frame) cap.release() return frames # Function to run YOLOv8 on frames and save images def run_yolo_on_frames(frames, model, output_dir='output_images'): results = [] for idx, frame in enumerate(frames): result = model(frame) results.append(result) annotated_frame = result[0].plot(line_width=1, font_size=10) # Save annotated frame as an image output_path = f"{output_dir}/frame_{idx+1}.jpg" cv2.imwrite(output_path, cv2.cvtColor(annotated_frame, cv2.COLOR_RGB2BGR)) plt.imshow(cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB)) plt.axis('off') plt.show() return results # Main code youtube_url = 'https://www.youtube.com/shorts/mmEZ7pdrVIQ' video_path = download_youtube_video(youtube_url) print(f"Video downloaded to: {video_path}") model = YOLO('yolov8n.pt') # Load YOLOv8 model frames = process_video(video_path, seconds=10, fps=30) results = run_yolo_on_frames(frames, model) print("Processing completed and images saved.") |
COLAB
- אימון בינה מלאכותית