Spaces:
Runtime error
Runtime error
import streamlit as st | |
import transformers | |
import tensorflow | |
import PIL | |
from PIL import Image | |
from transformers import pipeline | |
model_checkpoint = "Modfiededition/t5-base-fine-tuned-on-jfleg" | |
def load_model(): | |
return pipeline("text2text-generation", model=model_checkpoint) | |
model = load_model() | |
#prompts | |
st.title("Writing Assistant for you π¦") | |
image = Image.open('grammar.jpg') | |
st.image(image, caption='Sunrise by the mountains') | |
st.subheader("Some examples: ") | |
example_1 = st.button("I am write on AI") | |
example_2 = st.button("This sentence has, bads grammar mistake!") | |
textbox = st.text_area('Write your text in this box:', '', height=100, max_chars=1000) | |
button = st.button('Detect grammar mistakes:') | |
# output | |
if example_1: | |
output_text = model("I am write on AI")[0]["generated_text"] | |
st.markdown("**"+output_text+"**") | |
if example_2: | |
output_text = model("This sentence has, bads grammar mistake!")[0]["generated_text"] | |
st.markdown("**"+output_text+"**") | |
if button: | |
output_text = model(textbox)[0]["generated_text"] | |
st.markdown("**"+output_text+"**") | |