On Ubuntu 24.10: (PyCharm 2024.3 Community Edition)
Code snippet:
model_name = "yolo11n" # pretrained Ultralytics model for YOLO11, nano, COCO dataset
model = YOLO(f"{model_name}.pt") # the nano model by Ultralytics
image_name = "screen" # current screen content is the input source for inference
results = model(f"{image_name}", stream=True) # using a parameter driven value for input source
for result in results:
Error message:
Traceback (most recent call last):
File "/home/reza/PycharmProjects/yolo11/predict/screen_predict.py", line 60, in <module>
for result in results:
^^^^^^^
File "/home/reza/PycharmProjects/yolo11/.venv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
response = gen.send(None)
^^^^^^^^^^^^^^
File "/home/reza/PycharmProjects/yolo11/.venv/lib/python3.12/site-packages/ultralytics/engine/predictor.py", line 245, in stream_inference
for self.batch in self.dataset:
^^^^^^^^^^^^
File "/home/reza/PycharmProjects/yolo11/.venv/lib/python3.12/site-packages/ultralytics/data/loaders.py", line 277, in __next__
im0 = np.asarray(self.sct.grab(self.monitor))[:, :, :3] # BGRA to BGR
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/reza/PycharmProjects/yolo11/.venv/lib/python3.12/site-packages/mss/base.py", line 101, in grab
screenshot = self._grab_impl(monitor)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/reza/PycharmProjects/yolo11/.venv/lib/python3.12/site-packages/mss/linux.py", line 428, in _grab_impl
ximage = self.xlib.XGetImage(
^^^^^^^^^^^^^^^^^^^^
File "/home/reza/PycharmProjects/yolo11/.venv/lib/python3.12/site-packages/mss/linux.py", line 230, in _validate
raise ScreenShotError(msg, details=details)
mss.exception.ScreenShotError: XGetImage() failed
Process finished with exit code 1
Would appreciate some guidance, please. Thanks.
Regards.