File size: 1,215 Bytes
c25690f
 
c3eb514
 
 
 
 
 
 
 
c25690f
c3eb514
c25690f
 
 
 
 
c3eb514
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c25690f
 
 
 
 
c3eb514
c25690f
 
 
c3eb514
c25690f
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import gradio as gr
from openvideo import push_file_to_hf
try:
    import ml4co_kit
except:
    os.system("pip install ml4co-kit-0.0.2a1.tar.gz")    
    import ml4co_kit
from ml4co_kit import CVRPPyVRPSolver
from ml4co_kit import CVRPDataGenerator

FILEPATH = "data/cvrp/uniform/cvrp50_uniform.txt"

def handle(
    hf_token: str, 
    filename: str, 
):
    solver = CVRPPyVRPSolver(time_limit=10)
    gen = CVRPDataGenerator(
        num_threads=8,
        solver=solver,
        train_samples_num=6400,
        val_samples_num=0,
        test_samples_num=0,
    )
    gen.generate()
    push_file_to_hf(
        hf_token=hf_token,
        hf_repo_id="ML4CO/ML4VRP",
        file_path=FILEPATH,
        path_in_repo=filename
    )
    
    
with gr.Blocks() as demo:
    gr.Markdown(
        '''
        VRP Data Generating
        '''
    )
    hf_token = gr.Textbox(label="HuggingFace Token")
    filename = gr.Textbox(label="txt name")

    with gr.Row():
        button = gr.Button("Submit", variant="primary")
        clear = gr.Button("Clear")

    button.click(
        handle, 
        [hf_token, filename], 
        outputs=None
    )


if __name__ == "__main__":
    demo.launch(debug = True)