Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import os
|
|
| 8 |
hf_token = os.getenv("HF_TOKEN")
|
| 9 |
login(hf_token)
|
| 10 |
|
|
|
|
| 11 |
model = GLiNER2.from_pretrained("fastino/gliner2-base-0207")
|
| 12 |
|
| 13 |
def run_ner(text, types_csv, descs):
|
|
@@ -82,6 +83,8 @@ header.brand .subtitle {
|
|
| 82 |
border-radius: 0.75rem;
|
| 83 |
box-shadow: 0 4px 10px rgba(0,0,0,0.05);
|
| 84 |
margin-bottom: 1.5rem;
|
|
|
|
|
|
|
| 85 |
}
|
| 86 |
.gr-button.primary {
|
| 87 |
background: var(--primary) !important;
|
|
@@ -105,7 +108,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple", secondary_hue="blue"),
|
|
| 105 |
with gr.Tabs():
|
| 106 |
# NER Tab
|
| 107 |
with gr.TabItem("π Named Entity Recognition"):
|
| 108 |
-
with gr.Row(elem_classes="card"
|
| 109 |
with gr.Column(scale=2):
|
| 110 |
txt1 = gr.Textbox(label="Input Text", lines=5, placeholder="Enter text to extract entities...")
|
| 111 |
types1 = gr.Textbox(label="Entity Types (CSV)", value="person, organization, location, date, title, topic")
|
|
@@ -118,7 +121,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple", secondary_hue="blue"),
|
|
| 118 |
|
| 119 |
# Classification Tab
|
| 120 |
with gr.TabItem("π Text Classification"):
|
| 121 |
-
with gr.Row(elem_classes="card"
|
| 122 |
with gr.Column(scale=2):
|
| 123 |
txt2 = gr.Textbox(label="Input Text", lines=5, placeholder="Enter text to classify...")
|
| 124 |
task2 = gr.Textbox(label="Task Name", value="sentiment_analysis")
|
|
@@ -133,7 +136,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple", secondary_hue="blue"),
|
|
| 133 |
|
| 134 |
# Structure Extraction Tab
|
| 135 |
with gr.TabItem("π Structure Extraction"):
|
| 136 |
-
with gr.Row(elem_classes="card"
|
| 137 |
with gr.Column(scale=2):
|
| 138 |
txt3 = gr.Textbox(label="Input Text", lines=5, placeholder="Enter text for structure extraction...")
|
| 139 |
struct3 = gr.Code(language="json", label="Schema (JSON)", lines=8, value=json.dumps({
|
|
|
|
| 8 |
hf_token = os.getenv("HF_TOKEN")
|
| 9 |
login(hf_token)
|
| 10 |
|
| 11 |
+
# Load model once
|
| 12 |
model = GLiNER2.from_pretrained("fastino/gliner2-base-0207")
|
| 13 |
|
| 14 |
def run_ner(text, types_csv, descs):
|
|
|
|
| 83 |
border-radius: 0.75rem;
|
| 84 |
box-shadow: 0 4px 10px rgba(0,0,0,0.05);
|
| 85 |
margin-bottom: 1.5rem;
|
| 86 |
+
display: grid;
|
| 87 |
+
grid-gap: 1rem;
|
| 88 |
}
|
| 89 |
.gr-button.primary {
|
| 90 |
background: var(--primary) !important;
|
|
|
|
| 108 |
with gr.Tabs():
|
| 109 |
# NER Tab
|
| 110 |
with gr.TabItem("π Named Entity Recognition"):
|
| 111 |
+
with gr.Row(elem_classes="card"):
|
| 112 |
with gr.Column(scale=2):
|
| 113 |
txt1 = gr.Textbox(label="Input Text", lines=5, placeholder="Enter text to extract entities...")
|
| 114 |
types1 = gr.Textbox(label="Entity Types (CSV)", value="person, organization, location, date, title, topic")
|
|
|
|
| 121 |
|
| 122 |
# Classification Tab
|
| 123 |
with gr.TabItem("π Text Classification"):
|
| 124 |
+
with gr.Row(elem_classes="card"):
|
| 125 |
with gr.Column(scale=2):
|
| 126 |
txt2 = gr.Textbox(label="Input Text", lines=5, placeholder="Enter text to classify...")
|
| 127 |
task2 = gr.Textbox(label="Task Name", value="sentiment_analysis")
|
|
|
|
| 136 |
|
| 137 |
# Structure Extraction Tab
|
| 138 |
with gr.TabItem("π Structure Extraction"):
|
| 139 |
+
with gr.Row(elem_classes="card"):
|
| 140 |
with gr.Column(scale=2):
|
| 141 |
txt3 = gr.Textbox(label="Input Text", lines=5, placeholder="Enter text for structure extraction...")
|
| 142 |
struct3 = gr.Code(language="json", label="Schema (JSON)", lines=8, value=json.dumps({
|