vumichien commited on
Commit
714b95b
1 Parent(s): a9aa45c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -19
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("urchade/gliner_mediumv2.1")
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("urchade/gliner_mediumv2.1")
126
  text = """
127
- Cristiano Ronaldo dos Santos Aveiro (Portuguese pronunciation: [kɾiʃˈtjɐnu ʁɔˈnaldu]; born 5 February 1985) is a Portuguese professional footballer who plays as a forward for and captains both Saudi Pro League club Al Nassr and the Portugal national team. Widely regarded as one of the greatest players of all time, Ronaldo has won five Ballon d'Or awards,[note 3] a record three UEFA Men's Player of the Year Awards, and four European Golden Shoes, the most by a European player. He has won 33 trophies in his career, including seven league titles, five UEFA Champions Leagues, the UEFA European Championship and the UEFA Nations League. Ronaldo holds the records for most appearances (183), goals (140) and assists (42) in the Champions League, goals in the European Championship (14), international goals (128) and international appearances (205). He is one of the few players to have made over 1,200 professional career appearances, the most by an outfield player, and has scored over 850 official senior career goals for club and country, making him the top goalscorer of all time.
128
  """
129
- labels = ["person", "award", "date", "competitions", "teams"]
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
- Cristiano Ronaldo dos Santos Aveiro => person
139
- 5 February 1985 => date
140
- Al Nassr => teams
141
- Portugal national team => teams
142
- Ballon d'Or => award
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][1], label="Text input", placeholder="Enter your text here"
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(