TZYSJTU / Sketch-Generation-with-Drawing-Process-Guided-by-Vector-Flow-and-Grayscale

This is the official implementation of the AAAI 2021 accepted paper "Sketch Generation with Drawing Process Guided by Vector Flow and Grayscale"
Creative Commons Zero v1.0 Universal
288 stars 61 forks source link

AttributeError: 'NoneType' object has no attribute ‘shape' #2

Closed cedro3 closed 3 years ago

cedro3 commented 3 years ago

When I run the quickstart python cat.py in Google Colab, I get the following error:

Traceback (most recent call last): File "cat.py", line 129, in dirmask, = rotate(dir_mask, -angle, pad_color=0) File "/content/Sketch-Generation-with-Drawing-Process-Guided-by-Vector-Flow-and-Grayscale/drawpatch.py", line 9, in rotate (h, w) = image.shape[:2] AttributeError: 'NoneType' object has no attribute ‘shape'

nareshr8 commented 3 years ago

The other issue that I have raised (https://github.com/TZYSJTU/Sketch-Generation-with-Drawing-Process-Guided-by-Vector-Flow-and-Grayscale/issues/1) is the reason for this error. One of the intermediate file is not getting generated.

TZYSJTU commented 3 years ago

if name == 'main':

file_name = os.path.basename(input_path)
file_name = file_name.split('.')[0]
print(file_name)
output_path = output_path+"/"+file_name
if not os.path.exists(output_path):
    os.makedirs(output_path)
    os.makedirs(output_path+"/mask")
    os.makedirs(output_path+"/process")

check whether these directories generated

nareshr8 commented 3 years ago

mask and process folders are generated. Infact mask{}.png is getting generated. but the file that is expected is dir_mask{}.png which is not getting generated.

TZYSJTU commented 3 years ago
    for i in range(self.dir_num):
        if i==0:
            minimum = -90
            maximum = -90+length/2
            mask1 = 255*(((angle>minimum)+(angle==minimum))*(angle<maximum))
            maximum = 90
            minimum = 90-length/2
            mask2 = 255*((angle>minimum)+(angle==minimum))
            mask = mask1 + mask2
            cv2.imwrite(self.output_path+'./dir_mask{}.png'.format(i),np.uint8(mask.numpy()))
        else:
            minimum = -90+(i-1/2)*length   
            maximum = minimum + length  
            mask = 255*(((angle>minimum)+(angle==minimum))*(angle<maximum))
            cv2.imwrite(self.output_path+'./dir_mask{}.png'.format(i),np.uint8(mask.numpy()))

The corresponding code is in the file ETF/edge_tangent_flow.py Please check why these dir_mask{}.png files are not generated.

cedro3 commented 3 years ago

mask .png and tone_cumulate .png are generated in the mask folder. However, nothing is generated in the process folder.

TZYSJTU commented 3 years ago

see git

------------------ 原始邮件 ------------------ 发件人: "Yuichi Sugita"<notifications@github.com>; 发送时间: 2020年12月17日(星期四) 晚上9:16 收件人: "TZYSJTU/Sketch-Generation-with-Drawing-Process-Guided-by-Vector-Flow-and-Grayscale"<Sketch-Generation-with-Drawing-Process-Guided-by-Vector-Flow-and-Grayscale@noreply.github.com>; 抄送: "Einsames Brandenburg"<1390139621@qq.com>; "Comment"<comment@noreply.github.com>; 主题: Re: [TZYSJTU/Sketch-Generation-with-Drawing-Process-Guided-by-Vector-Flow-and-Grayscale] AttributeError: 'NoneType' object has no attribute ‘shape' (#2)

mask .png and tone_cumulate .png are generated in the mask folder. However, nothing is generated in the process folder.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

cedro3 commented 3 years ago

Would you tell me how to get python cat.py working correctly?

TZYSJTU commented 3 years ago
for i in range(self.dir_num):
    if i==0:
        minimum = -90
        maximum = -90+length/2
        mask1 = 255*(((angle>minimum)+(angle==minimum))*(angle<maximum))
        maximum = 90
        minimum = 90-length/2
        mask2 = 255*((angle>minimum)+(angle==minimum))
        mask = mask1 + mask2
        cv2.imwrite(self.output_path+'./dir_mask{}.png'.format(i),np.uint8(mask.numpy()))
    else:
        minimum = -90+(i-1/2)*length   
        maximum = minimum + length  
        mask = 255*(((angle>minimum)+(angle==minimum))*(angle<maximum))
        cv2.imwrite(self.output_path+'./dir_mask{}.png'.format(i),np.uint8(mask.numpy()))

Please improve your coding skills

nareshr8 commented 3 years ago

@TZYSJTU stop being rude. First of all @cedro3 is just asking about execution. If your code isn't working and throwing errors people are asking about it, it has nothing to do with their coding skill. You suggest to run a Python file. But it is failing. Its your code which should be inspected.

Your code is not running in our machine. In that case it is not we who are at fault. Your potential arguments that it is working on my and my friends machine aren't relevant.

Note: You have no rights to comment on others coding skills. You haven't seen his or my coding skill to judge us. In the end its your code that is not replicatable. I respect your work. But stop being rude.

TZYSJTU commented 3 years ago

I can't guarantee that my code can run successfully on everyone's machines because of various strange reasons. In addition, I have pointed out the corresponding solution to you. I think I have done enough.

cedro3 commented 3 years ago

Thank you for your kind point. With the code you taught me, I modified lines 137-151 in edge_tangent_flow.py. However, the same error occurs as shown below.

Traceback (most recent call last): File "cat.py", line 129, in dirmask, = rotate(dir_mask, -angle, pad_color=0) File "/content/Sketch-Generation-with-Drawing-Process-Guided-by-Vector-Flow-and-Grayscale/drawpatch.py", line 9, in rotate (h, w) = image.shape[:2] AttributeError: 'NoneType' object has no attribute 'shape'

TZYSJTU commented 3 years ago

This means 'image' is none. Is dir_mask{}.png generated now?

nareshr8 commented 3 years ago

Yes. Found the issue. The line : cv2.imwrite(self.output_path+'./dir_mask{}.png'.format(i),np.uint8(mask.numpy()))

must be:

cv2.imwrite(self.output_path+'/dir_mask{}.png'.format(i),np.uint8(mask.numpy()))

The mismatch has an extra dot in the first parameter near between output_path and / cv2.imwrite(self.output_path+'./dir_mask{}.png'.format(i),np.uint8(mask.numpy()))

Removing it in both if and else resolved it.

TZYSJTU commented 3 years ago

Thanks for your discovery, I have corrected the code. I like programmers like you. @nareshr8

cedro3 commented 3 years ago

Thank you so much. The error has been fixed.