opt-test / app.py
varun500's picture
Update app.py
300b5da
raw
history blame contribute delete
680 Bytes
import streamlit as st
from transformers import AutoTokenizer, AutoModelForCausalLM
# Load the pre-trained model and tokenizer
model_name = "facebook/opt-125m"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
# Create the Streamlit app
st.title("Text Summarization App")
text_input = st.text_area("Enter text to summarize")
if st.button("Summarize"):
input_ids = tokenizer.encode(text_input, return_tensors="pt")
summary_ids = model.generate(input_ids, max_length=100, min_length=20, do_sample=False)
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
st.write("Summary:", summary)