CogView2 icon indicating copy to clipboard operation
CogView2 copied to clipboard

InferenceModel class do not have from_pretrained()

Open akira-sasaki opened this issue 3 years ago • 9 comments

I build cogview2 with colab. And run your script, I have this error.

InferenceModel class do not have from_pretrained().

!./text2image.sh --input-source input.txt
WARNING: No training data specified
using world size: 1 and model-parallel size: 1 
Traceback (most recent call last):
  File "cogview2_text2image.py", line 233, in <module>
    main(args)
  File "cogview2_text2image.py", line 48, in main
    model, args = InferenceModel.from_pretrained(args, 'coglm')
AttributeError: type object 'InferenceModel' has no attribute 'from_pretrained'

Are there any omissions in the committed sources?

akira-sasaki avatar Jun 16 '22 01:06 akira-sasaki

This is strange, InferenceModel should have this method by Inheriting. Could you share your version of Python and SwissArmyTransformer(you can upgrade it to 0.2.3 and try again)?

Sleepychord avatar Jun 16 '22 06:06 Sleepychord

I used old version SwissArmyTransformer==0.1.2. I update to 0.2.3 and try again.

akira-sasaki avatar Jun 16 '22 06:06 akira-sasaki

I had error, again

Traceback (most recent call last):
  File "cogview2_text2image.py", line 19, in <module>
    from SwissArmyTransformer import get_args, get_tokenizer
  File "/usr/local/lib/python3.7/dist-packages/SwissArmyTransformer/__init__.py", line 4, in <module>
    from .model import AutoModel
  File "/usr/local/lib/python3.7/dist-packages/SwissArmyTransformer/model/__init__.py", line 3, in <module>
    from .encoder_decoder_model import EncoderDecoderModel
  File "/usr/local/lib/python3.7/dist-packages/SwissArmyTransformer/model/encoder_decoder_model.py", line 87
    return encoder_outputs, decoder_outputs, *mems
                                             ^
SyntaxError: invalid syntax

I use python 3.7, which version of Python should I use? 

akira-sasaki avatar Jun 16 '22 06:06 akira-sasaki

according to this issue #4 , maybe you should upgrade it to python 3.8.

Sleepychord avatar Jun 16 '22 07:06 Sleepychord

Can you share the Colab notebook? I can periodically try it and pray that I get an A100.

metaphorz avatar Jun 16 '22 17:06 metaphorz

@metaphorz Here is Replicate demo that is backed with A100 if you are interested :) https://replicate.com/thudm/cogview2

chenxwh avatar Jun 17 '22 11:06 chenxwh

@chenxwh thank you I will try

metaphorz avatar Jun 18 '22 03:06 metaphorz

@metaphorz I shared colab working. https://github.com/akira-sasaki/playground/blob/main/CogView2.ipynb

The GPU memory is 16GB at ColabPro+. So, we need --only-first-stage option.

If you want to make it all work, you might need an A100.

akira-sasaki avatar Jun 19 '22 00:06 akira-sasaki

@akira-sasaki thanks very much.

metaphorz avatar Jun 19 '22 20:06 metaphorz