def process_raw_data()

in src/open-r1-multimodal/local_scripts/prepare_hf_data.py [0:0]


def process_raw_data(raw_data):
    # Parse the raw data if it's a string
    if isinstance(raw_data, str):
        data = json.loads(raw_data)
    else:
        data = raw_data

    # Extract problem and solution
    try:
        problem, solution = extract_problem_solution(data["gpt4o_response"])
        image = load_image_from_path(data["image_path"])

        return {
            "image": image,
            "problem": problem,
            "solution": solution,
            "original_question": data["question"],
            "original_answer": data["answer"],
        }
    except Exception as e:
        print(f"Error processing data {data}: {str(e)}")
        return {
            "image": None,
            "problem": None,
            "solution": None,
            "original_question": None,
            "original_answer": None,
        }