Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,33 @@ os.environ["PIXEL3DMM_CODE_BASE"] = f"{os.getcwd()}"
|
|
| 15 |
os.environ["PIXEL3DMM_PREPROCESSED_DATA"] = f"{os.getcwd()}/proprocess_results"
|
| 16 |
os.environ["PIXEL3DMM_TRACKING_OUTPUT"] = f"{os.getcwd()}/tracking_results"
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# Utility to select first image from a folder
|
| 19 |
def first_image_from_dir(directory):
|
| 20 |
patterns = ["*.jpg", "*.png", "*.jpeg"]
|
|
|
|
| 15 |
os.environ["PIXEL3DMM_PREPROCESSED_DATA"] = f"{os.getcwd()}/proprocess_results"
|
| 16 |
os.environ["PIXEL3DMM_TRACKING_OUTPUT"] = f"{os.getcwd()}/tracking_results"
|
| 17 |
|
| 18 |
+
def sh(cmd): subprocess.check_call(cmd, shell=True)
|
| 19 |
+
|
| 20 |
+
# only do this once per VM restart
|
| 21 |
+
sh("pip install -e .")
|
| 22 |
+
sh("cd src/pixel3dmm/preprocessing/facer && pip install -e .")
|
| 23 |
+
sh("cd src/pixel3dmm/preprocessing/PIPNet/FaceBoxesV2/utils && sh make.sh")
|
| 24 |
+
|
| 25 |
+
def install_cuda_toolkit():
|
| 26 |
+
CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda_12.1.0_530.30.02_linux.run"
|
| 27 |
+
CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
|
| 28 |
+
subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
|
| 29 |
+
subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
|
| 30 |
+
subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
|
| 31 |
+
|
| 32 |
+
os.environ["CUDA_HOME"] = "/usr/local/cuda"
|
| 33 |
+
os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
|
| 34 |
+
os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
|
| 35 |
+
os.environ["CUDA_HOME"],
|
| 36 |
+
"" if "LD_LIBRARY_PATH" not in os.environ else os.environ["LD_LIBRARY_PATH"],
|
| 37 |
+
)
|
| 38 |
+
# Fix: arch_list[-1] += '+PTX'; IndexError: list index out of range
|
| 39 |
+
os.environ["TORCH_CUDA_ARCH_LIST"] = "9.0"
|
| 40 |
+
print("==> finished installation")
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
install_cuda_toolkit()
|
| 44 |
+
|
| 45 |
# Utility to select first image from a folder
|
| 46 |
def first_image_from_dir(directory):
|
| 47 |
patterns = ["*.jpg", "*.png", "*.jpeg"]
|