# Path: humanrl/utils.py
# ACTION_MEANING = {
#     None: "NONE",
#     0: "NOOP",
#     1: "FIRE",
#     2: "UP",
#     3: "RIGHT",
#     4: "LEFT",
#     5: "DOWN",
#     6: "UPRIGHT",
#     7: "UPLEFT",
#     8: "DOWNRIGHT",
#     9: "DOWNLEFT",
#     10: "UPFIRE",
#     11: "RIGHTFIRE",
#     12: "LEFTFIRE",
#     13: "DOWNFIRE",
#     14: "UPRIGHTFIRE",
#     15: "UPLEFTFIRE",
#     16: "DOWNRIGHTFIRE",
#     17: "DOWNLEFTFIRE",
# }
# 
# ACTION_MEANING_TO_ACTION = {v: k for k, v in ACTION_MEANING.items()}
# 
# SAFE_ACTION_MAPPINGS = {"SpaceInvaders": {0: 0, 1: 0, 2: 2, 3: 3, 4: 2, 5: 3}}
# 
# def identity(*args):
#     if len(args) == 1:
#         return args[0]
#     return args
# 
# def shuffle(lst):
#     random.shuffle(lst)
#     return lst


import argparse
import datetime
import gzip
import itertools
import logging
import os
import os.path
import pickle
import random
import time
import numpy as np
import cv2
import humanrl.frame as frame_module
from multiprocessing.connection import Listener
from subprocess import call
from PIL import Image
from humanrl.utils import (ACTION_MEANING, ACTION_MEANING_TO_ACTION,
                           SAFE_ACTION_MAPPINGS, identity, shuffle)
        cv2.line(img, (0, 0), (int(500 * image_scale), 0), (255, 0, 0), 20)

    text_top = int(.86 * img.shape[0])
    for text in extra_text:
        text_top = add_text(img, text, text_top, image_scale=image_scale)
    # text_top = add_text(img, "Mean: {}".format(np.mean(frame.image)), text_top, image_scale=image_scale)
    if "frame/action/proposed_action" in frame.info:
        # print("Proposed Action: {}".format(ACTION_MEANING[action_set[frame.action]]))
        text_top = add_text(
            img,
            "Proposed Action: {}".format(
                ACTION_MEANING[action_set[frame.get_proposed_action()]]),
            text_top,
            image_scale=image_scale)
    if "frame/action/real_action" in frame.info and frame.get_real_action() is not None:
        # print("Real Action: {}".format(ACTION_MEANING[action_set[frame.get_real_action()]]))
        text_top = add_text(
            img,
            "Real Action: {}".format(
                ACTION_MEANING[action_set[frame.get_real_action()]]),
            text_top,
            image_scale=image_scale)
    if frame.prediction is not None:
        text_top = add_text(
            img, "Prediction: {:.2e}".format(frame.prediction), text_top, image_scale=image_scale)
    # Display the previous two actions
    for idx, a in enumerate(reversed(prev_actions)):
        if a is not None:
            text_top = add_text(
                img,

# Path: humanrl/utils.py
# ACTION_MEANING = {
#     None: "NONE",
#     0: "NOOP",
#     1: "FIRE",
#     2: "UP",
#     3: "RIGHT",
#     4: "LEFT",
#     5: "DOWN",
#     6: "UPRIGHT",
#     7: "UPLEFT",
#     8: "DOWNRIGHT",
#     9: "DOWNLEFT",
#     10: "UPFIRE",
#     11: "RIGHTFIRE",
#     12: "LEFTFIRE",
#     13: "DOWNFIRE",
#     14: "UPRIGHTFIRE",
#     15: "UPLEFTFIRE",
#     16: "DOWNRIGHTFIRE",
#     17: "DOWNLEFTFIRE",
# }
# 
# ACTION_MEANING_TO_ACTION = {v: k for k, v in ACTION_MEANING.items()}
# 
# SAFE_ACTION_MAPPINGS = {"SpaceInvaders": {0: 0, 1: 0, 2: 2, 3: 3, 4: 2, 5: 3}}
# 
# def identity(*args):
#     if len(args) == 1:
#         return args[0]
#     return args
# 
# def shuffle(lst):
#     random.shuffle(lst)
#     return lst


# Path: scripts/human_feedback.py
import argparse
import datetime
import gzip
import itertools
import logging
import os
import os.path
import pickle
import random
import time
import numpy as np
import cv2
import humanrl.frame as frame_module
from multiprocessing.connection import Listener
from subprocess import call
from PIL import Image
from humanrl.utils import (ACTION_MEANING, ACTION_MEANING_TO_ACTION,
                           SAFE_ACTION_MAPPINGS, identity, shuffle)

        cv2.line(img, (0, 0), (int(500 * image_scale), 0), (255, 0, 0), 20)

    text_top = int(.86 * img.shape[0])
    for text in extra_text:
        text_top = add_text(img, text, text_top, image_scale=image_scale)
    # text_top = add_text(img, "Mean: {}".format(np.mean(frame.image)), text_top, image_scale=image_scale)
    if "frame/action/proposed_action" in frame.info:
        # print("Proposed Action: {}".format(ACTION_MEANING[action_set[frame.action]]))
        text_top = add_text(
            img,
            "Proposed Action: {}".format(
                ACTION_MEANING[action_set[frame.get_proposed_action()]]),
            text_top,
            image_scale=image_scale)
    if "frame/action/real_action" in frame.info and frame.get_real_action() is not None:
        # print("Real Action: {}".format(ACTION_MEANING[action_set[frame.get_real_action()]]))
        text_top = add_text(
            img,
            "Real Action: {}".format(
                ACTION_MEANING[action_set[frame.get_real_action()]]),
            text_top,
            image_scale=image_scale)
    if frame.prediction is not None:
        text_top = add_text(
            img, "Prediction: {:.2e}".format(frame.prediction), text_top, image_scale=image_scale)
    # Display the previous two actions
    for idx, a in enumerate(reversed(prev_actions)):
        if a is not None:
            text_top = add_text(
                img,

                "Previous Action {}: {}".format(idx, ACTION_MEANING[action_set[a]]),