I trained my model for about 3 hours and I exported and downloaded the pkl file. But I can’t seem to load it into a learner.
I’ve downloaded the pkl file into kaggle and I used: learn = load_learner("../input/aptos-import/APTOS.pkl") to load it in.
But an error appears when I try to train it: /opt/conda/lib/python3.7/site-packages/fastprogress/fastprogress.py:74: UserWarning: Your generator is empty. warn("Your generator is empty.")
Hello, I have a similar concern with .pkl files. I have a series of textural features saved as pkl files, and when I try to open them in pyCharm (see image attached) they are written in an unfamiliar syntax. How do I fix this to make it readable? The code should read as a series of digits.
.pkl files are stored in binary format, so they will not be rendered as text in a text editor.
You could save files in a format which are understandable by the text editor and try.
For example, if you have a dictionary stored in your pickle file you could do something as follows
import pickle, json
your_pickle_file_path = "foo/bar.pkl"
with open(your_pickle_file_path, "rb") as f:
data = pickle.load(f)
# Save this file as a json (If the underlying object is a json)
destination_path = "./destination_file.json"
if isinstance(data, dict):
json.dump(data, open(destination_path, "w"))
# Save the file as a dataframe (If the underlying object is a dataframe)
import pandas as pd
destination_path = "./destination_file.csv"
if isinstance(data, pd.DataFrame):
data.to_csv(destination_path)
# Save the file as a text file (if the underlying object is a string)
import pandas as pd
destination_path = "./destination_file.txt"
with open(destination_path, "w") as f:
f.writelines(data)
It may not be the best idea to store model files which contain weights and biases in text format as you wouldn’t be able to get any actionable or insightful information by viewing them in a text file…