Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'caartoonize' #1

Open
calvin886 opened this issue Oct 12, 2020 · 17 comments
Open

ModuleNotFoundError: No module named 'caartoonize' #1

calvin886 opened this issue Oct 12, 2020 · 17 comments

Comments

@calvin886
Copy link

when i try to run: python vid.py. it shows error :"ModuleNotFoundError: No module named 'caartoonize'"

@Shaashwat05
Copy link
Owner

when i try to run: python vid.py. it shows error :"ModuleNotFoundError: No module named 'caartoonize'"

There is a spelling mistake there. Change the import from caartoonize to cartoonize, it will work.

@calvin886
Copy link
Author

Thanks a lot, it works after I change the word.

But, when i try to run: python vid.py, it shows me an error:

(cartoon) shideMacBook-Pro-4:Cartoonify_reality-master shi$ python vid.py Traceback (most recent call last): File "vid.py", line 3, in <module> from cartoonize import caart File "/Users/shi/Desktop/Cartoonify_reality-master/cartoonize.py", line 111, in <module> output=caart(cv2.imread("original.jpg")) File "/Users/shi/Desktop/Cartoonify_reality-master/cartoonize.py", line 102, in caart contours,_=cv2.findContours(edge,cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) ValueError: too many values to unpack (expected 2)

I seems like missing some values in either imread() or findContours() method.
Have you seen this error before?

@Shaashwat05
Copy link
Owner

Thanks a lot, it works after I change the word.

But, when i try to run: python vid.py, it shows me an error:

(cartoon) shideMacBook-Pro-4:Cartoonify_reality-master shi$ python vid.py Traceback (most recent call last): File "vid.py", line 3, in <module> from cartoonize import caart File "/Users/shi/Desktop/Cartoonify_reality-master/cartoonize.py", line 111, in <module> output=caart(cv2.imread("original.jpg")) File "/Users/shi/Desktop/Cartoonify_reality-master/cartoonize.py", line 102, in caart contours,_=cv2.findContours(edge,cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) ValueError: too many values to unpack (expected 2)

I seems like missing some values in either imread() or findContours() method.
Have you seen this error before?

In cartoonize.py, comment out the lines outside the caart function(lines 111 and so) since they are used for images to call the function. These lines may be interfering with the actual function for videos.

Also, I tried running the same code and there seem to be no other errors.

@calvin886
Copy link
Author

Thanks for your patience, when i comment out line 111 and line 112 in cartoonize.py, the first error solved. however, there is still a error cartoon) shideMacBook-Pro-4:Cartoonify_reality-master shi$ python vid.py Traceback (most recent call last): File "vid.py", line 14, in <module> img=caart(img) File "/Users/shi/Desktop/Cartoonify_reality-master/cartoonize.py", line 102, in caart contours,_=cv2.findContours(edge,cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) ValueError: too many values to unpack (expected 2)

It seems like, the findContours() function return more than two items, so the error happened.
Do you have any idea about this error?

@Shaashwat05
Copy link
Owner

Thanks for your patience, when i comment out line 111 and line 112 in cartoonize.py, the first error solved. however, there is still a error cartoon) shideMacBook-Pro-4:Cartoonify_reality-master shi$ python vid.py Traceback (most recent call last): File "vid.py", line 14, in <module> img=caart(img) File "/Users/shi/Desktop/Cartoonify_reality-master/cartoonize.py", line 102, in caart contours,_=cv2.findContours(edge,cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) ValueError: too many values to unpack (expected 2)

It seems like, the findContours() function return more than two items, so the error happened.
Do you have any idea about this error?

Its no problem, thank you for the doubts.

So I checked the OpenCV documentation and there seem to be 3 values that the findContours() function returns. The issue is that I ran the same code today and there was no error. Maybe it is because of version changes.

Try using 3 values as input to the function, with the middle value as contours. This should solve the problem

@Shaashwat05
Copy link
Owner

Shaashwat05 commented Dec 27, 2020 via email

@maitra
Copy link

maitra commented Dec 27, 2020

yes, you may consider fixing the line that is supposed to be uncommented. By default, the filename should be original2.jpg. But thanks for the code.

@Shaashwat05
Copy link
Owner

yes, you may consider fixing the line that is supposed to be uncommented. By default, the filename should be original2.jpg. But thanks for the code.

Happy to help

@maitra
Copy link

maitra commented Dec 27, 2020

Btw, the k-means clustering: does it cluster by individual channel? What is K here?

@Shaashwat05
Copy link
Owner

Shaashwat05 commented Dec 27, 2020

Btw, the k-means clustering: does it cluster by individual channel? What is K here?

It clusters the channels individually. So normally, an image is 8-bit right. In this, we try to cluster the 8-bits into 4-5 bits to reduce the number of colors. K is the number of bits.

@maitra
Copy link

maitra commented Dec 27, 2020

Btw, the k-means clustering: does it cluster by individual channel? What is K here?

It clusters the channels individually. So normally, an image is 8-bit right. In this, we try to cluster the 8-bits into 4-5 bits to reduce the number of colors. K is the number of bits.

I see, thanks! I wonder if we can distort the cartoon. Perhaps adding random noise to the contours might do it. Btw, separately, askopenfile from tkinter can stop the hardcoding of the input.

@maitra
Copy link

maitra commented Dec 27, 2020

def select_input() -> None:
    file = askopenfile(title='Please select one (any) frame from your set of ima
ges.',
                       filetypes=[('Image Files', ['.jpeg', '.jpg', '.png', '.gi
f',
                                                   '.tiff', '.tif', '.bmp'])])
    if file != None:
        return(file.name)
    
img_path=select_input()

output=caart(cv2.imread(img_path))

Hereis how you can do this. Should probably fix the output too, just add cartoon.jpg, after the filename (without extension).

@Shaashwat05
Copy link
Owner

Btw, the k-means clustering: does it cluster by individual channel? What is K here?

It clusters the channels individually. So normally, an image is 8-bit right. In this, we try to cluster the 8-bits into 4-5 bits to reduce the number of colors. K is the number of bits.

I see, thanks! I wonder if we can distort the cartoon. Perhaps adding random noise to the contours might do it. Btw, separately, askopenfile from tkinter can stop the hardcoding of the input.

How would distortion help??

@maitra
Copy link

maitra commented Dec 27, 2020

I see, thanks! I wonder if we can distort the cartoon. Perhaps adding random noise to the contours might do it. Btw, separately, askopenfile from tkinter can stop the hardcoding of the input.

How would distortion help??

Distortion would make the image into a true cartoon. Right now, it really makes outlines of the images and that is pretty much it. Right?

@Shaashwat05
Copy link
Owner

I see, thanks! I wonder if we can distort the cartoon. Perhaps adding random noise to the contours might do it. Btw, separately, askopenfile from tkinter can stop the hardcoding of the input.

How would distortion help??

Distortion would make the image into a true cartoon. Right now, it really makes outlines of the images and that is pretty much it. Right?

As of now, it reduces the bit size of the image and utilizes other OpenCV filters for contours and edges. I haven't thought of it by using distortion, but you can try and see for yourself.

@maitra
Copy link

maitra commented Dec 28, 2020

Distortion would make the image into a true cartoon. Right now, it really makes outlines of the images and that is pretty much it. Right?

As of now, it reduces the bit size of the image and utilizes other OpenCV filters for contours and edges. I haven't thought of it by using distortion, but you can try and see for yourself.

Yes, indeed. It will require more work than available routines. There are at least two ways of going about it. Perhaps reduce the widths of the contours randomly, and create an optical illusion. Another, more correct approach spatially distort the contours.

@Shaashwat05
Copy link
Owner

Distortion would make the image into a true cartoon. Right now, it really makes outlines of the images and that is pretty much it. Right?

As of now, it reduces the bit size of the image and utilizes other OpenCV filters for contours and edges. I haven't thought of it by using distortion, but you can try and see for yourself.

Yes, indeed. It will require more work than available routines. There are at least two ways of going about it. Perhaps reduce the widths of the contours randomly, and create an optical illusion. Another, more correct approach spatially distort the contours.

That is a nice idea indeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants