Update app.py
Browse files
app.py
CHANGED
@@ -12,3 +12,29 @@ api = HfApi(endpoint="https://huggingface.co")
|
|
12 |
gender_classifier = pipeline('text-classification', model='Dannel/Gender_Classifier', use_auth_token=access_token)
|
13 |
|
14 |
# Resto del c贸digo...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
gender_classifier = pipeline('text-classification', model='Dannel/Gender_Classifier', use_auth_token=access_token)
|
13 |
|
14 |
# Resto del c贸digo...
|
15 |
+
def infer_gender(name):
|
16 |
+
"""
|
17 |
+
Infiere el g茅nero de una persona a partir de su nombre.
|
18 |
+
|
19 |
+
Args:
|
20 |
+
name (str): El nombre de la persona.
|
21 |
+
|
22 |
+
Returns:
|
23 |
+
str: El g茅nero predicho ('Male' o 'Female').
|
24 |
+
"""
|
25 |
+
# Hacer la predicci贸n utilizando el modelo cargado
|
26 |
+
prediction = gender_classifier([name])[0]
|
27 |
+
|
28 |
+
return prediction['label']
|
29 |
+
|
30 |
+
# Crear la interfaz de Gradio
|
31 |
+
demo = gr.Interface(
|
32 |
+
fn=infer_gender,
|
33 |
+
inputs=gr.Textbox(label="Nombre"),
|
34 |
+
outputs=gr.Label(label="G茅nero predicho"),
|
35 |
+
title="Clasificador de G茅nero",
|
36 |
+
description="Ingresa un nombre para predecir su g茅nero."
|
37 |
+
)
|
38 |
+
|
39 |
+
# Ejecutar la aplicaci贸n
|
40 |
+
demo.launch(share=True)
|