Spaces:
Runtime error
Runtime error
File size: 1,246 Bytes
aab5d44 243e29d aab5d44 4ab56fe aab5d44 4ab56fe aab5d44 4ab56fe 243e29d 96800a1 bd42249 4ab56fe bd42249 aab5d44 2064b17 243e29d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
#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()
|