File size: 1,035 Bytes
43355d2
 
 
cd38e87
43355d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82b3972
 
43355d2
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import gradio as gr
import shutil
import main_oss

def predict_from_pdf(pdf_file):
    upload_dir = "./catalogue/"
    os.makedirs(upload_dir, exist_ok=True)
    
    try:
        dest_path = os.path.join(upload_dir, pdf_file.name)
        with open(dest_path, "wb") as f:
            f.write(pdf_file.read())
        
        df, response = main_oss.process_pdf_catalog(dest_path)
        return df, response
    except Exception as e:
        return None, f"Error: {str(e)}"

pdf_examples = [
    ["catalogue/flexpocket.pdf"],
    ["catalogue/ASICS_Catalog.pdf"],
]

demo = gr.Interface(
    fn=predict_from_pdf,
    inputs=gr.File(label="Upload PDF Catalog"),
    outputs=["json", "text"],
    examples=pdf_examples,
    title="Open Source PDF Catalog Parser",
    description="Efficient PDF catalog processing using MinerU and OpenLLM",
    article="Uses MinerU for layout analysis and DeepSeek-1.3B for structured extraction"
)

if __name__ == "__main__":
    demo.queue().launch(server_name="0.0.0.0", server_port=7860)