kadabengaran commited on
Commit
24d7bd7
·
1 Parent(s): 2424164
Files changed (1) hide show
  1. app/main.py +13 -21
app/main.py CHANGED
@@ -19,30 +19,18 @@ img {
19
  """
20
 
21
  footer="""<style>
22
- a:link , a:visited{
23
- color: blue;
24
- background-color: transparent;
25
- text-decoration: underline;
26
- }
27
-
28
- a:hover, a:active {
29
- color: red;
30
- background-color: transparent;
31
- text-decoration: underline;
32
- }
33
-
34
  .footer {
35
  position: fixed;
36
  left: 0;
37
  bottom: 0;
38
  width: 100%;
39
  background-color: white;
40
- color: black;
41
  text-align: center;
42
  }
43
  </style>
44
  <div class="footer">
45
- <p>Developed with ❤ by <a style='display: block; text-align: center;' href="https://www.heflin.dev/" target="_blank">Heflin Stephen Raj S</a></p>
46
  </div>
47
  """
48
  # Config
@@ -50,18 +38,23 @@ MAX_SEQ_LEN = 128
50
  MODELS_PATH = "kadabengaran/IndoBERT-BiLSTM-Useful-App-Review"
51
  LABELS = {'Not Useful': 0, 'Useful': 1}
52
 
53
- # Get the Keys
54
- def get_key(val, my_dict):
55
- for key, value in my_dict.items():
56
- if val == value:
57
- return key
58
-
59
  def get_device():
60
  if torch.cuda.is_available():
61
  return torch.device('cuda')
62
  else:
63
  return torch.device('cpu')
64
 
 
 
 
 
 
 
 
 
 
 
 
65
  def load_tokenizer(model_path):
66
  tokenizer = BertTokenizer.from_pretrained(model_path)
67
  return tokenizer
@@ -153,7 +146,6 @@ class App:
153
  def run(self):
154
  self.init_session_state() # Initialize session state
155
  tokenizer = load_tokenizer(MODELS_PATH)
156
- device = get_device()
157
  model = load_model()
158
  """App Review Classifier"""
159
  html_temp = """
 
19
  """
20
 
21
  footer="""<style>
 
 
 
 
 
 
 
 
 
 
 
 
22
  .footer {
23
  position: fixed;
24
  left: 0;
25
  bottom: 0;
26
  width: 100%;
27
  background-color: white;
28
+ color: #fff;
29
  text-align: center;
30
  }
31
  </style>
32
  <div class="footer">
33
+ <p>CUDA enabled</p>
34
  </div>
35
  """
36
  # Config
 
38
  MODELS_PATH = "kadabengaran/IndoBERT-BiLSTM-Useful-App-Review"
39
  LABELS = {'Not Useful': 0, 'Useful': 1}
40
 
 
 
 
 
 
 
41
  def get_device():
42
  if torch.cuda.is_available():
43
  return torch.device('cuda')
44
  else:
45
  return torch.device('cpu')
46
 
47
+ USE_CUDA = False
48
+ device = get_device()
49
+ if device.type == 'cuda':
50
+ USE_CUDA = True
51
+
52
+ # Get the Keys
53
+ def get_key(val, my_dict):
54
+ for key, value in my_dict.items():
55
+ if val == value:
56
+ return key
57
+
58
  def load_tokenizer(model_path):
59
  tokenizer = BertTokenizer.from_pretrained(model_path)
60
  return tokenizer
 
146
  def run(self):
147
  self.init_session_state() # Initialize session state
148
  tokenizer = load_tokenizer(MODELS_PATH)
 
149
  model = load_model()
150
  """App Review Classifier"""
151
  html_temp = """