I am trying to install styleformer module in Jupyter Notebook Server having Tensorflow 2.3 as kernel with Python 3.6
Module: https://github.com/PrithivirajDamodaran/Styleformer
Since there is no internet in server, I upload the github file in notebook from local and install this using setup.py file.
One problem is that I have to be always inside the Styleformer ( Note: S capital) folder to run this command
from styleformer import Styleformer
But as soon as I run this command:
sf = Styleformer(style = 0)
It gives the below error:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/transformers/configuration_utils.py in get_config_dict(cls, pretrained_model_name_or_path, **kwargs)
241 if resolved_config_file is None:
--> 242 raise EnvironmentError
243 config_dict = cls._dict_from_json_file(resolved_config_file)
OSError:
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call last)
/usr/local/bin/kernel-launchers/python/scripts/launch_ipykernel.py in <module>
1 from styleformer import Styleformer
----> 2 sf = Styleformer(style = 0)
~/Styleformer/styleformer/styleformer.py in __init__(self, style)
7
8 self.style = style
----> 9 self.adequacy = Adequacy()
10 self.model_loaded = False
11
~/Styleformer/styleformer/adequacy.py in __init__(self, model_tag)
3 def __init__(self, model_tag='prithivida/parrot_adequacy_on_BART'):
4 from transformers import AutoModelForSequenceClassification, AutoTokenizer
----> 5 self.nli_model = AutoModelForSequenceClassification.from_pretrained(model_tag)
6 self.tokenizer = AutoTokenizer.from_pretrained(model_tag)
7
/opt/conda/lib/python3.6/site-packages/transformers/modeling_auto.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
1357 config = kwargs.pop("config", None)
1358 if not isinstance(config, PretrainedConfig):
-> 1359 config = AutoConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
1360
1361 for config_class, model_class in MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING.items():
/opt/conda/lib/python3.6/site-packages/transformers/configuration_auto.py in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
201
202 """
--> 203 config_dict, _ = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
204
205 if "model_type" in config_dict:
/opt/conda/lib/python3.6/site-packages/transformers/configuration_utils.py in get_config_dict(cls, pretrained_model_name_or_path, **kwargs)
249 f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a {CONFIG_NAME} file\n\n"
250 )
--> 251 raise EnvironmentError(msg)
252
253 except json.JSONDecodeError:
OSError: Can't load config for 'prithivida/parrot_adequacy_on_BART'. Make sure that:
- 'prithivida/parrot_adequacy_on_BART' is a correct model identifier listed on 'https://huggingface.co/models'
- or 'prithivida/parrot_adequacy_on_BART' is the correct path to a directory containing a config.json file
Is there a way to fix this error. May be by uploading the file manually? As it calls the below lines for style=0:
class Styleformer():
def __init__(self, style=0):
from transformers import AutoTokenizer
from transformers import AutoModelForSeq2SeqLM
from styleformer import Adequacy
self.style = style
self.adequacy = Adequacy()
self.model_loaded = False
if self.style == 0:
self.ctf_tokenizer = AutoTokenizer.from_pretrained("prithivida/informal_to_formal_styletransfer")
self.ctf_model = AutoModelForSeq2SeqLM.from_pretrained("prithivida/informal_to_formal_styletransfer")
print("Casual to Formal model loaded...")
self.model_loaded = True
Note: When I run same thing on Google Colab, It automatically downloads few files and works fine. I do not know which file or models it downloads. It's a bit confusing. Please help.