Sasidhar commited on
Commit
79341c6
·
1 Parent(s): 634dfe9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -32,14 +32,23 @@ def init_zsl_topic_classification():
32
  pipe = pipeline("zero-shot-classification", model=MODEL)
33
  template = "This text is about {}."
34
  return pipe, template
 
 
 
 
 
 
 
 
35
 
36
  # Model initialization
37
  pipeline_summarization = init_text_summarization_model()
38
  pipeline_zsl, template = init_zsl_topic_classification()
 
39
 
40
  st.header("Intelligent Document Automation")
41
 
42
- def get_text_from_ocr_engine(uploaded_file):
43
  return "This is a sample text for named entity recognition and other tasks"
44
 
45
  with st.sidebar:
@@ -52,4 +61,5 @@ if selected_menu == "Upload Document":
52
  if uploaded_file is not None:
53
  ocr_text = get_text_from_ocr_engine(uploaded_file)
54
  st.write("Upload Successful")
55
-
 
 
32
  pipe = pipeline("zero-shot-classification", model=MODEL)
33
  template = "This text is about {}."
34
  return pipe, template
35
+
36
+ @st.cache(allow_output_mutation = True)
37
+ def init_ner_pipeline():
38
+ tokenizer = AutoTokenizer.from_pretrained("d4data/biomedical-ner-all")
39
+ model = AutoModelForTokenClassification.from_pretrained("d4data/biomedical-ner-all")
40
+ pipe = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple") # pass device=0 if using gpu
41
+ return pipe
42
+
43
 
44
  # Model initialization
45
  pipeline_summarization = init_text_summarization_model()
46
  pipeline_zsl, template = init_zsl_topic_classification()
47
+ pipeline_ner =init_ner_pipeline()
48
 
49
  st.header("Intelligent Document Automation")
50
 
51
+ def get_text_from_ocr_engine():
52
  return "This is a sample text for named entity recognition and other tasks"
53
 
54
  with st.sidebar:
 
61
  if uploaded_file is not None:
62
  ocr_text = get_text_from_ocr_engine(uploaded_file)
63
  st.write("Upload Successful")
64
+ elif selected_menu == "Upload Document:
65
+ st.write(get_text_from_ocr_engine())