Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gliner import GLiNER
|
| 3 |
+
|
| 4 |
+
# Cargar el modelo
|
| 5 |
+
model = GLiNER.from_pretrained("EmergentMethods/gliner_medium_news-v2.1")
|
| 6 |
+
|
| 7 |
+
# Funci贸n para predecir entidades
|
| 8 |
+
def predict_entities(text):
|
| 9 |
+
labels = ["person", "location", "date", "event", "facility", "vehicle", "number", "organization"]
|
| 10 |
+
entities = model.predict_entities(text, labels)
|
| 11 |
+
return entities
|
| 12 |
+
|
| 13 |
+
# Definir la funci贸n de API
|
| 14 |
+
def api_function(text):
|
| 15 |
+
entities = predict_entities(text)
|
| 16 |
+
return entities
|
| 17 |
+
|
| 18 |
+
# Configurar la interfaz Gradio
|
| 19 |
+
iface = gr.Interface(fn=api_function, inputs="text", outputs="json")
|
| 20 |
+
iface.launch(share=True)
|