Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ from gliner import GLiNER
|
|
3 |
import gradio as gr
|
4 |
|
5 |
jp_model = GLiNER.from_pretrained("vumichien/ner-jp-gliner")
|
6 |
-
meal_model = GLiNER.from_pretrained("
|
7 |
|
8 |
|
9 |
def merge_tokens(entities, text):
|
@@ -37,19 +37,33 @@ def merge_tokens(entities, text):
|
|
37 |
|
38 |
examples = [
|
39 |
[
|
40 |
-
"ner_jp",
|
41 |
"SPRiNGSと最も仲の良いライバルグループ。",
|
|
|
42 |
"その他の組織名, 法人名, 地名, 人名",
|
43 |
0.3,
|
44 |
True,
|
45 |
],
|
46 |
[
|
47 |
-
"ner_jp",
|
48 |
"レッドフォックス株式会社は、東京都千代田区に本社を置くITサービス企業である",
|
|
|
49 |
"その他の組織名, 法人名, 地名, 人名",
|
50 |
0.3,
|
51 |
False,
|
52 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
]
|
54 |
|
55 |
|
@@ -122,11 +136,11 @@ with gr.Blocks(title="GLiNER-M-v2.1") as demo:
|
|
122 |
gr.Code(
|
123 |
'''
|
124 |
from gliner import GLiNER
|
125 |
-
model = GLiNER.from_pretrained("
|
126 |
text = """
|
127 |
-
|
128 |
"""
|
129 |
-
labels = ["
|
130 |
entities = model.predict_entities(text, labels)
|
131 |
for entity in entities:
|
132 |
print(entity["text"], "=>", entity["label"])
|
@@ -135,23 +149,16 @@ for entity in entities:
|
|
135 |
)
|
136 |
gr.Code(
|
137 |
"""
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
UEFA Men's Player of the Year Awards => award
|
144 |
-
European Golden Shoes => award
|
145 |
-
UEFA Champions Leagues => competitions
|
146 |
-
UEFA European Championship => competitions
|
147 |
-
UEFA Nations League => competitions
|
148 |
-
Champions League => competitions
|
149 |
-
European Championship => competitions
|
150 |
"""
|
151 |
)
|
152 |
|
153 |
input_text = gr.Textbox(
|
154 |
-
value=examples[0][
|
155 |
)
|
156 |
with gr.Row() as row:
|
157 |
models = gr.Dropdown(
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
jp_model = GLiNER.from_pretrained("vumichien/ner-jp-gliner")
|
6 |
+
meal_model = GLiNER.from_pretrained("vumichien/meals-gliner")
|
7 |
|
8 |
|
9 |
def merge_tokens(entities, text):
|
|
|
37 |
|
38 |
examples = [
|
39 |
[
|
|
|
40 |
"SPRiNGSと最も仲の良いライバルグループ。",
|
41 |
+
"ner_jp",
|
42 |
"その他の組織名, 法人名, 地名, 人名",
|
43 |
0.3,
|
44 |
True,
|
45 |
],
|
46 |
[
|
|
|
47 |
"レッドフォックス株式会社は、東京都千代田区に本社を置くITサービス企業である",
|
48 |
+
"ner_jp",
|
49 |
"その他の組織名, 法人名, 地名, 人名",
|
50 |
0.3,
|
51 |
False,
|
52 |
],
|
53 |
+
[
|
54 |
+
"The aromatic flavors of Bangladesh's popular dessert, Mishti Doi, are elevated with a rich chocolate syrup. The velvety texture and subtle sweetness of the ice cream pair perfectly with the crunch of chopped nuts.",
|
55 |
+
"ner_meals",
|
56 |
+
"food, location, ingredient, dessert",
|
57 |
+
0.5,
|
58 |
+
True,
|
59 |
+
],
|
60 |
+
[
|
61 |
+
"The newly opened bakery in Lahore, Pakistan is famous for its freshly baked naan bread. The aroma of warm garlic and coriander wafts through the air, enticing customers to try their signature dish - the 'Lahori Naan'.",
|
62 |
+
"ner_meals",
|
63 |
+
"food, location, ingredient, dessert",
|
64 |
+
0.5,
|
65 |
+
False,
|
66 |
+
],
|
67 |
]
|
68 |
|
69 |
|
|
|
136 |
gr.Code(
|
137 |
'''
|
138 |
from gliner import GLiNER
|
139 |
+
model = GLiNER.from_pretrained("vumichien/meals-gliner", load_tokenizer=True)
|
140 |
text = """
|
141 |
+
The aromatic flavors of Bangladesh's popular dessert, Mishti Doi, are elevated with a rich chocolate syrup. The velvety texture and subtle sweetness of the ice cream pair perfectly with the crunch of chopped nuts.
|
142 |
"""
|
143 |
+
labels = ["food", "location", "ingredient", "dessert"]
|
144 |
entities = model.predict_entities(text, labels)
|
145 |
for entity in entities:
|
146 |
print(entity["text"], "=>", entity["label"])
|
|
|
149 |
)
|
150 |
gr.Code(
|
151 |
"""
|
152 |
+
Bangladesh => location
|
153 |
+
Mishti Doi => food
|
154 |
+
chocolate syrup => ingredient
|
155 |
+
ice cream => dessert
|
156 |
+
chopped nuts => ingredient
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
"""
|
158 |
)
|
159 |
|
160 |
input_text = gr.Textbox(
|
161 |
+
value=examples[0][0], label="Text input", placeholder="Enter your text here"
|
162 |
)
|
163 |
with gr.Row() as row:
|
164 |
models = gr.Dropdown(
|