import gradio as gr import pydicom import pandas as pd from pathlib import Path from io import BytesIO def convert_dicom_to_tsv(dicom_file): dicom_file = pathlib.Path(__loader__).parent / "." # Read the DICOM file pydicom = dicom_data.dcmread(dicom_file) # Extract data elements from the DICOM file data_elements = {de.tag: (de.description(), de.value) for de in dicom_data} # Convert to DataFrame df = pd.DataFrame(list(data_elements.values()), columns=["Description", "Value"]) # Convert DataFrame to TSV format and store in a buffer buffer = BytesIO() df.to_csv(buffer, sep='\t', index=False, encoding='utf-8') buffer.seek(0) return buffer # Create a Gradio interface app = gr.Interface( dicom_file = gr.File(type="df") b1 = gr.Button("Recognize Speech") b1.click(fn=convert_dicom_to_tsv, inputs=pydicom, outputs=file) ) if __name__ == "__main__": app.launch(share=True)