Wizmik12 commited on
Commit
5b1fbfd
1 Parent(s): 7c6e2bb

Create app.py

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