#๐Ÿ”’ opencv error for loading image

76 messages ยท Page 1 of 1 (latest)

vagrant sedge
#

works fine on .ipynb

rain narwhalBOT
#

@vagrant sedge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

vagrant sedge
#
    self.icon = cv2.imread("paddle.png") / 255.0
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'
#

and yeah, when running through .ipynb it works
and for .py I have to remove .0

frank juniper
vagrant sedge
#
environment.py  paddle.png  __pycache__
#

look this is all files

#

hey , but I am on docker right now

frank juniper
#

if you print(cv2.imread("paddle.png")) what does it show?

#

Before that line

vagrant sedge
#

wait

#

can't open file

#

but it is there

frank juniper
#

The error didn't say its missing

#

The error is saying that can't divide None and 255.0

vagrant sedge
#

[ WARN:[email protected]] global loadsave.cpp:241 findDecoder imread_('paddle.png'): can't open/read file: check file path/integrity

#

this is full error

frank juniper
#

Why can't it open the file?

#

Does the file have permissions?

vagrant sedge
#

yeah!!

frank juniper
vagrant sedge
#

home/user/Projects/Pong/RL/paddle.png

frank juniper
#

Didn't you say that its in the Docker container?

vagrant sedge
frank juniper
vagrant sedge
frank juniper
#

Check your Dockerfile?

#

How did you make it into Docker?

vagrant sedge
#

I am new to this

vagrant sedge
#

I am just using docker because of pytorch

#

so I pulll pytorch image in my Pong/

frank juniper
#

I forget. So is the paddle.png in Docker or not?

vagrant sedge
frank juniper
#

Did you make a Dockerfile?

vagrant sedge
#

yeah

frank juniper
#

Show whats in it

vagrant sedge
#

WORKDIR /app

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD ["python"]```
frank juniper
#

yeah so the paddle.png is in /app

vagrant sedge
#

yeah sort of

frank juniper
#

wdym sort of?

vagrant sedge
#

ignore that
/app/RL/paddle.png

frank juniper
#

ok

#

do that

#

imread that path

vagrant sedge
#

again same error

#

self.icon = cv2.imread("app/RL/paddle.png") / 255.0

#

I tried with RL/paddle.png also

frank juniper
#

You need to add / before the app

#

'/app/RL/paddle.png'

vagrant sedge
#

same error again

frank juniper
#

Can you share the full error message?

#

For the current one

vagrant sedge
#
Traceback (most recent call last):
  File "/app/RL/environment.py", line 243, in <module>
    obs = env.reset()
  File "/app/RL/environment.py", line 131, in reset
    self.striker = Striker()
  File "/app/RL/environment.py", line 31, in __init__
    self.icon = cv2.imread("/RL/paddle.png") / 255.0
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'```
vagrant sedge
#

I tried and same error

frank juniper
#

Show it please

vagrant sedge
#
Traceback (most recent call last):
  File "/app/RL/environment.py", line 243, in <module>
    obs = env.reset()
  File "/app/RL/environment.py", line 131, in reset
    self.striker = Striker()
  File "/app/RL/environment.py", line 31, in __init__
    self.icon = cv2.imread("app/RL/paddle.png") / 255.0
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'```
vagrant sedge
#
Traceback (most recent call last):
  File "/app/RL/environment.py", line 243, in <module>
    obs = env.reset()
  File "/app/RL/environment.py", line 132, in reset
    self.ball = Ball()
  File "/app/RL/environment.py", line 67, in __init__
    self.icon = cv2.imread("ball.png") / 255.0
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'```
frank juniper
#

If it errors that as well, I need to see it pls

vagrant sedge
#

ohh that's mean it;s working

frank juniper
#

So that means the paddle.png works

vagrant sedge
#

lemmme do that for ball.png

frank juniper
#

Make sure its the absolute file path for all

vagrant sedge
#

yeah thanks for the time buddy!

#

I did app/...

#

but forgot to add / before app

#

close

#

!close

rain narwhalBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.