transpolymer commited on
Commit
b69e05d
·
verified ·
1 Parent(s): 3b0f51a

Update prediction.py

Browse files
Files changed (1) hide show
  1. prediction.py +3 -4
prediction.py CHANGED
@@ -17,7 +17,8 @@ np.random.seed(42)
17
  torch.manual_seed(42)
18
  torch.backends.cudnn.deterministic = True
19
  torch.backends.cudnn.benchmark = False
20
-
 
21
  # ------------------------ Load ChemBERTa Model + Tokenizer ------------------------
22
  @st.cache_resource
23
  def load_chemberta():
@@ -26,8 +27,7 @@ def load_chemberta():
26
  model.eval()
27
  model.to(device) # Send model to GPU if available
28
  return tokenizer, model
29
- # Check if CUDA is available for GPU acceleration
30
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
31
 
32
  # ------------------------ Load Scalers ------------------------
33
  scalers = {
@@ -66,7 +66,6 @@ class TransformerRegressor(nn.Module):
66
  x = x.mean(dim=1)
67
  return self.regression_head(x)
68
 
69
- # ------------------------ Load Model ------------------------
70
  @st.cache_resource
71
  def load_model():
72
  # Initialize the model architecture first
 
17
  torch.manual_seed(42)
18
  torch.backends.cudnn.deterministic = True
19
  torch.backends.cudnn.benchmark = False
20
+ # Check if CUDA is available for GPU acceleration
21
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
22
  # ------------------------ Load ChemBERTa Model + Tokenizer ------------------------
23
  @st.cache_resource
24
  def load_chemberta():
 
27
  model.eval()
28
  model.to(device) # Send model to GPU if available
29
  return tokenizer, model
30
+
 
31
 
32
  # ------------------------ Load Scalers ------------------------
33
  scalers = {
 
66
  x = x.mean(dim=1)
67
  return self.regression_head(x)
68
 
 
69
  @st.cache_resource
70
  def load_model():
71
  # Initialize the model architecture first