Najish Mahmud commited on
Commit
7900aac
1 Parent(s): 96f24e9

first launch

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +37 -0
  3. requirements.txt +104 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .venv
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import transformers
2
+ import sentencepiece
3
+ import torch
4
+ import gradio as gr
5
+
6
+ # from indicnlp.normalize.indic_normalize import IndicNormalizerFactory
7
+ from transformers import MarianMTModel, AutoTokenizer, T5ForConditionalGeneration
8
+ from deep_translator import GoogleTranslator
9
+
10
+ def summarize(message):
11
+ tokenizer_bn_en = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-bn-en")
12
+ model_bn_en = MarianMTModel.from_pretrained("Helsinki-NLP/opus-mt-bn-en")
13
+ tokenizer = AutoTokenizer.from_pretrained('t5-base')
14
+ model = T5ForConditionalGeneration.from_pretrained('t5-base')
15
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
16
+ with torch.no_grad():
17
+ # tokenize the input text
18
+ input_ids = tokenizer_bn_en.encode(message, return_tensors='pt')
19
+
20
+ # generate the output translation
21
+ output_ids = model_bn_en.generate(input_ids)
22
+ output_text1 = tokenizer_bn_en.decode(output_ids[0], skip_special_tokens=True)
23
+
24
+ #input for the summarization model
25
+ input_text2 = output_text1
26
+
27
+ # tokenize the input text and generate the summary in english
28
+ input_ids = tokenizer.encode(input_text2, return_tensors='pt')
29
+ summary_ids = model.generate(input_ids, max_length=50, num_beams=30, early_stopping=True)
30
+ summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
31
+ summarized = GoogleTranslator(source='en', target='bn').translate(summary)
32
+ return summarized
33
+
34
+ # summarize("যুক্তরাষ্ট্রের নিউজার্সি অঙ্গরাজ্যের হোপওয়েল শহর এলাকার একটি বাড়ির ছাদে একটি ধাতব বস্তু আছড়ে পড়েছে। ধাতব বস্তুটি উল্কাপিণ্ড হতে পারে বলে ধারণা করা হচ্ছে। এ ঘটনায় কেউ হতাহত হয়নি বলে জানিয়েছে পুলিশ। স্থানীয় সময় গত সোমবার বেলা একটার কিছু সময় পর ওল্ড ওয়াশিংটন ক্রসিং পেনিংটন রোড এলাকায় অবস্থিত একটি বাড়িতে এ ঘটনা ঘটে। পুলিশের ভাষ্য, বস্তুটি আয়তাকার। দেখতে ধাতব পদার্থের মতো। বাড়ির বাসিন্দারা জানান, ঘটনার পর তাঁরা সংশ্লিষ্ট সহায়তা কর্তৃপক্ষকে ফোন করেন। আকাশ থেকে কোনো বস্তু যে বাড়ির ছাদে এসে পড়েছে, এ কথা কর্তৃপক্ষকে বোঝাতে তাঁদের বেগ পেতে হয়েছে।")
35
+
36
+ iface = gr.Interface(fn=summarize, inputs="text", outputs="text")
37
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ appdirs==1.4.4
2
+ async-timeout==4.0.2
3
+ attrs==22.2.0
4
+ autocommand==2.2.2
5
+ beautifulsoup4==4.12.2
6
+ Brlapi==0.8.4
7
+ btrfsutil==6.3
8
+ build==0.10.0
9
+ cached-property==1.5.2
10
+ cffi==1.15.1
11
+ chardet==5.1.0
12
+ cmake==3.26.3
13
+ cryptography==40.0.2
14
+ cssselect==1.2.0
15
+ Cython==0.29.34
16
+ deep-translator==1.10.1
17
+ fastjsonschema==2.16.3
18
+ filelock==3.12.0
19
+ flit_core==3.8.0
20
+ fsspec==2023.5.0
21
+ greenlet==2.0.2
22
+ grpcio==1.53.0
23
+ huggingface-hub==0.14.1
24
+ idna==3.4
25
+ ifaddr==0.2.0
26
+ inflect==6.0.4
27
+ installer==0.7.0
28
+ jaraco.context==4.3.0
29
+ jaraco.functools==3.6.0
30
+ jaraco.text==3.11.1
31
+ Jinja2==3.1.2
32
+ lensfun==0.3.3
33
+ Levenshtein==0.21.0
34
+ libfdt==1.7.0
35
+ libtorrent==2.0.8
36
+ lit==16.0.3
37
+ louis==3.25.0
38
+ lxml==4.9.2
39
+ MarkupSafe==2.1.2
40
+ meson==1.1.0
41
+ more-itertools==9.1.0
42
+ mpmath==1.3.0
43
+ msgpack==1.0.5
44
+ netifaces==0.11.0
45
+ netsnmp-python==1.0a1
46
+ networkx==3.1
47
+ nspektr==0.4.0
48
+ numpy==1.24.3
49
+ nvidia-cublas-cu11==11.10.3.66
50
+ nvidia-cuda-cupti-cu11==11.7.101
51
+ nvidia-cuda-nvrtc-cu11==11.7.99
52
+ nvidia-cuda-runtime-cu11==11.7.99
53
+ nvidia-cudnn-cu11==8.5.0.96
54
+ nvidia-cufft-cu11==10.9.0.58
55
+ nvidia-curand-cu11==10.2.10.91
56
+ nvidia-cusolver-cu11==11.4.0.1
57
+ nvidia-cusparse-cu11==11.7.4.91
58
+ nvidia-nccl-cu11==2.14.3
59
+ nvidia-nvtx-cu11==11.7.91
60
+ ordered-set==4.1.0
61
+ packaging==23.0
62
+ platformdirs==3.5.0
63
+ ply==3.11
64
+ protobuf==4.21.12
65
+ psutil==5.9.5
66
+ pwquality==1.4.5
67
+ pycairo==1.23.0
68
+ pycparser==2.21
69
+ pydantic==1.10.7
70
+ pyenchant==3.2.2
71
+ PyGObject==3.44.1
72
+ PyNaCl==1.4.0
73
+ pynvim==0.4.3
74
+ pypandoc==1.11
75
+ pyparsing==3.0.9
76
+ pyproject_hooks==1.0.0
77
+ pywayland==0.4.15
78
+ pywlroots==0.15.24
79
+ pyxdg==0.28
80
+ PyYAML==6.0
81
+ rapidfuzz==3.0.0
82
+ regex==2023.5.5
83
+ requests==2.28.2
84
+ scour==0.38.2
85
+ sentencepiece==0.1.99
86
+ setproctitle==1.3.2
87
+ shiboken2==5.15.9
88
+ six==1.16.0
89
+ soupsieve==2.4.1
90
+ sympy==1.12
91
+ tokenizers==0.13.3
92
+ tomli==2.0.1
93
+ tomli_w==1.0.0
94
+ torch==2.0.1
95
+ tqdm==4.65.0
96
+ transformers==4.29.1
97
+ triton==2.0.0
98
+ trove-classifiers==2023.4.29
99
+ typing_extensions==4.5.0
100
+ ufw==0.36.1
101
+ urllib3==1.26.15
102
+ validate-pyproject==0.12.2.post1.dev0+g2940279.d20230508
103
+ xkbcommon==0.8
104
+ zeroconf==0.39.4