sakeef commited on
Commit
4286de4
·
verified ·
1 Parent(s): d56ecdf

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from huggingface_hub import hf_hub_download, snapshot_download
4
+
5
+ from pipeline import DialogPipeline
6
+ from demo_app import create_demo
7
+
8
+ MODEL_REPO = "sakeef/bangla-dialog-models"
9
+
10
+ # Download NLU checkpoint (single .pt file) and the T5 model directory from the
11
+ # Hub on first startup. After that they are cached and reused across restarts.
12
+ nlu_ckpt = hf_hub_download(repo_id=MODEL_REPO, filename="nlu/best_model.pt")
13
+ nlu_dir = os.path.dirname(nlu_ckpt)
14
+
15
+ nlg_dir = snapshot_download(repo_id=MODEL_REPO, allow_patterns="nlg/*")
16
+ nlg_dir = os.path.join(nlg_dir, "nlg")
17
+
18
+ pipeline = DialogPipeline(
19
+ nlu_model_path=nlu_dir,
20
+ gen_model_path=nlg_dir,
21
+ labels_dir="./labels",
22
+ bert_model="sagorsarker/bangla-bert-base",
23
+ )
24
+
25
+ demo = create_demo(pipeline)
26
+ demo.launch()