Opencv error: name `cv2` is not defined

I also switched to fastai==0.7.0 following the announcement but now I am getting this error

/usr/local/lib/python3.6/dist-packages/fastai/ in ()
3 from enum import IntEnum
----> 5 def scale_min(im, targ, interpolation=cv2.INTER_AREA):
6 “”" Scales the image so that the smallest axis is of size targ.

NameError: name ‘cv2’ is not defined

did someone else faced this issue too? I am stuck for a while.

Hi @amit007,

Have you tried to update your environment again using the version 0.7 source code ?

1 Like

it works fine now,(the same code)!

1 Like

I occured the same problem, how can you solved? I have fastai==1.0.11

I apparently solved the cv2 import problem by importing it directly as ‘import cv2’. It seems to work but I won’t know for sure until I find out how to import FilesDataset. I believe that I have fastai v1.0.24, but I am at work so not positive.

Hope that helps,

I solved the cv2 problem by importing ’ import cv2 ’ in

How you did this?

I have the same error using the kaggle kernel. I installed fastai==0.7.0 via pip and then tried import cv2 but still can’t import conv_learner.