samanjoy2 commited on
Commit
3146a45
1 Parent(s): 7319a13

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +22 -0
  2. ii.ipynb +81 -0
  3. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ import torch
4
+
5
+ # Load the text-to-text generation pipeline
6
+ pipe = pipeline("text2text-generation", model="samanjoy2/bnpunct_banglat5_seq2seq_finetuned", device='cpu')
7
+
8
+ st.title("Bangla Punctutation Restoration")
9
+
10
+ # User input for text generation
11
+ input_text = st.text_area("Enter Bangla text for restoration:", max_chars=100)
12
+
13
+ if st.button("Restore Punctuations"):
14
+ if input_text:
15
+ # Generate text using the pipeline
16
+ generated_text = pipe(input_text, max_length=512, batch_size=1)[0]['generated_text']
17
+
18
+ # Display the generated text
19
+ st.subheader("Generated Text:")
20
+ st.write(generated_text)
21
+ else:
22
+ st.warning("Please enter text for generation.")
ii.ipynb ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 7,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "from transformers import pipeline"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": 8,
15
+ "metadata": {},
16
+ "outputs": [
17
+ {
18
+ "name": "stderr",
19
+ "output_type": "stream",
20
+ "text": [
21
+ "Downloading config.json: 100%|██████████| 827/827 [00:00<00:00, 276kB/s]\n",
22
+ "Downloading model.safetensors: 23%|██▎ | 231M/990M [01:04<03:30, 3.61MB/s] "
23
+ ]
24
+ }
25
+ ],
26
+ "source": [
27
+ "pipe = pipeline(\"text2text-generation\", model=\"samanjoy2/bnpunct_banglat5_seq2seq_finetuned\", device='cpu')"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "code",
32
+ "execution_count": 6,
33
+ "metadata": {},
34
+ "outputs": [
35
+ {
36
+ "data": {
37
+ "text/plain": [
38
+ "'বুঝলাম নাহ। তুমার সম্যা কি?'"
39
+ ]
40
+ },
41
+ "execution_count": 6,
42
+ "metadata": {},
43
+ "output_type": "execute_result"
44
+ }
45
+ ],
46
+ "source": [
47
+ "texts = \"বুঝলাম নাহ তুমার সম্যা কি\"\n",
48
+ "ipas = pipe(texts, max_length=512, batch_size=1)[0]['generated_text']\n",
49
+ "ipas"
50
+ ]
51
+ },
52
+ {
53
+ "cell_type": "code",
54
+ "execution_count": null,
55
+ "metadata": {},
56
+ "outputs": [],
57
+ "source": []
58
+ }
59
+ ],
60
+ "metadata": {
61
+ "kernelspec": {
62
+ "display_name": "gputorch_1",
63
+ "language": "python",
64
+ "name": "python3"
65
+ },
66
+ "language_info": {
67
+ "codemirror_mode": {
68
+ "name": "ipython",
69
+ "version": 3
70
+ },
71
+ "file_extension": ".py",
72
+ "mimetype": "text/x-python",
73
+ "name": "python",
74
+ "nbconvert_exporter": "python",
75
+ "pygments_lexer": "ipython3",
76
+ "version": "3.9.18"
77
+ }
78
+ },
79
+ "nbformat": 4,
80
+ "nbformat_minor": 2
81
+ }
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ transformers
3
+ torch