Dagobert42 commited on
Commit
3b57a52
1 Parent(s): e21d0e1

moved resources to cache

Browse files
Files changed (1) hide show
  1. resources.py +23 -0
resources.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import torch
3
+ import streamlit as st
4
+ from random import shuffle
5
+
6
+ @st.cache_data
7
+ def load_variables():
8
+ return {
9
+ "counter" : 0,
10
+ "augment" : False
11
+ }
12
+
13
+ @st.cache_data
14
+ def load_sentences():
15
+ with open("sentences.pt", 'rb') as f:
16
+ return shuffle(torch.load(f))
17
+
18
+ @st.cache_resource
19
+ def load_model(model):
20
+ return pipeline("ner",
21
+ model=model,
22
+ aggregation_strategy="average"
23
+ )