Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,22 +11,17 @@ os.environ['KERAS_BACKEND'] = 'tensorflow'
|
|
| 11 |
os.environ['HF_USERNAME'] = 'Grey01'
|
| 12 |
|
| 13 |
|
| 14 |
-
hf_username = huggingface_hub.whoami()['name']
|
| 15 |
-
hf_url = f'hf://{hf_username}/bart_billsum'
|
| 16 |
|
| 17 |
-
|
| 18 |
-
@st.cache_resource
|
| 19 |
-
def load_model_and_preprocessor():
|
| 20 |
-
bart_billsum = keras_nlp.models.BartSeq2SeqLM.from_preset(f'hf://{hf_username}/bart_billsum')
|
| 21 |
-
|
| 22 |
-
# Load the default BART preprocessor (assuming you saved its configuration)
|
| 23 |
-
#preprocessor = keras_nlp.models.BartSeq2SeqLMPreprocessor.from_preset('bart_base_en', encoder_sequence_length=512,
|
| 24 |
-
|
| 25 |
-
#decoder_sequence_length=128,)
|
| 26 |
-
|
| 27 |
-
return model
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
st.title("SummarizeIt")
|
| 32 |
|
|
@@ -63,7 +58,7 @@ def generate_text(model, input_texts, max_length=200, print_time_taken=False):
|
|
| 63 |
return summary
|
| 64 |
|
| 65 |
generated_summaries = generate_text(
|
| 66 |
-
|
| 67 |
text, # Pass the list of documents directly
|
| 68 |
)
|
| 69 |
st.subheader("Generated Summary:")
|
|
|
|
| 11 |
os.environ['HF_USERNAME'] = 'Grey01'
|
| 12 |
|
| 13 |
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
from huggingface_hub import whoami
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
# Get the username
|
| 18 |
+
hf_username = whoami()['name']
|
| 19 |
+
|
| 20 |
+
# Define the model repository
|
| 21 |
+
model_repo = f'{hf_username}/bart_billsum'
|
| 22 |
+
|
| 23 |
+
# Load the Keras NLP model
|
| 24 |
+
bart_billsum = keras_nlp.models.BartSeq2SeqLM.from_preset(model_repo)
|
| 25 |
|
| 26 |
st.title("SummarizeIt")
|
| 27 |
|
|
|
|
| 58 |
return summary
|
| 59 |
|
| 60 |
generated_summaries = generate_text(
|
| 61 |
+
bart_billsum,
|
| 62 |
text, # Pass the list of documents directly
|
| 63 |
)
|
| 64 |
st.subheader("Generated Summary:")
|