File size: 1,504 Bytes
9b11bd0
cc1caa1
 
 
9b11bd0
5299e8e
 
cc1caa1
9b11bd0
cc1caa1
 
65fa959
cc1caa1
65fa959
 
5299e8e
65fa959
 
cc1caa1
 
65fa959
 
 
cc1caa1
 
 
 
65fa959
 
 
 
 
 
 
 
cc1caa1
 
5299e8e
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
37
38
import spaces
import gradio as gr
from transformers import pipeline

# আপনার ফাইন-টিউন করা 100% একুরেট মডেল
MODEL_ID = "bisalsaha/bart-trade-doc-classifier"
classifier = pipeline("text-classification", model=MODEL_ID)

@spaces.GPU
def classify_document(text):
    if not text or not text.strip():
        return {"error": "অনুগ্রহ করে ডকুমেন্টের টেক্সট পেস্ট করুন।"}
    
    # ৬টি মূল বাংলাদেশ ব্যাংক ক্যাটাগরিতে প্রেডিকশন
    results = classifier(text[:1024], top_k=None)
    
    all_scores = {r["label"]: f"{round(r['score'] * 100, 2)}%" for r in results}
    top_result = results[0]
    
    return {
        "Document Category": top_result["label"],
        "Confidence": f"{round(top_result['score'] * 100, 2)}%",
        "All Category Confidences": all_scores
    }

demo = gr.Interface(
    fn=classify_document,
    inputs=gr.Textbox(
        label="Document Text (from PDF / OCR)", 
        lines=12, 
        placeholder="Paste document text from Bill of Entry, LCA, LC, IMP, EXP, or PRC here..."
    ),
    outputs=gr.JSON(label="Bangladesh Bank IDP Classification Result"),
    title="🏦 UCB - Bangladesh Bank Trade Document Classifier",
    description="Fine-tuned BART Model for 6 Core Bangladesh Bank Regulatory Categories (LCA, LC, Bill of Entry, IMP, EXP, PRC)."
)

demo.launch()