Closed Teymoor-Ali closed 3 months ago
You can use the Python API.
from ultralytics import YOLOv10
model = YOLOv10("best.pt")
model.predict(...)
add ‘prediction = prediction['one2many'][0]’ to File "I:\Github\test\yolov10-main\yolov10-main\ultralytics\utils\ops.py", line 216, in non_max_suppression bs = prediction.shape[0] # batch size
final code:
prediction = prediction['one2many'][0]
bs = prediction.shape[0]
add ‘prediction = prediction['one2many'][0]’ to File "I:\Github\test\yolov10-main\yolov10-main\ultralytics\utils\ops.py", line 216, in non_max_suppression bs = prediction.shape[0] # batch size
final code:
prediction = prediction['one2many'][0] bs = prediction.shape[0]
You shouldn't do this because NMS shouldn't be used for post-processing at all. Otherwise it defeats the purpose.
You can also rename the best.pt
file to yolov10.pt
to fix the CLI tool because the code decides based on that whether it's YOLOv10 or not:
from ultralytics import YOLOv10
Just to double check, I installed this Repo, unless theres another repo thats not the main ultralytics package thats contains YOLOv10? as far as i know they havent merges the yolo10 code into their main.
ImportError: cannot import name 'YOLOv10' from 'ultralytics' (c:\Users\Teymo\AppData\Local\Programs\Python\Python311\Lib\site-packages\ultralytics__init__.py)
from ultralytics import YOLOv10
Just to double check, I installed this Repo, unless theres another repo thats not the main ultralytics package thats contains YOLOv10? as far as i know they havent merges the yolo10 code into their main.
ImportError: cannot import name 'YOLOv10' from 'ultralytics' (c:\Users\Teymo\AppData\Local\Programs\Python\Python311\Lib\site-packages\ultralyticsinit.py)
How did you install it? You should use pip install -e .
and be running the import from inside the repo directory.
Yes, I have done pip install, I assume I have to switch to the directory for it to import.
I have been using juypter notebooks on visual studio.
Yes, I have done pip install, I assume I have to switch to the directory for it to import.
I have been using juypter notebooks on visual studio.
Yeah. You have to cd into that directory.
In Jupyter, you do %cd /path/
to change directory.
Apologies, didnt realise that the conda environment with the YOLOV10 installation was not selected. I got it working now, Thanks.
You can use the Python API.
from ultralytics import YOLOv10 model = YOLOv10("best.pt") model.predict(...)
I used the code to predict, but do not know where the prediction results save?
Could you please try to pass save=True
into model.predict()
?
您可以使用 Python API。
from ultralytics import YOLOv10 model = YOLOv10("best.pt") model.predict(...)
他会保存在哪
You can use the Python API.
from ultralytics import YOLOv10 model = YOLOv10("best.pt") model.predict(...)
I used the code to predict, but do not know where the prediction results save?
Hello, have you found a way to save the results?
Could you please try to add save=True
in model.predict(...)
?
from ultralytics import YOLOv10
model = YOLOv10("yolov10n.pt")
model.predict(save=True)
And the results will be saved in runs/detect/predict
by default.
WARNING ⚠️ 'source' is missing. Using 'source=ultralytics/assets'.
image 1/2 ultralytics/assets/bus.jpg: 640x480 4 persons, 1 bus, 83.2ms
image 2/2 ultralytics/assets/zidane.jpg: 384x640 2 persons, 82.5ms
Speed: 2.3ms preprocess, 82.8ms inference, 1.5ms postprocess per image at shape (1, 3, 384, 640)
Results saved to runs/detect/predict2
Could you please try to add
save=True
inmodel.predict(...)
?from ultralytics import YOLOv10 model = YOLOv10("yolov10n.pt") model.predict(save=True)
And the results will be saved in
runs/detect/predict
by default.WARNING ⚠️ 'source' is missing. Using 'source=ultralytics/assets'. image 1/2 ultralytics/assets/bus.jpg: 640x480 4 persons, 1 bus, 83.2ms image 2/2 ultralytics/assets/zidane.jpg: 384x640 2 persons, 82.5ms Speed: 2.3ms preprocess, 82.8ms inference, 1.5ms postprocess per image at shape (1, 3, 384, 640) Results saved to runs/detect/predict2
Thanks for answering! It worked!
I want to do object tracking for the video. The python code is import cv2 from ultralytics import YOLO model = YOLO('/data/anonym1/project-office/ultralytics-main/detect/train2/weights/best.pt') video_path = "/data/anonym1/Users/ghm_data/yolov9-main/yolov9-main/Manhole_image/test/Drone_aerial_video_3.mp4" cap = cv2.VideoCapture(video_path) while cap.isOpened(): success, frame = cap.read() if success: results = model.track(frame, persist=True, save=True) print(results[0].boxes) annotated_frame = results[0].plot() cv2.imshow("YOLOv10 Tracking", annotated_frame) if cv2.waitKey(1) & 0xFF == ord("q"): break else: break cap.release() cv2.destroyAllWindows()
But there is an error, the error code is:
Traceback (most recent call last):
File "/data/anonym1/Users/ghm_data/yolov10-main/tracker.py", line 18, in
You can also rename the
best.pt
file toyolov10.pt
to fix the CLI tool because the code decides based on that whether it's YOLOv10 or not:
The author seems to ignore this issue. This is a very simple and effective method
@wint11 Could you please try to replace YOLO
with YOLOv10
? Thanks!
@JaySonWu-star Thanks! We just made the YOLOv10 by default in cli. Could you please update the codebase and try again? Thank you!
Hi so i trained my model and im trying to run inference,
Command used "!yolo predict model="I:/Github/test/runs/detect/train/weights/best.pt" source="03_001_130524.png"
i get this error File "c:\Users\Teymo.conda\envs\YOLO10\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\Users\Teymo.conda\envs\YOLO10\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\Teymo.conda\envs\YOLO10\Scripts\yolo.exe__main.py", line 7, in
sys.exit(entrypoint())
File "I:\Github\test\yolov10-main\yolov10-main\ultralytics\cfg\ init__.py", line 587, in entrypoint
getattr(model, mode)(**overrides) # default args from model
File "I:\Github\test\yolov10-main\yolov10-main\ultralytics\engine\model.py", line 441, in predict
return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream)
File "I:\Github\test\yolov10-main\yolov10-main\ultralytics\engine\predictor.py", line 177, in predictcli
for in gen: # noqa, running CLI inference without accumulating any outputs (do not modify)
File "c:\Users\Teymo.conda\envs\YOLO10\lib\site-packages\torch\utils_contextlib.py", line 35, in generator_context
response = gen.send(None)
File "I:\Github\test\yolov10-main\yolov10-main\ultralytics\engine\predictor.py", line 255, in stream_inference
self.results = self.postprocess(preds, im, im0s)
File "I:\Github\test\yolov10-main\yolov10-main\ultralytics\models\yolo\detect\predict.py", line 25, in postprocess
preds = ops.non_max_suppression(
File "I:\Github\test\yolov10-main\yolov10-main\ultralytics\utils\ops.py", line 216, in non_max_suppression
bs = prediction.shape[0] # batch size
AttributeError: 'dict' object has no attribute 'shape'