paul hilders commited on
Commit
2910b3b
1 Parent(s): e71dad4

Add NER test

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -27,7 +27,7 @@ clip.clip._MODELS = {
27
  device = "cuda" if torch.cuda.is_available() else "cpu"
28
  model, preprocess = clip.load("ViT-B/32", device=device, jit=False)
29
 
30
- # nlp = spacy.load("en_core_web_sm")
31
 
32
  # Gradio Section:
33
  def run_demo(image, text):
@@ -48,13 +48,13 @@ def run_demo(image, text):
48
 
49
  # Apply NER to extract named entities, and run the explainability method
50
  # for each named entity.
51
- # highlighed_entities = []
52
- # for ent in nlp(text).ents:
53
- # ent_text = ent.text
54
- # ent_label = ent.label_
55
- # highlighed_entities.append((ent_text, ent_label))
56
 
57
- # print(highlighed_entities)
58
 
59
  return overlapped, highlighted_text
60
 
 
27
  device = "cuda" if torch.cuda.is_available() else "cpu"
28
  model, preprocess = clip.load("ViT-B/32", device=device, jit=False)
29
 
30
+ nlp = spacy.load("en_core_web_sm")
31
 
32
  # Gradio Section:
33
  def run_demo(image, text):
 
48
 
49
  # Apply NER to extract named entities, and run the explainability method
50
  # for each named entity.
51
+ highlighed_entities = []
52
+ for ent in nlp(text).ents:
53
+ ent_text = ent.text
54
+ ent_label = ent.label_
55
+ highlighed_entities.append((ent_text, ent_label))
56
 
57
+ print(highlighed_entities)
58
 
59
  return overlapped, highlighted_text
60