-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
161 lines (118 loc) · 6.26 KB
/
setup.py
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import os
def initial_setup():
# Run this when setting up from scratch!
# requirements
os.system("pip install --user -r requirements_all.txt")
os.system("pip3 install --user -r requirements_all.txt")
# ME-GraphAU Install
if not(os.path.exists('megraphau')):
os.system("git clone https://github.com/JayRGopal/ME-GraphAU")
os.rename('ME-GraphAU', 'megraphau')
# Yolo_Tracking Install
if not(os.path.exists('yolo_tracking')):
os.system("git clone https://github.com/JayRGopal/yolo_tracking")
os.chdir('yolo_tracking')
os.system("pip install -e .")
os.chdir('..')
# NEMO Install
# if not os.path.exists("scripts_nemo_asr/transcribe_speech.py"):
# os.system("wget -P scripts_nemo_asr/ https://raw.githubusercontent.com/NVIDIA/NeMo/stable/examples/asr/transcribe_speech.py")
# if not os.path.exists("scripts_nemo_asr/speech_to_text_eval.py"):
# os.system("wget -P scripts_nemo_asr/ https://raw.githubusercontent.com/NVIDIA/NeMo/stable/examples/asr/speech_to_text_eval.py")
# os.system('pip3 install Cython')
# os.system('python3 -m pip install git+https://github.com/NVIDIA/[email protected]#egg=nemo_toolkit')
# Note: You may also need visualstudio.microsoft.com/visual-cpp-build-tools/
# Note: We also had to clone the nemo repo and pip install requirements on the CPU workstation
# MMPose Install
os.system('pip install numpy==1.23.5')
os.system("pip install -U openmim")
os.system("pip3 install mmpose")
os.system("python3 -m mim install mmengine")
os.system('python3 -m mim install "mmcv>=2.0.0"')
os.system('python3 -m mim install "mmdet>=3.0.0"')
os.system('python3 -m mim install "mmcls>=1.0.0rc5"')
os.system('python3 -m mim install "mmpretrain>=1.0.0"') # for ViT Pose
if not(os.path.exists('mmpose')):
os.system("git clone https://github.com/JayRGopal/mmpose")
os.system('cd mmpose')
os.system('pip install -r requirements.txt')
os.system('pip install -v -e .')
os.system('cd ..')
os.system('pip install numpy==1.23.5')
return
def partial_setup():
# Run this when completing setup of an environment with TF, Torch, and cuda all installed
# requirements
os.system("pip install --user -r requirements_partial.txt")
os.system("pip3 install --user -r requirements_partial.txt")
# MMPose Install
os.system('pip install numpy==1.23.5')
os.system("pip install -U openmim")
os.system("pip3 install mmpose")
os.system("python3 -m mim install mmengine")
os.system('python3 -m mim install "mmcv>=2.0.0"')
os.system('python3 -m mim install "mmdet>=3.0.0"')
os.system('python3 -m mim install "mmcls>=1.0.0rc5"')
os.system('python3 -m mim install "mmpretrain>=1.0.0"') # for ViT Pose
os.system('cd mmpose')
os.system('pip install -r requirements.txt')
os.system('pip install -v -e .')
os.system('cd ..')
os.system('pip install numpy==1.23.5')
return
def gpu_setup():
# May need to adjust this based on workstation
os.system("pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118")
return
if __name__ == '__main__':
# Uncomment for initial setup
#initial_setup()
partial_setup()
# Uncomment for GPU
#gpu_setup()
import requests
def down_now(save_path, file_id):
# Construct the direct download link
download_link = f"https://drive.google.com/uc?export=download&id={file_id}"
# Call the requests library to download the file
response = requests.get(download_link)
if response.status_code == 200:
# Save the downloaded file to the specified path
with open(save_path, "wb") as f:
f.write(response.content)
print(f"File downloaded and saved to {save_path}.")
else:
print("An error occurred while downloading the file.")
return
def download_file(link: str, output_path: str) -> None:
# Download the file using requests with streaming and chunked writing
with requests.get(link, stream=True) as response:
if response.status_code == 200:
with open(output_path, "wb") as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
print(f"File downloaded and saved to {output_path}")
else:
print("An error occurred while downloading the file.")
import gdown
def gdownload(fid, dest):
url = f'https://drive.google.com/uc?id={fid}'
destination = dest
gdown.download(url, destination, quiet=False)
return
if __name__ == '__main__':
if not(os.path.exists("megraphau/checkpoints/swin_base_patch4_window7_224.pth")):
gdownload('1U_PEhO5ymJc77kNtVrMja_cRcC0UpfS4', "megraphau/checkpoints/swin_base_patch4_window7_224.pth")
if not(os.path.exists("megraphau/checkpoints/OpenGprahAU-SwinB_first_stage.pth")):
gdownload('1_sJpvGLbZxoFenQFT7qYtTw91tEKSe0u', "megraphau/checkpoints/OpenGprahAU-SwinB_first_stage.pth")
if not(os.path.exists('megraphau/checkpoints/OpenGprahAU-ResNet50_first_stage.pth')):
gdownload('1zuIZXz7MPsKOlDJMjju8oMYZRifl9sHt', 'megraphau/checkpoints/OpenGprahAU-ResNet50_first_stage.pth')
#gdownload('1wnJzvZ8bTR1yc4BhAiNaqU3HH10YX_cf', 'megraphau/checkpoints/OpenGprahAU-ResNet50_first_stage.pth')
# if not(os.path.exists('megraphau/checkpoints/MEFARG_resnet50_BP4D_fold3.pth')):
# gdownload('178lhLCfPKOKlBLj2QgbqQDFEfoXMHEoD', 'megraphau/checkpoints/MEFARG_resnet50_BP4D_fold3.pth')
if not(os.path.exists("megraphau/checkpoints/resnet50-19c8e357.pth")):
gdownload('1i68ZxnsI7Hw6vxcFy_IXXfQ05supUDhp', "megraphau/checkpoints/resnet50-19c8e357.pth")
#download_file("https://download.pytorch.org/models/resnet50-19c8e357.pth", "megraphau/checkpoints/resnet50-19c8e357.pth")
if not(os.path.exists("MMPose_models/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth")):
gdownload('1xCcdCFslOp2K6GNg9ep6RdYyOeue2V7g', "MMPose_models/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth")
#download_file('https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth', "MMPose_models/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth")