Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +23 -2
src/streamlit_app.py
CHANGED
|
@@ -1,3 +1,24 @@
|
|
| 1 |
|
| 2 |
-
import
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
import pandas as pd # <-- CRITICAL MISSING IMPORT
|
| 3 |
+
import streamlit as st # <-- CRITICAL MISSING IMPORT
|
| 4 |
+
from gliner import GLiNER
|
| 5 |
+
|
| 6 |
+
# 1. Initialize the GLiNER Model
|
| 7 |
+
model = GLiNER.from_pretrained("urchade/gliner_largev2")
|
| 8 |
+
|
| 9 |
+
# 2. Define Input Data
|
| 10 |
+
text = """
|
| 11 |
+
Cristiano Ronaldo dos Santos Aveiro
|
| 12 |
+
(Portuguese pronunciation: [kɾiʃˈtjɐnu ʁɔˈnaldu]; born 5 February 1985) is a Portuguese professional
|
| 13 |
+
footballer who plays as a forward for and captains both Saudi Pro League club
|
| 14 |
+
Al Nassr
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
labels = ["person", "award", "date", "competitions", "teams"]
|
| 18 |
+
|
| 19 |
+
# 3. Predict Entities
|
| 20 |
+
entities = model.predict_entities(text, labels)
|
| 21 |
+
|
| 22 |
+
# 4. Create and Display DataFrame in Streamlit
|
| 23 |
+
df = pd.DataFrame(entities)
|
| 24 |
+
st.dataframe(df)
|