Screenshot to RGB

Hello. Any solution?
When I write pil instead of pytorch (line19), it does not give an error, but the pil is slower. I want to use pytorch.

My Code

Errors

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Users\1700x\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\1700x\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "F:\screenss.py", line 89, in main
    check4()
  File "F:\screenss.py", line 33, in check4
    rgb = im.convert('RGB')
AttributeError: 'Tensor' object has no attribute 'convert'

PyTorch doesn’t provide any image decoding methods and torchvision uses PIL by default.
You could try to use OpenCV instead of PIL or alternatively PIL-SIMD, which might speedup your code.

1 Like