saiful9379 commited on
Commit
8fdaf65
1 Parent(s): 0eb914d

add streamlit

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  import torch
3
  import argparse
 
4
  import sentencepiece as spm
5
  from utils import utils_cls
6
  from model import BanglaTransformer
@@ -83,7 +84,7 @@ class Bn2EnTranslation:
83
  "bn_tokenizer" : bn_tokenizer,
84
  "bn_vocab" : bn_vocab,
85
  "en_vocab" : en_vocab,
86
- "model" : model
87
  }
88
  return models
89
  def translate(self, text, models):
@@ -105,14 +106,14 @@ class Bn2EnTranslation:
105
 
106
 
107
 
108
- if __name__ == "__main__":
109
- print(torch.cuda.get_device_name(0))
110
- text = "এই উপজেলায় ১টি সরকারি কলেজ রয়েছে"
111
-
112
- obj = Bn2EnTranslation()
113
- models = obj.get_bntoen_model()
 
114
  pre = obj.translate(text, models)
115
- print("="*20)
116
- print(f"input : {text}")
117
- print(f"prediction: {pre}")
118
 
 
1
  import os
2
  import torch
3
  import argparse
4
+ import streamlit as st
5
  import sentencepiece as spm
6
  from utils import utils_cls
7
  from model import BanglaTransformer
 
84
  "bn_tokenizer" : bn_tokenizer,
85
  "bn_vocab" : bn_vocab,
86
  "en_vocab" : en_vocab,
87
+ "model": model
88
  }
89
  return models
90
  def translate(self, text, models):
 
106
 
107
 
108
 
109
+ # if __name__ == "__main__":
110
+ # print(torch.cuda.get_device_name(0))
111
+ text = "এই উপজেলায় ১টি সরকারি কলেজ রয়েছে"
112
+ obj = Bn2EnTranslation()
113
+ models = obj.get_bntoen_model()
114
+ text = st.text_area("Enter some text:এই উপজেলায় ১টি সরকারি কলেজ রয়েছে")
115
+ if text:
116
  pre = obj.translate(text, models)
117
+ print(f"Input : {text}")
118
+ print(f"Prediction : {pre}")
 
119