Dannyar608 commited on
Commit
b6b0c94
·
verified ·
1 Parent(s): 8463af4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -36,24 +36,19 @@ if HF_TOKEN:
36
  # ========== DEEPSEEK MODEL LOADING ==========
37
  def load_deepseek_model():
38
  """Load the DeepSeek model with progress tracking"""
39
- progress = gr.Progress()
40
- progress(0, desc="Loading DeepSeek model...")
41
-
42
  try:
43
  start_time = time.time()
44
  tokenizer = AutoTokenizer.from_pretrained(
45
  "deepseek-ai/DeepSeek-V3",
46
  trust_remote_code=True
47
  )
48
- progress(0.3, desc="Loading tokenizer...")
49
 
50
  model = AutoModelForCausalLM.from_pretrained(
51
  "deepseek-ai/DeepSeek-V3",
52
  trust_remote_code=True,
53
  torch_dtype=torch.float16,
54
- device_map="auto"
55
  )
56
- progress(0.9, desc="Loading model weights...")
57
 
58
  load_time = time.time() - start_time
59
  print(f"DeepSeek model loaded in {load_time:.2f} seconds")
@@ -1459,13 +1454,17 @@ def create_interface():
1459
  outputs=[tabs, nav_message, quiz_alert]
1460
  )
1461
 
1462
- # Check model loading status periodically
1463
  def check_model_status():
1464
  if model is not None and tokenizer is not None:
1465
  return gr.update(visible=False)
1466
  return gr.update(visible=True)
1467
 
1468
- app.load(check_model_status, None, model_status, every=1)
 
 
 
 
1469
 
1470
  return app
1471
 
@@ -1475,4 +1474,4 @@ app = create_interface()
1475
  # For Hugging Face Spaces deployment
1476
  if __name__ == "__main__":
1477
  app.launch()
1478
-
 
36
  # ========== DEEPSEEK MODEL LOADING ==========
37
  def load_deepseek_model():
38
  """Load the DeepSeek model with progress tracking"""
 
 
 
39
  try:
40
  start_time = time.time()
41
  tokenizer = AutoTokenizer.from_pretrained(
42
  "deepseek-ai/DeepSeek-V3",
43
  trust_remote_code=True
44
  )
 
45
 
46
  model = AutoModelForCausalLM.from_pretrained(
47
  "deepseek-ai/DeepSeek-V3",
48
  trust_remote_code=True,
49
  torch_dtype=torch.float16,
50
+ device_map="auto" if torch.cuda.is_available() else None
51
  )
 
52
 
53
  load_time = time.time() - start_time
54
  print(f"DeepSeek model loaded in {load_time:.2f} seconds")
 
1454
  outputs=[tabs, nav_message, quiz_alert]
1455
  )
1456
 
1457
+ # Check model loading status
1458
  def check_model_status():
1459
  if model is not None and tokenizer is not None:
1460
  return gr.update(visible=False)
1461
  return gr.update(visible=True)
1462
 
1463
+ app.load(
1464
+ fn=check_model_status,
1465
+ inputs=None,
1466
+ outputs=model_status
1467
+ )
1468
 
1469
  return app
1470
 
 
1474
  # For Hugging Face Spaces deployment
1475
  if __name__ == "__main__":
1476
  app.launch()
1477
+