Update app.py
Browse files
app.py
CHANGED
@@ -2,39 +2,8 @@ import os
|
|
2 |
from transformers import pipeline
|
3 |
from huggingface_hub import HfApi
|
4 |
|
5 |
-
# Obt茅n
|
6 |
access_token = os.environ.get("HUGGING_FACE_ACCESS_TOKEN")
|
|
|
7 |
|
8 |
-
# Crear una instancia de HfApi
|
9 |
-
api = HfApi(endpoint="https://huggingface.co")
|
10 |
|
11 |
-
# Cargar el modelo pre-entrenado con autenticaci贸n
|
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)
|
|
|
2 |
from transformers import pipeline
|
3 |
from huggingface_hub import HfApi
|
4 |
|
5 |
+
# Obt茅n tu clave de acceso de Hugging Face
|
6 |
access_token = os.environ.get("HUGGING_FACE_ACCESS_TOKEN")
|
7 |
+
print(HUGGING_FACE_ACCESS_TOKEN)
|
8 |
|
|
|
|
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|