Wizmik12 commited on
Commit
b08dcff
1 Parent(s): 617e183

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -1,3 +1,24 @@
1
  import gradio as gr
 
2
 
3
- gr.load("models/Andresmfs/st5s-es-inclusivo").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
 
4
+ # Set up OpenAI API key
5
+ tokenizer = AutoTokenizer.from_pretrained("Andresmfs/st5s-es-inclusivo")
6
+ model = AutoModelForSeq2SeqLM.from_pretrained("Andresmfs/st5s-es-inclusivo")
7
+
8
+ def make_neutral(phrase):
9
+ # Define prompt for converting gendered text to neutral
10
+ input_ids = tokenizer(phrase, return_tensors="pt").input_ids
11
+
12
+ # Call the LLM to generate neutral text
13
+ outputs = model.generate(input_ids)
14
+
15
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
16
+
17
+ iface = gr.Interface(
18
+ fn=make_neutral,
19
+ inputs="text",
20
+ outputs="text",
21
+ title="Gender-Neutralizer",
22
+ description="Enter a gendered phrase and get it converted into neutral form."
23
+ )
24
+ iface.launch()