demo_shitu/1.py

29 lines
837 B
Python

from ultralytics import YOLO,Explorer
# Load a pre-trained YOLOv10n model
model = YOLO("./yolov10x.pt")
# explorer = Explorer(data="./dataset.yaml", model="yolov10x.pt")
# explorer.create_embeddings_table()
# similar_images_df = explorer.get_similar(img="./1.jpg")
# a=explorer.sql_query("WHERE labels LIKE '%person%' AND labels LIKE '%cake%' LIMIT 10")
# print(a)
results =model.train(data="./dataset.yaml", epochs=3)
# results = model("./1.jpg")metrics = model.val()
print(results)
# 保存模型
model.export(format='onnx')
# results[0].show()
# metrics = model.val()
# print(metrics)
# 保存模型
# model.export(format='onnx')
# Perform object detection on an image
# results = model("./1.jpg")
# print(results)
# Display the results
# results[0].show()
# results[0].save(filename="result.jpg") # save to disk 保存到磁盘