suryadev1 commited on
Commit
445302e
1 Parent(s): 751666e

changed num workers

Browse files
Files changed (4) hide show
  1. app.py +12 -2
  2. result.txt +6 -0
  3. src/test_saved_model.py +4 -2
  4. tets.py +0 -0
app.py CHANGED
@@ -16,14 +16,24 @@ def process_file(file, model_name):
16
  shutil.copyfile(file.name, saved_test_dataset)
17
  # For demonstration purposes, we'll just return the content with the selected model name
18
  subprocess.run(["python", "src/test_saved_model.py"])
19
- return f"Model: {model_name}\nContent:\n{content}"
 
 
 
 
 
 
 
 
 
 
20
 
21
  # List of models for the dropdown menu
22
  models = ["Model A", "Model B", "Model C"]
23
 
24
  # Create the Gradio interface
25
  with gr.Blocks() as demo:
26
- gr.Markdown("# File Processor with Model Selection")
27
  gr.Markdown("Upload a .txt file and select a model from the dropdown menu.")
28
 
29
  with gr.Row():
 
16
  shutil.copyfile(file.name, saved_test_dataset)
17
  # For demonstration purposes, we'll just return the content with the selected model name
18
  subprocess.run(["python", "src/test_saved_model.py"])
19
+ result = {}
20
+ with open("result.txt", 'r') as file:
21
+ for line in file:
22
+ key, value = line.strip().split(': ', 1)
23
+ # print(type(key))
24
+ if key=='epoch':
25
+ result[key]=value
26
+ else:
27
+ result[key]=float(value)
28
+
29
+ return f"Model: {model_name}\nResult:\n{result}"
30
 
31
  # List of models for the dropdown menu
32
  models = ["Model A", "Model B", "Model C"]
33
 
34
  # Create the Gradio interface
35
  with gr.Blocks() as demo:
36
+ gr.Markdown("# ASTRA")
37
  gr.Markdown("Upload a .txt file and select a model from the dropdown menu.")
38
 
39
  with gr.Row():
result.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ epoch: EP0_test
2
+ accuracy: 12.545819442371167
3
+ avg_loss: 0.0
4
+ precisions: 0.9988672445640735
5
+ recalls: 0.8782073609659816
6
+ f1_scores: 0.9254850123297983
src/test_saved_model.py CHANGED
@@ -148,7 +148,9 @@ class BERTFineTunedTrainer:
148
  "recalls": recalls,
149
  "f1_scores": f1_scores
150
  }
151
-
 
 
152
  print(final_msg)
153
 
154
  # print("EP%d_%s, avg_loss=" % (epoch, str_code), avg_loss / len(data_iter), "total_acc=", total_correct * 100.0 / total_element)
@@ -217,7 +219,7 @@ if __name__ == "__main__":
217
  print("Loading Test Dataset", args.test_dataset)
218
  test_dataset = TokenizerDataset(args.test_dataset, args.test_label, vocab_obj, seq_len=args.seq_len, train=False)
219
  print("Creating Dataloader")
220
- test_data_loader = DataLoader(test_dataset, batch_size=args.batch_size, num_workers=0)
221
  bert = torch.load(args.finetuned_bert_checkpoint, map_location="cpu")
222
 
223
  if args.workspace_name == "ratio_proportion_change4":
 
148
  "recalls": recalls,
149
  "f1_scores": f1_scores
150
  }
151
+ with open("result.txt", 'w') as file:
152
+ for key, value in final_msg.items():
153
+ file.write(f"{key}: {value}\n")
154
  print(final_msg)
155
 
156
  # print("EP%d_%s, avg_loss=" % (epoch, str_code), avg_loss / len(data_iter), "total_acc=", total_correct * 100.0 / total_element)
 
219
  print("Loading Test Dataset", args.test_dataset)
220
  test_dataset = TokenizerDataset(args.test_dataset, args.test_label, vocab_obj, seq_len=args.seq_len, train=False)
221
  print("Creating Dataloader")
222
+ test_data_loader = DataLoader(test_dataset, batch_size=args.batch_size, num_workers=4)
223
  bert = torch.load(args.finetuned_bert_checkpoint, map_location="cpu")
224
 
225
  if args.workspace_name == "ratio_proportion_change4":
tets.py ADDED
The diff for this file is too large to render. See raw diff