Spaces:
Sleeping
Sleeping
import torch | |
from transformers import AutoModel | |
model_name = "Richieburundi/Ariginalmodel" | |
model = AutoModel.from_pretrained(model_name, config=None, tokenizer=None) | |
import streamlit as st | |
def generate_text(input_text, max_length=50): | |
inputs = tokenizer(input_text, return_tensors="pt") | |
outputs = model.generate(**inputs, max_length=max_length, num_return_sequences=1, do_sample=True, top_k=50, top_p=0.95, num_beams=5) | |
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
return generated_text | |
st.title("AI Text Generation") | |
st.write("Enter some text, and the AI will generate a response.") | |
input_text = st.text_area("Input Text", height=200) | |
if st.button("Generate Text"): | |
try: | |
generated_text = generate_text(input_text) | |
st.write("Generated Text:") | |
st.write(generated_text) | |
except Exception as e: | |
st.error(f"Error generating text: {e}") |