bjascob / amrlib

A python library that makes AMR parsing, generation and visualization simple.
MIT License
216 stars 33 forks source link

errors while trying to run "amr_view" #29

Closed Bancherd-DeLong closed 2 years ago

Bancherd-DeLong commented 2 years ago

HI: Thank you for sharing. I might have missed the instructions, but when I tried to run "amr_view", I got the following errors: "AMRView Config stog_model_dir = /home/bancherd/.local/lib/python3.8/site-packages/amrlib/data/model_stog stog_model_fn = model.pt stog_device = cpu gtos_model_dir = /home/bancherd/.local/lib/python3.8/site-packages/amrlib/data/model_gtos gtos_num_ret_seq = 8 gtos_num_beams = 8 gtos_batch_size = 1 gtos_device = cpu render_format = pdf Exception in thread Thread-2: Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/home/bancherd/.local/lib/python3.8/site-packages/amrlib/amr_view/processor_gtos.py", line 39, in load_model self.inference = load_inference_model(self.model_dir, num_beams=self.num_beams, File "/home/bancherd/.local/lib/python3.8/site-packages/amrlib/models/model_factory.py", line 46, in load_inference_model raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), model_directory) FileNotFoundError: [Errno 2] No such file or directory: '/home/bancherd/.local/lib/python3.8/site-packages/amrlib/data/model_gtos' Exception in thread Thread-1: "

However, I have this in my "amr_view.json" file:

"{ "stog_model_dir": "/home/bancherd/amrlib/amrlib/data/model_stog", "stog_model_fn": "model.pt", "stog_device": "cuda:0", "gtos_model_dir": "Home/amrlib/amrlib/data/model_gtos", "gtos_num_ret_seq": 8, "gtos_num_beams": 8, "gtos_batch_size": 1, "gtos_device": "cuda:0", "render_format": "pdf" }"

Thanks,

Bancherd

bjascob commented 2 years ago

When you pip3 install amrlib it puts the amr_view script in your path (type which amr_view to see where). When you execute that script it will then load the json file from your pip3 install directory (ie.. /home/bjascob/.local/lib/python3.8/site-packages/amrlib/amr_view/amr_view.json). Change the paths in that file to point where you want them to.

If you'd prefer to run amr_view with a local copy of the project (not pip3 installed) look in scripts/50_Build_AMR_View and run the script run_amr_view.py. This should load the config from the local location.

BTW... When I tried this I notice an error NOT related to your issue above that is probably caused by the version of the transformers library I have installed. If you see the error (ImportError: cannot import name 'T5ForConditionalGeneration' from 'transformers'...). There's a simple fix that I'll post shortly.

Bancherd-DeLong commented 2 years ago

Got it. (Also confirmed T5F..-error. Thank you. I will close the issue.