Spaces:
Runtime error
Runtime error
#from transformers import pipeline | |
import gradio as gr | |
#from transformers import AutoTokenizer, AutoModelForCausalLM | |
##from os import path | |
##MODEL_DIRECTORY = "/models/mrm8488-t5-base-finetuned-emotion" | |
#tokenizer = AutoTokenizer.from_pretrained("tuner007/pegasus_paraphrase", use_fast=False) | |
##if not path.exists(MODEL_DIRECTORY): | |
#model = AutoModelForCausalLM.from_pretrained("tuner007/pegasus_paraphrase") | |
## model.save_pretrained(MODEL_DIRECTORY) | |
##else: | |
## model = AutoModelWithLMHead.from_pretrained(MODEL_DIRECTORY) | |
# | |
def get_emotion(text): | |
# input_ids = tokenizer.encode(text + '</s>', return_tensors='pt') | |
# output = model.generate(input_ids=input_ids, max_length=2) | |
# | |
# # print(output) | |
# dec = [tokenizer.decode(ids) for ids in output] | |
# print(dec) | |
# label = dec[0] | |
return text | |
def parph(name= "paraphrase: This is something which I cannt understand at all."): | |
#text2text = pipeline("text2text-generation") | |
##model_name = 'tuner007/pegasus_paraphrase' | |
#text2text = pipeline('text2text-generation', model = "Vamsi/T5_Paraphrase_Paws") | |
##text2text(name) | |
test = get_emotion(name) | |
return test # text2text(name) | |
iface = gr.Interface(fn=parph, inputs="text", outputs="text") | |
iface.launch() | |