Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	| import streamlit as st | |
| from transformers import AutoTokenizer,AutoModelForSeq2SeqLM | |
| import random | |
| def load_model(input_complex_sentence,model): | |
| base_path = "flax-community/" | |
| model_path = base_path + model | |
| tokenizer = AutoTokenizer.from_pretrained(model_path) | |
| model = AutoModelForSeq2SeqLM.from_pretrained(model_path) | |
| tokenized_sentence = tokenizer(input_complex_sentence,return_tensors="pt") | |
| result = model.generate(tokenized_sentence['input_ids'],attention_mask = tokenized_sentence['attention_mask'],max_length=256,num_beams=5) | |
| generated_sentence = tokenizer.decode(result[0],skip_special_tokens=True) | |
| return generated_sentence | |
| def load_page(): | |
| st.sidebar.title("🧠Sentence Simplifier") | |
| st.title("Sentence Split in English using T5 Variants") | |
| st.write("Sentence Split is the task of **dividing a long Complex Sentence into Simple Sentences**") | |
| st.sidebar.write("## UI Options") | |
| model = st.sidebar.selectbox( | |
| "Please Choose the Model", | |
| ("t5-base-wikisplit","t5-v1_1-base-wikisplit", "byt5-base-wikisplit","t5-large-wikisplit")) | |
| change_example = st.sidebar.checkbox("Try Random Examples") | |
| examples = [ | |
| "Mary likes to play football in her freetime whenever she meets with her friends that are very nice people.", | |
| "It broadcasts on AM frequency 1600 kHz and is under ownership of Multicultural Broadcasting with studios in Surrey , British Columbia .", | |
| "On March 1 , the Blackhawks played in their 2nd outdoor game in franchise history at Soldier Field in part of the new NHL Stadium Series ", | |
| "'' The Rain Song '' is a love ballad , over 7 minutes in length , and is considered by singer Robert Plant to be his best overall vocal performance .", | |
| "The resulting knowledge about human kinesiology and sport nutrition combined with his distinctive posing styles makes Kamali a sought out bodybuilder for seminars and guest appearances and has been featured in many bodybuilding articles , as well as being on the cover of MUSCLEMAG magazine .", | |
| "The East London Line closed on 22 December 2007 and reopened on 27 April 2010 , becoming part of the new London Overground system .", | |
| "' Bandolier - Budgie ' , a free iTunes app for iPad , iPhone and iPod touch , released in December 2011 , tells the story of the making of Bandolier in the band 's own words - including an extensive audio interview with Burke Shelley .", | |
| "' Eden Black ' was grown from seed in the late 1980s by Stephen Morley , under his conditions it produces pitchers that are almost completley black .", | |
| "' Wilson should extend his stint on The Voice to renew public interest in the band ; given that they 're pulling out all the stops , they deserve all the acclaim that surrounded them for their first two albums .", | |
| "'' '' New York Mining Disaster 1941 '' '' was the second EP released by the Bee Gees in 1967 on the Spin Records , like their first EP , it was released only in Australia .", | |
| "'' ADAPTOGENS : Herbs for Strength , Stamina , and Stress Relief , '' Healing Arts Press , 2007 - contains a detailed monograph on Schisandra chinensis as well as highlights health benefits ." | |
| ] | |
| if change_example: | |
| example = examples[random.randint(0, len(examples)-1)] | |
| input_complex_sentence = st.text_area("Please type a Complex Sentence to split",example) | |
| split = st.button('Change and Split✂️') | |
| else: | |
| example=examples[0] | |
| input_complex_sentence = st.text_area("Please type a Complex Sentence to split",example) | |
| split = st.button('Split✂️') | |
| if split: | |
| with st.spinner("Spliting Sentence...🧠"): | |
| generated_sentence = load_model(input_complex_sentence, model) | |
| sentence1, sentence2, _ = generated_sentence.split(".") | |
| st.write("**Sentence1:** "+sentence1+".") | |
| st.write("**Sentence2:** "+sentence2+".") | |
