ubuntu
commited on
Commit
·
68e5f5a
1
Parent(s):
e4ae9d7
update genn_astar
Browse files- app.py +7 -8
- genn_astar.py +0 -2
app.py
CHANGED
@@ -19,28 +19,27 @@ def _handle_ged_solve(
|
|
19 |
gexf_1_path: str,
|
20 |
gexf_2_path: str
|
21 |
):
|
|
|
22 |
if gexf_1_path is None:
|
23 |
raise gr.Error("Please upload file completely!")
|
24 |
if gexf_2_path is None:
|
25 |
raise gr.Error("Please upload file completely!")
|
26 |
|
27 |
-
|
28 |
-
print("111")
|
29 |
dirs = pygm.utils.user_cache_dir("pygmtools")
|
30 |
-
print(dirs)
|
31 |
-
print(os.path.exists(dirs))
|
32 |
if not os.path.exists(dirs):
|
33 |
os.makedirs(dirs)
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
37 |
astar(
|
38 |
g1_path=gexf_1_path,
|
39 |
g2_path=gexf_2_path,
|
40 |
output_path="media",
|
41 |
filename="ged_image"
|
42 |
)
|
43 |
-
print("444")
|
44 |
solved_time = time.time() - start_time
|
45 |
|
46 |
message = "Successfully solve the GED problem, using time ({:.3f}s).".format(solved_time)
|
|
|
19 |
gexf_1_path: str,
|
20 |
gexf_2_path: str
|
21 |
):
|
22 |
+
# check the input files
|
23 |
if gexf_1_path is None:
|
24 |
raise gr.Error("Please upload file completely!")
|
25 |
if gexf_2_path is None:
|
26 |
raise gr.Error("Please upload file completely!")
|
27 |
|
28 |
+
# check the pretrained file
|
|
|
29 |
dirs = pygm.utils.user_cache_dir("pygmtools")
|
|
|
|
|
30 |
if not os.path.exists(dirs):
|
31 |
os.makedirs(dirs)
|
32 |
+
if os.path.exists(PRETRAINED_PATH):
|
33 |
+
shutil.move(src=PRETRAINED_PATH, dst=os.path.join(dirs, PRETRAINED_PATH))
|
34 |
+
|
35 |
+
# begin solve
|
36 |
+
start_time = time.time()
|
37 |
astar(
|
38 |
g1_path=gexf_1_path,
|
39 |
g2_path=gexf_2_path,
|
40 |
output_path="media",
|
41 |
filename="ged_image"
|
42 |
)
|
|
|
43 |
solved_time = time.time() - start_time
|
44 |
|
45 |
message = "Successfully solve the GED problem, using time ({:.3f}s).".format(solved_time)
|
genn_astar.py
CHANGED
@@ -141,9 +141,7 @@ def astar(
|
|
141 |
A2 = torch.tensor(pygm.utils.from_networkx(graph2)).float().to(device)
|
142 |
|
143 |
# Caculate the ged
|
144 |
-
print("111111")
|
145 |
x_pred = pygm.genn_astar(feat1, feat2, A1, A2, return_network=False)
|
146 |
-
print("222222")
|
147 |
|
148 |
# Plot
|
149 |
draw(graph1, colors1, labels1, output_filename.format(1), "Graph1")
|
|
|
141 |
A2 = torch.tensor(pygm.utils.from_networkx(graph2)).float().to(device)
|
142 |
|
143 |
# Caculate the ged
|
|
|
144 |
x_pred = pygm.genn_astar(feat1, feat2, A1, A2, return_network=False)
|
|
|
145 |
|
146 |
# Plot
|
147 |
draw(graph1, colors1, labels1, output_filename.format(1), "Graph1")
|