MMSRL

Our Multimodal Semantic Role Labeling model for CONSTRAINT 2022
git clone https://esimon.eu/repos/MMSRL.git
Log | Files | Refs | Submodules | README

show_predictions.py (694B)


      1 import pathlib
      2 import pickle
      3 import sys
      4 
      5 
      6 def show_predictions(path: pathlib.Path) -> None:
      7     with path.open("rb") as input_file:
      8         try:
      9             while True:
     10                 image, entities = pickle.load(input_file)
     11                 for entity, prediction in entities.items():
     12                     prediction_str = " ".join(map(str, prediction.tolist()))
     13                     print(f"{image}\t{entity}\t{prediction_str}")
     14                 print("")
     15         except EOFError:
     16             pass
     17 
     18 
     19 if __name__ == "__main__":
     20     if len(sys.argv) != 2:
     21         print(f"Usage: {sys.argv[0]} prediction_file", file=sys.stderr)
     22         sys.exit(1)
     23     show_predictions(pathlib.Path(sys.argv[1]))