Skip to content

Commit e0b9084

Browse files
committed
update quick demo code
1 parent 95d9bea commit e0b9084

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

assets/download_demo_images.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import os
22
import wget
3+
import shutil
34
import zipfile
5+
import argparse
46

5-
def main():
6-
wget.download(
7-
'https://github.com/FanChiMao/Competition-2024-PyTorch-Tracking/releases/download/v0.0/demo_images.zip')
7+
def main(target_path):
8+
target_path = os.path.abspath(target_path)
9+
wget.download('https://github.com/FanChiMao/Competition-2024-PyTorch-Tracking/releases/download/v0.0/demo_images.zip',
10+
out=target_path)
811

912
try:
1013
print("Start download the demo images...")
11-
if os.path.exists("./demo_images.zip"):
12-
with zipfile.ZipFile("demo_images.zip") as zip_ref:
13-
zip_ref.extractall(".")
14+
if os.path.exists(os.path.join(target_path, "./demo_images.zip")):
15+
with zipfile.ZipFile(os.path.join(target_path, "./demo_images.zip")) as zip_ref:
16+
zip_ref.extractall(target_path)
1417
except Exception as error:
1518
print(f"Error Exception: {error}")
1619
finally:
17-
if os.path.exists("./demo_images.zip"):
18-
os.remove("./demo_images.zip")
20+
if os.path.exists(os.path.join(target_path, "./demo_images.zip")):
21+
os.remove(os.path.join(target_path, "./demo_images.zip"))
1922

2023

2124
if __name__ == '__main__':
22-
main()
25+
parser = argparse.ArgumentParser()
26+
parser.add_argument('--target_path', type=str, default=".")
27+
args = parser.parse_args()
28+
main(args.target_path)

demo_examples.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import os
2-
import sys
3-
sys.path.append("Detector")
42

53
print(">> Download pretrained weights")
64
try:
@@ -15,7 +13,7 @@
1513
os.makedirs("assets", exist_ok=True)
1614
if not os.path.exists("assets/demo_images"):
1715
try:
18-
os.system("python assets/download_demo_images.py")
16+
os.system("python assets/download_demo_images.py --target_path assets")
1917
if not os.path.exists("assets/demo_images"):
2018
raise "demo_images doesn't exist"
2119
except Exception as error:

0 commit comments

Comments
 (0)