def save_data(PredicteData, metadata, dataname, pdindex, imagenames, save_as_csv):
"""Save predicted data as h5 file and metadata as pickle file; created by predict_videos.py"""
DataMachine = pd.DataFrame(PredicteData, columns=pdindex, index=imagenames)
if save_as_csv:
print("Saving csv poses!")
DataMachine.to_csv(dataname.split(".h5")[0] + ".csv")
DataMachine.to_hdf(dataname, "df_with_missing", format="table", mode="w")
with open(dataname.split(".h5")[0] + "_meta.pickle", "wb") as f:
# Pickle the 'data' dictionary using the highest protocol available.
pickle.dump(metadata, f, pickle.HIGHEST_PROTOCOL)
def save_metadata(metadatafilename, data, trainIndices, testIndices, trainFraction):
with open(metadatafilename, "wb") as f:
# Pickle the 'labeled-data' dictionary using the highest protocol available.
pickle.dump(
[data, trainIndices, testIndices, trainFraction], f, pickle.HIGHEST_PROTOCOL
)
def load_metadata(metadatafile):
with open(metadatafile, "rb") as f:
[
trainingdata_details,
trainIndices,
testIndices,
testFraction_data,
] = pickle.load(f)
return trainingdata_details, trainIndices, testIndices, testFraction_data
def get_immediate_subdirectories(a_dir):
"""Get list of immediate subdirectories"""
return [
name for name in os.listdir(a_dir) if os.path.isdir(os.path.join(a_dir, name))
]
meta_py
最新推荐文章于 2024-07-29 14:37:54 发布