Spaces:
Build error
Build error
Upload 3 files
Browse files- app.py +26 -43
- requirements.txt +3 -3
app.py
CHANGED
@@ -1,62 +1,45 @@
|
|
1 |
import os
|
2 |
-
import time
|
3 |
-
import shutil
|
4 |
-
import pandas as pd
|
5 |
import gradio as gr
|
6 |
-
from
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
SAVE_CSV_DIR = "panda70m_csv"
|
11 |
-
SAVE_VIDEOS_DIR = "panda70m_videos"
|
12 |
|
13 |
def handle(
|
14 |
hf_token: str,
|
15 |
filename: str,
|
16 |
):
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
download_video_links(hf_token=hf_token, filename=filename, save_dir=SAVE_CSV_DIR)
|
24 |
|
25 |
-
# devide .csv to 100 files and download
|
26 |
-
csv_path = os.path.join(SAVE_CSV_DIR, filename)
|
27 |
-
data = pd.read_csv(csv_path)
|
28 |
-
for idx in range(len(data) // 100):
|
29 |
-
if idx <= 27:
|
30 |
-
continue;
|
31 |
-
begin_idx = idx * 100
|
32 |
-
end_idx = idx * 100 + 100
|
33 |
-
part_data = data[begin_idx : end_idx]
|
34 |
-
part_filename = filename.replace(".csv", "") + "_{:06d}_{:06d}.csv".format(begin_idx, end_idx)
|
35 |
-
targz_filename = part_filename.replace(".csv", ".tar.gz")
|
36 |
-
part_save_path = os.path.join(SAVE_CSV_DIR, part_filename)
|
37 |
-
part_data.to_csv(part_save_path)
|
38 |
-
download_videos_by_csv(
|
39 |
-
csv_file_path=part_save_path,
|
40 |
-
save_dir=SAVE_VIDEOS_DIR,
|
41 |
-
targz_filename=targz_filename
|
42 |
-
)
|
43 |
-
push_to_hf(
|
44 |
-
hf_token=hf_token,
|
45 |
-
hf_repo_id="OpenVideo/Panda-70M-raw",
|
46 |
-
file_path=os.path.join(SAVE_VIDEOS_DIR, targz_filename),
|
47 |
-
path_in_repo=targz_filename
|
48 |
-
)
|
49 |
-
shutil.rmtree(SAVE_VIDEOS_DIR)
|
50 |
-
|
51 |
-
|
52 |
with gr.Blocks() as demo:
|
53 |
gr.Markdown(
|
54 |
'''
|
55 |
-
|
56 |
'''
|
57 |
)
|
58 |
hf_token = gr.Textbox(label="HuggingFace Token")
|
59 |
-
filename = gr.Textbox(label="
|
60 |
|
61 |
with gr.Row():
|
62 |
button = gr.Button("Submit", variant="primary")
|
|
|
1 |
import os
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
+
from openvideo import push_file_to_hf
|
4 |
+
try:
|
5 |
+
import ml4co_kit
|
6 |
+
except:
|
7 |
+
os.system("pip install ml4co-kit-0.0.2a1.tar.gz")
|
8 |
+
import ml4co_kit
|
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=6400,
|
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:
|
36 |
gr.Markdown(
|
37 |
'''
|
38 |
+
VRP Data Generating
|
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")
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
gradio
|
3 |
-
|
4 |
-
|
|
|
1 |
+
openvideo
|
2 |
gradio
|
3 |
+
cython
|
4 |
+
pyvrp==0.6.3
|