sahibnanda commited on
Commit
d9579cb
1 Parent(s): 48ec1cf
TextSummarizationModel/assets/tokenizer/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
TextSummarizationModel/assets/tokenizer/vocabulary.json ADDED
The diff for this file is too large to render. See raw diff
 
TextSummarizationModel/config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"module": "keras_nlp.src.models.bart.bart_backbone", "class_name": "BartBackbone", "config": {"name": "bart_backbone", "trainable": true, "vocabulary_size": 50265, "num_layers": 6, "num_heads": 12, "hidden_dim": 768, "intermediate_dim": 3072, "dropout": 0.1, "max_sequence_length": 1024}, "registered_name": "keras_nlp>BartBackbone", "build_config": {"input_shape": {"encoder_token_ids": [null, null], "encoder_padding_mask": [null, null], "decoder_token_ids": [null, null], "decoder_padding_mask": [null, null]}}, "weights": "model.weights.h5"}
TextSummarizationModel/metadata.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "keras_version": "3.0.1",
3
+ "keras_nlp_version": "0.7.0",
4
+ "parameter_count": 139417344,
5
+ "date_saved": "2023-12-27@02:00:52"
6
+ }
TextSummarizationModel/model.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab4030711d47cbed4fd3f8fe913977aef6e4932f0f05d5bba91e2de066e08f1f
3
+ size 558205584
TextSummarizationModel/new_model.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2b8c98bd0559fd313c22c7a16c9109053fb1aacea38c0b514486fb441ad0b0d
3
+ size 1673753584
TextSummarizationModel/tokenizer.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "module": "keras_nlp.src.models.bart.bart_tokenizer",
3
+ "class_name": "BartTokenizer",
4
+ "config": {
5
+ "name": "bart_tokenizer",
6
+ "trainable": true,
7
+ "dtype": "int32",
8
+ "sequence_length": null,
9
+ "add_prefix_space": false
10
+ },
11
+ "registered_name": "keras_nlp>BartTokenizer",
12
+ "assets": [
13
+ "assets/tokenizer/merges.txt",
14
+ "assets/tokenizer/vocabulary.json"
15
+ ],
16
+ "weights": null
17
+ }
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from textSFunctionality import generateText
3
+
4
+ # Set the page configuration and theme once at the top
5
+ st.set_page_config(page_title="Text Summarization", page_icon="⭐")
6
+
7
+ st.write(
8
+ """
9
+ <style>
10
+ .reportview-container {
11
+ background-color: #f8f9fa;
12
+ }
13
+ .sidebar .sidebar-content {
14
+ background-color: #f0f2f6;
15
+ }
16
+ h1 {
17
+ color: #0cdec0;
18
+ }
19
+ .stButton > button {
20
+ background-color: #38d6c0; /* Lighter teal shade */
21
+ color: black;
22
+ font-weight: bold;
23
+ transition: background-color 0.3s, color 0.3s;
24
+ }
25
+ .stButton > button:hover {
26
+ background-color: #01947f; /* Even lighter teal for hover */
27
+ color: white; /* Change text color on hover */
28
+ }
29
+ .stTextArea > textarea {
30
+ background-color: #ffffff;
31
+ color: #333;
32
+ }
33
+ </style>
34
+ """, unsafe_allow_html=True
35
+ )
36
+
37
+ def main():
38
+ st.title('Text Summarization')
39
+
40
+ # Text area for user input
41
+ user_input = st.text_area("#### **Enter Text To Summarize**:", height=300)
42
+
43
+ # Button to trigger summarization
44
+ if st.button("Summarize"):
45
+ if user_input:
46
+ summary = generateText(user_input)
47
+ st.write("#### **Summarized Text**:")
48
+ st.write(summary)
49
+ else:
50
+ st.write("Please Enter Some Text To Summarize.")
51
+
52
+ if __name__ == '__main__':
53
+ main()
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ streamlit==1.33.0
2
+ numpy==1.26.4
3
+ keras==2.15.0
4
+ tensorflow==2.15.0
5
+ tensorflow-text==2.15.0
6
+ keras-nlp==0.9.3
textSFunctionality.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ import os
3
+ import tensorflow as tf
4
+ import keras
5
+ import keras_nlp
6
+
7
+ MAX_ENCODER_SEQUENCE_LENGTH = 512
8
+ MAX_DECODER_SEQUENCE_LENGTH = 128
9
+
10
+ MODEL_PATH = r"TextSummarizationModel"
11
+ WEIGHT_PATH = r"new_model.weights.h5"
12
+ WEIGHT_PATH = os.path.join(MODEL_PATH, WEIGHT_PATH)
13
+
14
+ def cleanText(text):
15
+ text = str(text)
16
+ text = re.sub(r'[^a-zA-Z0-9\s]', '', text)
17
+ text = text.lower()
18
+ return text
19
+
20
+ preprocessor = keras_nlp.models.BartSeq2SeqLMPreprocessor.from_preset(MODEL_PATH, encoder_sequence_length=MAX_ENCODER_SEQUENCE_LENGTH,decoder_sequence_length=MAX_DECODER_SEQUENCE_LENGTH,)
21
+ model = keras_nlp.models.BartSeq2SeqLM.from_preset(MODEL_PATH, preprocessor=preprocessor)
22
+ model.load_weights(WEIGHT_PATH)
23
+
24
+ def generateText(input_text, model=model, max_length=200):
25
+ input_text = cleanText(input_text)
26
+ output = model.generate(input_text, max_length=max_length)
27
+ return output