Shredder commited on
Commit
70b186b
1 Parent(s): 2c4ce5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -1,9 +1,13 @@
1
  import gradio as gr
2
  from transformers import AutoTokenizer, AutoModelForTokenClassification,RobertaTokenizer
3
  import torch
 
 
4
  from fin_readability_sustainability import BERTClass, do_predict
5
  import pandas as pd
6
 
 
 
7
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
8
 
9
 
@@ -13,7 +17,6 @@ model_sustain.to(device)
13
  model_sustain.load_state_dict(torch.load('sustainability_model.bin', map_location=device)['model_state_dict'])
14
 
15
 
16
- from nltk.tokenize import sent_tokenize
17
  def get_sustainability(text):
18
  df = pd.DataFrame({'sentence':sent_tokenize(text)})
19
  actual_predictions_sustainability = do_predict(model_sustain, tokenizer_sus, df)
 
1
  import gradio as gr
2
  from transformers import AutoTokenizer, AutoModelForTokenClassification,RobertaTokenizer
3
  import torch
4
+ import nltk
5
+ from nltk.tokenize import sent_tokenize
6
  from fin_readability_sustainability import BERTClass, do_predict
7
  import pandas as pd
8
 
9
+ nltk.download('punkt')
10
+
11
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
12
 
13
 
 
17
  model_sustain.load_state_dict(torch.load('sustainability_model.bin', map_location=device)['model_state_dict'])
18
 
19
 
 
20
  def get_sustainability(text):
21
  df = pd.DataFrame({'sentence':sent_tokenize(text)})
22
  actual_predictions_sustainability = do_predict(model_sustain, tokenizer_sus, df)