import streamlit as st # from transformers import (T5ForConditionalGeneration, AutoTokenizer, pipeline) from transformers import pipeline # import torch st.set_page_config(layout="wide", page_title="تبدیل متون محاوره‌ای به فارسی") model_path = 'erfan226/persian-t5-formality-transfer' model = T5ForConditionalGeneration.from_pretrained(model_path) tokenizer = AutoTokenizer.from_pretrained(model_path) pipe = pipeline(task='text2text-generation', model=model, tokenizer=tokenizer) def paraphrase(text): for j in range(3): out = pipe(text, encoder_no_repeat_ngram_size=4, do_sample=True, num_beams=5, max_length=128)[0]['generated_text'] print("Paraphrase:", out) link = st.text_area('Paste your link here...', "من با دوستام میرم بازی", height=50) min_length = st.sidebar.slider('حداقل طول جمله', min_value=10, max_value=100, value=50, step=10) max_length = st.sidebar.slider('حداکثر طول طول جمله', min_value=30, max_value=700, value=100, step=10) num_beams = st.sidebar.slider('طول Beam', min_value=1, max_value=10, value=5, step=1) out = paraphrase(link) st.write(out) # x = st.slider('Select a value') # st.write(x, 'squared is', x * x)