dad1909 commited on
Commit
7130d3a
·
verified ·
1 Parent(s): a4047d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -12,15 +12,18 @@ max_seq_length = 4096
12
  dtype = None
13
  load_in_4bit = True
14
  hf_token = os.getenv("HF_TOKEN")
 
15
 
16
- pre_models = "dad1909/CyberSentinel-3"
17
- uploads_models = "CyberSentinel-4"
 
 
18
 
19
  print("Starting model and tokenizer loading...")
20
 
21
  # Load the model and tokenizer
22
  model, tokenizer = FastLanguageModel.from_pretrained(
23
- model_name=pre_models,
24
  max_seq_length=max_seq_length,
25
  dtype=dtype,
26
  load_in_4bit=load_in_4bit,
@@ -135,6 +138,11 @@ print("Starting training...")
135
  trainer_stats = trainer.train()
136
  print("Training completed.")
137
 
 
 
 
 
 
138
  print("Saving the trained model...")
139
  model.save_pretrained_merged("model", tokenizer, save_method="merged_16bit")
140
  print("Model saved successfully.")
@@ -148,5 +156,5 @@ model.push_to_hub_merged(
148
  )
149
  print("Model pushed to hub successfully.")
150
 
151
- api = HfApi()
152
- api.pause_space(repo_id="dad1909/CyberCode")
 
12
  dtype = None
13
  load_in_4bit = True
14
  hf_token = os.getenv("HF_TOKEN")
15
+ current_num = os.getenv("NUM")
16
 
17
+ print(f"stage ${current_num}")
18
+
19
+ api = HfApi(token=hf_token)
20
+ models = f"dad1909/CyberSentinel-{current_num}"
21
 
22
  print("Starting model and tokenizer loading...")
23
 
24
  # Load the model and tokenizer
25
  model, tokenizer = FastLanguageModel.from_pretrained(
26
+ model_name=models,
27
  max_seq_length=max_seq_length,
28
  dtype=dtype,
29
  load_in_4bit=load_in_4bit,
 
138
  trainer_stats = trainer.train()
139
  print("Training completed.")
140
 
141
+ num = int(current_num)
142
+ num += 1
143
+
144
+ uploads_models = f"CyberSentinel-{str(num)}"
145
+
146
  print("Saving the trained model...")
147
  model.save_pretrained_merged("model", tokenizer, save_method="merged_16bit")
148
  print("Model saved successfully.")
 
156
  )
157
  print("Model pushed to hub successfully.")
158
 
159
+ api.delete_space_variable(repo_id="dad1909/CyberCode", key="NUM")
160
+ api.add_space_variable(repo_id="dad1909/CyberCode", key="NUM", value=str(num))