Update visomaster/visomaster_install.py
Browse files
visomaster/visomaster_install.py
CHANGED
|
@@ -30,10 +30,19 @@ models_name = os.path.join(models_path, "visomaster_models.7z")
|
|
| 30 |
cuda_bin_path = os.path.join(base_dir, "CUDA", "bin")
|
| 31 |
cuda_lib_path = os.path.join(base_dir, "CUDA", "lib")
|
| 32 |
|
|
|
|
|
|
|
|
|
|
| 33 |
def download_with_requests(url, destination):
|
| 34 |
response = requests.get(url, stream=True, headers={"User-Agent": "Mozilla/5.0"})
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
def extract_archive(archive_path, extract_dir):
|
| 39 |
subprocess.run([seven_zip_path, "x", archive_path, f"-o{extract_dir}", "-y"], check=True)
|
|
@@ -73,28 +82,28 @@ def download_models():
|
|
| 73 |
extract_archive(models_name, models_path)
|
| 74 |
|
| 75 |
if __name__ == "__main__":
|
|
|
|
| 76 |
if not os.path.exists(aria2c_exe_path):
|
| 77 |
download_with_requests(aria2c_url, aria2c_exe_path)
|
|
|
|
| 78 |
|
| 79 |
if not os.path.exists(cuda_archive_path):
|
| 80 |
download_with_requests(cuda_url, cuda_archive_path)
|
|
|
|
| 81 |
if not os.path.exists(cuda_extract_dir):
|
| 82 |
extract_archive(cuda_archive_path, cuda_extract_dir)
|
|
|
|
| 83 |
if os.path.exists(cuda_extract_dir):
|
| 84 |
os.remove(cuda_archive_path)
|
|
|
|
| 85 |
|
| 86 |
clone_git_repo(git_repo_url, visomaster_dir)
|
| 87 |
-
|
| 88 |
setup_cuda_paths()
|
| 89 |
-
|
| 90 |
modify_requirements_file(requirements)
|
| 91 |
-
|
| 92 |
install_requirements()
|
| 93 |
-
|
| 94 |
download_bat()
|
| 95 |
-
|
| 96 |
download_ffmpeg()
|
| 97 |
-
|
| 98 |
download_models()
|
| 99 |
-
|
|
|
|
| 100 |
print("Установка завершена!")
|
|
|
|
| 30 |
cuda_bin_path = os.path.join(base_dir, "CUDA", "bin")
|
| 31 |
cuda_lib_path = os.path.join(base_dir, "CUDA", "lib")
|
| 32 |
|
| 33 |
+
def clear_terminal():
|
| 34 |
+
os.system('cls' if os.name == 'nt' else 'clear')
|
| 35 |
+
|
| 36 |
def download_with_requests(url, destination):
|
| 37 |
response = requests.get(url, stream=True, headers={"User-Agent": "Mozilla/5.0"})
|
| 38 |
+
total_size = int(response.headers.get("content-length", 0))
|
| 39 |
+
block_size = 16384
|
| 40 |
+
progress_bar = tqdm(total=total_size, unit="B", unit_scale=True, desc=f"Скачивание {os.path.basename(destination)}")
|
| 41 |
+
with open(destination, "wb") as file:
|
| 42 |
+
for data in response.iter_content(block_size):
|
| 43 |
+
progress_bar.update(len(data))
|
| 44 |
+
file.write(data)
|
| 45 |
+
progress_bar.close()
|
| 46 |
|
| 47 |
def extract_archive(archive_path, extract_dir):
|
| 48 |
subprocess.run([seven_zip_path, "x", archive_path, f"-o{extract_dir}", "-y"], check=True)
|
|
|
|
| 82 |
extract_archive(models_name, models_path)
|
| 83 |
|
| 84 |
if __name__ == "__main__":
|
| 85 |
+
clear_terminal()
|
| 86 |
if not os.path.exists(aria2c_exe_path):
|
| 87 |
download_with_requests(aria2c_url, aria2c_exe_path)
|
| 88 |
+
clear_terminal()
|
| 89 |
|
| 90 |
if not os.path.exists(cuda_archive_path):
|
| 91 |
download_with_requests(cuda_url, cuda_archive_path)
|
| 92 |
+
clear_terminal()
|
| 93 |
if not os.path.exists(cuda_extract_dir):
|
| 94 |
extract_archive(cuda_archive_path, cuda_extract_dir)
|
| 95 |
+
clear_terminal()
|
| 96 |
if os.path.exists(cuda_extract_dir):
|
| 97 |
os.remove(cuda_archive_path)
|
| 98 |
+
clear_terminal()
|
| 99 |
|
| 100 |
clone_git_repo(git_repo_url, visomaster_dir)
|
|
|
|
| 101 |
setup_cuda_paths()
|
|
|
|
| 102 |
modify_requirements_file(requirements)
|
|
|
|
| 103 |
install_requirements()
|
|
|
|
| 104 |
download_bat()
|
|
|
|
| 105 |
download_ffmpeg()
|
|
|
|
| 106 |
download_models()
|
| 107 |
+
clear_terminal()
|
| 108 |
+
|
| 109 |
print("Установка завершена!")
|