Spaces:
Runtime error
Runtime error
File size: 1,161 Bytes
4f22934 |
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 42 43 44 45 46 |
# -*- coding: utf-8 -*-
#Importing dependancies
from styleformer import Styleformer
import gradio as gr
import torch
import warnings
warnings.filterwarnings("ignore")
def set_seed(seed):
torch.manual_seed(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed_all(seed)
set_seed(1234)
#Casual-Formal
sf_0 = Styleformer(style=0)
#Formal-Casual
sf_1 = Styleformer(style=1)
#Active-Passive
sf_2 = Styleformer(style=2)
#Passive-Active
sf_3 = Styleformer(style=3)
def func(text, tone):
if tone=="Casual-Formal":
return sf_0.transfer(text)
if tone=="Formal-Casual":
return sf_1.transfer(text)
if tone=="Active-Passive":
return sf_2.transfer(text)
if tone=="Passive-Active":
return sf_3.transfer(text)
else:
return "No available Transfers😭"
#Initalizing Gradio App
app_description = "This model transforms the tone of text, from formal to informal, from Active to Passive. Choose your option below."
app_title = "Tone Transfer"
app = gr.Interface(func,["text",gr.inputs.Radio(["Casual-Formal", "Formal-Casual", "Active-Passive","Passive-Active"])],"text",description=app_description, title=app_title)
app.launch() |