jiupinjia / stylized-neural-painting

Official Pytorch implementation of the preprint paper "Stylized Neural Painting", in CVPR 2021.
https://jiupinjia.github.io/neuralpainter/
Creative Commons Zero v1.0 Universal
1.56k stars 262 forks source link

`AttributeError: 'ProgressivePainter' object has no attribute 'x'` #16

Closed Zhenye-Na closed 3 years ago

Zhenye-Na commented 3 years ago

Hello Zhengxia,

Thank you for creating this project, very interesting!

I spent some time playing around with the colab runtime 1, I tried to increase the default hyper-parameters by multiplying 2, so far so good.

However,

# settings
args.canvas_size = 1024 # size of the canvas for stroke rendering'
args.max_m_strokes = 1000 # max number of strokes
args.max_divide = 15 # divide an image up-to max_divide x max_divide patches
...

I have updated the args.canvas_size, args.max_m_strokes by multiplying 2, while args.max_divide from 10 to 15, then in the "drawing" phase:

pt = ProgressivePainter(args=args)
final_rendered_image = optimize_x(pt)

It throws error like this:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-30-8f14c24057d5> in <module>()
      1 pt = ProgressivePainter(args=args)
----> 2 final_rendered_image = optimize_x(pt)

<ipython-input-23-25a3da86e7fa> in optimize_x(pt)
     51                 pt.step_id += 1
     52 
---> 53         v = pt._normalize_strokes(pt.x)
     54         v = pt._shuffle_strokes_and_reshape(v)
     55         PARAMS = np.concatenate([PARAMS, v], axis=1)

AttributeError: 'ProgressivePainter' object has no attribute 'x'

Do you know why this error is thrown? Personally, I think maybe this is because that there should be some "math formula" behind these three (or more) parameters ?

What do you think?

Thanks!

jiupinjia commented 3 years ago

Hi @Zhenye-Na, thanks for your feedback. Can you try to restart the runtime and run from the beginning cell?

Zhenye-Na commented 3 years ago

thans for the reply, I will try to re-run the colab notebook, will attach the error here if it appears again,

Zhenye-Na commented 3 years ago

still run into the same error:

initialize network with normal
loading renderer from pre-trained checkpoint...
begin drawing...
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-12-8f14c24057d5> in <module>()
      1 pt = ProgressivePainter(args=args)
----> 2 final_rendered_image = optimize_x(pt)

<ipython-input-11-25a3da86e7fa> in optimize_x(pt)
     51                 pt.step_id += 1
     52 
---> 53         v = pt._normalize_strokes(pt.x)
     54         v = pt._shuffle_strokes_and_reshape(v)
     55         PARAMS = np.concatenate([PARAMS, v], axis=1)

AttributeError: 'ProgressivePainter' object has no attribute 'x'

maybe it is the size of the image I choose? you can review the colab notebook I used here

DeclK commented 3 years ago

It seems to be the problem of values below --max_m_strokes 1000 --max_divide 15 I tried some different values, and I guess the max_m_strokes value has to be divisible by (max_divide * 50)? If you try --max_m_strokes 1500, that might work.