heatingma commited on
Commit
870f28b
·
verified ·
1 Parent(s): 03d0cdb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -15
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import os
2
  import gradio as gr
 
 
3
  from openvideo import push_file_to_hf
4
  try:
5
  import ml4co_kit
@@ -9,27 +11,36 @@ except:
9
  from ml4co_kit import CVRPPyVRPSolver
10
  from ml4co_kit import CVRPDataGenerator
11
 
12
- FILEPATH = "data/cvrp/uniform/cvrp50_uniform.txt"
13
 
14
  def handle(
15
- hf_token: str,
16
- filename: str,
17
  ):
18
- solver = CVRPPyVRPSolver(time_limit=10)
19
  gen = CVRPDataGenerator(
20
  num_threads=8,
 
 
 
21
  solver=solver,
22
- train_samples_num=89600,
23
  val_samples_num=0,
24
- test_samples_num=0,
25
- )
26
- gen.generate()
27
- push_file_to_hf(
28
- hf_token=hf_token,
29
- hf_repo_id="ML4CO/ML4VRP",
30
- file_path=FILEPATH,
31
- path_in_repo=filename
32
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
 
35
  with gr.Blocks() as demo:
@@ -39,7 +50,6 @@ with gr.Blocks() as demo:
39
  '''
40
  )
41
  hf_token = gr.Textbox(label="HuggingFace Token")
42
- filename = gr.Textbox(label="txt name")
43
 
44
  with gr.Row():
45
  button = gr.Button("Submit", variant="primary")
@@ -47,7 +57,7 @@ with gr.Blocks() as demo:
47
 
48
  button.click(
49
  handle,
50
- [hf_token, filename],
51
  outputs=None
52
  )
53
 
 
1
  import os
2
  import gradio as gr
3
+ import uuid
4
+ import shutil
5
  from openvideo import push_file_to_hf
6
  try:
7
  import ml4co_kit
 
11
  from ml4co_kit import CVRPPyVRPSolver
12
  from ml4co_kit import CVRPDataGenerator
13
 
14
+ FILEPATH = "data/cvrp/uniform/cvrp100_uniform.txt"
15
 
16
  def handle(
17
+ hf_token: str
 
18
  ):
19
+ solver = CVRPPyVRPSolver(time_limit=60)
20
  gen = CVRPDataGenerator(
21
  num_threads=8,
22
+ nodes_num=100,
23
+ min_capacity=50,
24
+ max_capacity=50,
25
  solver=solver,
26
+ train_samples_num=256,
27
  val_samples_num=0,
28
+ test_samples_num=0
 
 
 
 
 
 
 
29
  )
30
+ cur_iter = 0
31
+ max_iter = 1000
32
+
33
+ while(cur_iter < max_iter):
34
+ gen.generate()
35
+ filename = uuid.uuid4().hex[:9] + ".txt"
36
+ push_file_to_hf(
37
+ hf_token=hf_token,
38
+ hf_repo_id="ML4CO/ML4VRPDataset",
39
+ file_path=FILEPATH,
40
+ path_in_repo=filename
41
+ )
42
+ shutil.rmtree("data/cvrp")
43
+ cur_iter = cur_iter + 1
44
 
45
 
46
  with gr.Blocks() as demo:
 
50
  '''
51
  )
52
  hf_token = gr.Textbox(label="HuggingFace Token")
 
53
 
54
  with gr.Row():
55
  button = gr.Button("Submit", variant="primary")
 
57
 
58
  button.click(
59
  handle,
60
+ [hf_token],
61
  outputs=None
62
  )
63