-3

I'm trying to use the code from this Github repo : https://github.com/dairui01/TSU_evaluation/tree/main/Frame_map

When I replace the csv file there and the pkl file with my own, I get the following error in my terminal:

 (this is what I entered)python Frame_based_map.py -split CS -pkl_path ./data.pkl
 THis is the printout:
Traceback (most recent call last):
  File "Frame_based_map.py", line 47, in <module>
    logits = pickle.load(pkl, encoding='latin1')
ModuleNotFoundError: No module named 'models'

https://drive.google.com/drive/folders/1Y-EOwSNUT1r5dxTi1MP0668weZlnLfJ9?usp=sharing

This is the google drive link to the files I am using, with the github code. The files are generated using the same method as the github link, so I am not sure what is wrong with my data.pkl file.

Any help is appreciated :)

Thank you!

Megan Darcy
  • 530
  • 5
  • 15
  • 1
    Loading that pickle file would require you to have a module called `models` (with the correct classes, etc.), which you apparently don't. Without the correct file present, you can't load that file. – AKX Sep 09 '22 at 07:41
  • @AKX how should I install the right `models` module? Like is there a specific version becasue I don't think it's specified in the git page. I'm quite new to this :) – Megan Darcy Sep 09 '22 at 07:47
  • You say it's your own .pkl file, so it's _your_ `models` module that's missing (that was present when you created the .pkl file). There's nothing to necessarily install. – AKX Sep 09 '22 at 07:55
  • but when I am running the test.pkl which is in the same format as mine, i didn't have any issue. So not sure why my pkl has this issue haha >< @AKX – Megan Darcy Sep 09 '22 at 08:24
  • A pkl file can contain absolutely any Python object, so you can't say "in the same format" without inspecting the file's contents with e.g. `pickletools`. The issue here is you're trying to use a pkl file that references a `models` module (as you had pickled an object that refers to that module) in a directory or project where there isn't such a module. – AKX Sep 09 '22 at 08:30

1 Answers1

1

data.pkl itself references the models module. The process of unpickling tries to load it and fails, since you do not have it.

Petras Purlys
  • 1,093
  • 6
  • 18
  • Oh I see! Thanks~ which `models` module do I need to install? I don't think it's specified in the git page :( – Megan Darcy Sep 09 '22 at 07:45
  • because when i ran their example pkl it worked fine in the current env – Megan Darcy Sep 09 '22 at 07:52
  • I'd suggest inspecting the pickled file, this post has some good insights on how to do that: https://stackoverflow.com/questions/64850179/inspecting-a-pickle-dump-for-dependencies It's hard to know where the module came from with knowing how the environment was set up. Also, you could try asking the repo owner how the file was generated, but there might not be a reply if you do not know each other. Welcome to the complicated world of simple python. – Petras Purlys Sep 09 '22 at 08:07