import gradio as gr import torch from transformers import AutoModelForObjectDetection, TableTransformerForObjectDetection from PIL import Image from pdf_processing import process_pdf # Load model and process the PDF def process_pdf_file(pdf_file): pdf_path = pdf_file.name # Get the path to the uploaded PDF output_folder = "./output" # Define the output folder # Call the existing function to process the PDF process_pdf(pdf_path, output_folder) return f"Processing completed. Output saved to {output_folder}" # Create Gradio interface def create_gradio_interface(): input_pdf = gr.File(label="Upload PDF", type="filepath") # Fixed argument here output_text = gr.Textbox(label="Processing Status", interactive=False) # Define the interface interface = gr.Interface( fn=process_pdf_file, inputs=input_pdf, outputs=output_text, live=True ) return interface # Start the application if __name__ == "__main__": gradio_interface = create_gradio_interface() gradio_interface.launch()