import pandas as pd import json import gradio as gr def create_jsonl(csv_file): df = pd.read_csv(csv_file) column_list = df.columns output = 'metadata.jsonl' total_data = [] for index, row in df.iterrows(): data = {} for column in column_list: if column == 'file_name': file_name = row[column] data[column] = row[column] row_data = {"file_name": file_name, "ground_truth": json.dumps(data)} total_data.append(row_data) with open(output, 'a', encoding='utf-8') as f: for row_data in total_data: f.write(json.dumps(row_data) + '\n') return output demo = gr.Interface(fn=create_jsonl,inputs=gr.File(),outputs=gr.File(), title=f"jsonl converter",) demo.launch()