import gradio as gr | |
from gliner import GLiNER | |
# Cargar el modelo | |
model = GLiNER.from_pretrained("EmergentMethods/gliner_medium_news-v2.1") | |
# Funci贸n para predecir entidades | |
def predict_entities(text): | |
labels = ["person", "location", "date", "event", "facility", "vehicle", "number", "organization"] | |
entities = model.predict_entities(text, labels) | |
return entities | |
# Definir la funci贸n de API | |
def api_function(text): | |
entities = predict_entities(text) | |
return entities | |
# Configurar la interfaz Gradio | |
iface = gr.Interface(fn=api_function, inputs="text", outputs="json") | |
iface.launch(share=True) | |