Spaces:
Sleeping
Sleeping
Download app.py from bisalsaha/ucb-doc-classifier: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/spaces/bisalsaha/ucb-doc-classifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/bisalsaha/ucb-doc-classifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/bisalsaha/ucb-doc-classifier/resolve/main/app.py
1.5 kB
| 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) | |
| 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() |