import gradio as gr from convert import convert_pdf_to_pgn import gradio_pdf as gr_pdf # Create the Gradio interface file_input = gr.File(label="Upload PDF") game_start_page_no = gr.Number(label="Game Start Page No.") game_end_page_no = gr.Number(label="Game End Page No.") # add gradio examples examples = [["book.pdf", 37, 38], ["book.pdf", 18, 19], ["book.pdf", 22, 24]] iface = gr.Interface( fn=convert_pdf_to_pgn, inputs=[file_input, game_start_page_no, game_end_page_no], outputs=[gr.File(label="Download Processed PGN File"), gr.HTML(label="Lichess Link"), gr_pdf.PDF(label="Selected Pages PDF")], title="♟️LitChessAI🔥 - Chess Book PDF to PGN Converter", description="Upload a PDF file containing a game from a chess book, specify the pages containing the game (for accuracy use the tool on a single game at a time), and download the processed PGN file for the game. We also share a Lichess link that you can open to open the game in an interactive experience.", examples=examples, cache_examples=True ) # Launch the interface iface.launch()