rohansampath commited on
Commit
cc13a5e
·
verified ·
1 Parent(s): 45eaf9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -27,17 +27,15 @@ def load_model():
27
  """Loads the Mistral model and tokenizer and updates the load status."""
28
  global tokenizer, model, model_loaded
29
  try:
30
- if model is not None and tokenizer is not None: # Prevent unnecessary reloads
31
- model_loaded = True
32
- return "✅ Model Already Loaded!"
33
-
34
- tokenizer = AutoTokenizer.from_pretrained(model_name, token=hf_token)
35
- model = AutoModelForCausalLM.from_pretrained(
36
- model_name,
37
- token=hf_token,
38
- torch_dtype=torch.float16
39
- )
40
- model.to('cuda')
41
  model_loaded = True
42
  return "✅ Model Loaded!"
43
  except Exception as e:
 
27
  """Loads the Mistral model and tokenizer and updates the load status."""
28
  global tokenizer, model, model_loaded
29
  try:
30
+ if tokenizer is None:
31
+ tokenizer = AutoTokenizer.from_pretrained(model_name, token=hf_token)
32
+ if model is None:
33
+ model = AutoModelForCausalLM.from_pretrained(
34
+ model_name,
35
+ token=hf_token,
36
+ torch_dtype=torch.float16
37
+ )
38
+ model.to('cuda')
 
 
39
  model_loaded = True
40
  return "✅ Model Loaded!"
41
  except Exception as e: