Mon Jun 26 05:12:51 PM CST 2023
53
demo.py
@ -1,53 +0,0 @@
|
|||||||
from ultralytics import YOLO
|
|
||||||
# from ultralytics.yolo.utils.benchmarks import benchmark 。
|
|
||||||
import cv2
|
|
||||||
|
|
||||||
# Load a model
|
|
||||||
# model = YOLO("yolov8n.yaml") # build a new model from scratch
|
|
||||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
|
||||||
|
|
||||||
# Use the model
|
|
||||||
# model.train(data="coco128.yaml", epochs=3,workers=0) # train the model,workers=0 if windows
|
|
||||||
# metrics = model.val() # evaluate model performance on the validation set
|
|
||||||
'''
|
|
||||||
results = model("bus.jpg") # predict on an image
|
|
||||||
print(results)
|
|
||||||
# '''
|
|
||||||
img_path = "./image/"
|
|
||||||
# results = model.predict(img_path, save=True,conf=0.5) # device=0 by default, conf:置信度阈值
|
|
||||||
# results = model.predict(img_path,save=True,classes=[0,2],conf=0.5) # i.e. classes=0,classes=[0,3,4]
|
|
||||||
|
|
||||||
# save detection results *
|
|
||||||
# results = model.predict(img_path,save=True,save_txt=True,classes=0,conf=0.4)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# predict video
|
|
||||||
video_path = "./video/1.mp4"
|
|
||||||
cap = cv2.VideoCapture(0)
|
|
||||||
|
|
||||||
# Loop through the video frames
|
|
||||||
while cap.isOpened():
|
|
||||||
# Read a frame from the video
|
|
||||||
success, frame = cap.read()
|
|
||||||
|
|
||||||
if success:
|
|
||||||
# Run YOLOv8 inference on the frame
|
|
||||||
results = model(frame)
|
|
||||||
|
|
||||||
# Visualize the results on the frame
|
|
||||||
annotated_frame = results[0].plot()
|
|
||||||
|
|
||||||
# Display the annotated frame
|
|
||||||
cv2.imshow("YOLOv8 Inference", annotated_frame)
|
|
||||||
|
|
||||||
# Break the loop if 'q' is pressed
|
|
||||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
# Break the loop if the end of the video is reached
|
|
||||||
break
|
|
||||||
|
|
||||||
# Release the video capture object and close the display window
|
|
||||||
cap.release()
|
|
||||||
cv2.destroyAllWindows()
|
|
0
detect_image.py
Normal file
0
detect_video.py
Normal file
BIN
image/182786930_7ea28fa4e5_b.jpg
Normal file
After Width: | Height: | Size: 157 KiB |
BIN
image/19749927709_0fc8e147f4_c.jpg
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
image/1_3B491ZMKZXn_8wNZzzmLjw.png
Normal file
After Width: | Height: | Size: 254 KiB |
BIN
image/2216426419_5ecce6a9b7_b.jpg
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
image/2216427485_4ab4a0ab15_b.jpg
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
image/26042575973_bec0ee4ed3_c.jpg
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
image/262351090_cce46a3aaf_b.jpg
Normal file
After Width: | Height: | Size: 167 KiB |
BIN
image/262351090_cce46a3aaf_c.jpg
Normal file
After Width: | Height: | Size: 122 KiB |
BIN
image/2637982077_a3eae26779.jpg
Normal file
After Width: | Height: | Size: 116 KiB |
BIN
image/26580716151_231617fa62_c.jpg
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
image/3141147409_a21cf55a3f_b.jpg
Normal file
After Width: | Height: | Size: 81 KiB |
BIN
image/3141148575_fa707caa51_b.jpg
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
image/3192850778_a357a8c4eb_b.jpg
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
image/3248900478_6c4a6820f7_c.jpg
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
image/345056969_e9cdec3f5b_b.jpg
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
image/3790917644_1439edce15_b.jpg
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
image/3790917644_1439edce15_c.jpg
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
image/391652196_caa374fa66_c.jpg
Normal file
After Width: | Height: | Size: 71 KiB |
BIN
image/4032144165_ae06416f49_b.jpg
Normal file
After Width: | Height: | Size: 194 KiB |
BIN
image/4032144629_74fccbaa55_b.jpg
Normal file
After Width: | Height: | Size: 126 KiB |
BIN
image/443608310_c7a2c5c461_b.jpg
Normal file
After Width: | Height: | Size: 113 KiB |
BIN
image/443608310_c7a2c5c461_c.jpg
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
image/4438771159_d7534ae13e_b.jpg
Normal file
After Width: | Height: | Size: 123 KiB |
BIN
image/45417730904_0ca22a249b_c.jpg
Normal file
After Width: | Height: | Size: 99 KiB |
BIN
image/4576880057_1da8f15531_c.jpg
Normal file
After Width: | Height: | Size: 216 KiB |
BIN
image/4590208246_9fe6b3ba4e_b.jpg
Normal file
After Width: | Height: | Size: 104 KiB |
BIN
image/5080604905_a3fa44daa2_c.jpg
Normal file
After Width: | Height: | Size: 77 KiB |
BIN
image/517635286_226efba7b5_z.jpg
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
image/52919232835_7efa5ba569_c.jpg
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
image/5345628611_c298fc968b_c.jpg
Normal file
After Width: | Height: | Size: 73 KiB |
BIN
image/5348993466_40cde6a06d_c.jpg
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
image/5751900082_3b019aa0f3_c.jpg
Normal file
After Width: | Height: | Size: 151 KiB |
BIN
image/6324133464_9605f83c27_c.jpg
Normal file
After Width: | Height: | Size: 88 KiB |
BIN
image/6364195427_0dca317ef3_c.jpg
Normal file
After Width: | Height: | Size: 63 KiB |
BIN
image/7454489180_bf2aeb87de_c.jpg
Normal file
After Width: | Height: | Size: 110 KiB |
BIN
image/FIKXSKACURH2DK7M6K6QTPZN5U.jpg
Normal file
After Width: | Height: | Size: 3.5 MiB |
BIN
image/maxresdefault.jpg
Normal file
After Width: | Height: | Size: 122 KiB |
BIN
image/rubikscube-2048px-08408.jpg
Normal file
After Width: | Height: | Size: 98 KiB |