ashhadahsan commited on
Commit
74e3a69
·
1 Parent(s): 20f398b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -31,7 +31,8 @@ model_classes = {
31
  }
32
 
33
 
34
- @st.cache(allow_output_mutation=True, suppress_st_warning=True)
 
35
  def load_t5():
36
  model = AutoModelForSeq2SeqLM.from_pretrained("t5-base")
37
 
@@ -39,30 +40,35 @@ def load_t5():
39
  return model, tokenizer
40
 
41
 
42
- @st.cache(allow_output_mutation=True, suppress_st_warning=True)
 
43
  def custom_model():
44
  return pipeline("summarization", model="my_awesome_sum/")
45
 
46
 
47
- @st.cache(allow_output_mutation=True, suppress_st_warning=True)
 
48
  def convert_df(df):
49
  # IMPORTANT: Cache the conversion to prevent computation on every rerun
50
  return df.to_csv(index=False).encode("utf-8")
51
 
52
 
53
- @st.cache(allow_output_mutation=True, suppress_st_warning=True)
 
54
  def load_one_line_summarizer(model):
55
  return model.load_model("t5", "snrspeaks/t5-one-line-summary")
56
 
57
 
58
- @st.cache(allow_output_mutation=True, suppress_st_warning=True)
 
59
  def classify_category():
60
  tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
61
  new_model = load_model("model")
62
  return tokenizer, new_model
63
 
64
 
65
- @st.cache(allow_output_mutation=True, suppress_st_warning=True)
 
66
  def classify_sub_theme():
67
  tokenizer = BertTokenizer.from_pretrained(
68
  "ashhadahsan/amazon-subtheme-bert-base-finetuned"
 
31
  }
32
 
33
 
34
+ # @st.cache(allow_output_mutation=True, suppress_st_warning=True)
35
+ @st.cache_resource
36
  def load_t5():
37
  model = AutoModelForSeq2SeqLM.from_pretrained("t5-base")
38
 
 
40
  return model, tokenizer
41
 
42
 
43
+ # @st.cache(allow_output_mutation=True, suppress_st_warning=True)
44
+ @st.cache_resource
45
  def custom_model():
46
  return pipeline("summarization", model="my_awesome_sum/")
47
 
48
 
49
+ # @st.cache(allow_output_mutation=True, suppress_st_warning=True)
50
+ @st.cache_resource
51
  def convert_df(df):
52
  # IMPORTANT: Cache the conversion to prevent computation on every rerun
53
  return df.to_csv(index=False).encode("utf-8")
54
 
55
 
56
+ # @st.cache(allow_output_mutation=True, suppress_st_warning=True)
57
+ @st.cache_resource
58
  def load_one_line_summarizer(model):
59
  return model.load_model("t5", "snrspeaks/t5-one-line-summary")
60
 
61
 
62
+ # @st.cache(allow_output_mutation=True, suppress_st_warning=True)
63
+ @st.cache_resource
64
  def classify_category():
65
  tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
66
  new_model = load_model("model")
67
  return tokenizer, new_model
68
 
69
 
70
+ # @st.cache(allow_output_mutation=True, suppress_st_warning=True)
71
+ @st.cache_resource
72
  def classify_sub_theme():
73
  tokenizer = BertTokenizer.from_pretrained(
74
  "ashhadahsan/amazon-subtheme-bert-base-finetuned"