import streamlit as st from transformers import BartForConditionalGeneration, BartTokenizer # Load the model and tokenizer from the local directory model_path = "disilbart-med-summary" # Replace with the actual path tokenizer = BartTokenizer.from_pretrained(model_path) model = BartForConditionalGeneration.from_pretrained(model_path) # Function to generate summary based on input def generate_summary(input_text): # Tokenize the input text input_ids = tokenizer.encode(input_text, return_tensors="pt") # Generate summary summary_ids = model.generate(input_ids, max_length=4000, num_beams=4, no_repeat_ngram_size=2) # Decode the summary summary_text = tokenizer.decode(summary_ids[0], skip_special_tokens=True) return summary_text # Streamlit app def main(): # Apply custom styling for the title st.markdown("