Spaces:
Runtime error
Runtime error
import os | |
import subprocess | |
def run_command(command,shell="/bin/bash"): | |
try: | |
subprocess.run(command, check=True, shell=True) | |
print(f"Successfully ran command: {command}") | |
except subprocess.CalledProcessError as e: | |
print(f"Error running command {command}: {e}") | |
def main(): | |
# Create virtual environment | |
run_command("python -m venv maskdino_env") | |
# Activate the virtual environment | |
# Note: The activation command differs between Windows and Unix systems | |
if os.name == 'nt': | |
activate_command = ".\\maskdino_env\\Scripts\\activate" | |
else: | |
activate_command = "source maskdino_env/bin/activate" | |
run_command(activate_command) | |
# Install PyTorch, torchvision | |
run_command("pip install torch==1.9.0 torchvision==0.10.0") | |
# Install OpenCV | |
run_command("pip install opencv-python") | |
# Clone and install Detectron2 | |
run_command("git clone https://github.com/facebookresearch/detectron2") | |
os.chdir("detectron2") | |
run_command("pip install -e .") | |
run_command("pip install git+https://github.com/cocodataset/panopticapi") | |
run_command("pip install git+https://github.com/mcordts/cityscapesScripts") | |
run_command("pip install --upgrade pip") | |
os.chdir("..") | |
# Clone and setup MaskDINO | |
run_command("git clone https://github.com/IDEA-Research/MaskDINO.git") | |
os.chdir("MaskDINO") | |
run_command("pip install -r requirements.txt") | |
# Compile CUDA kernel for MSDeformAttn | |
os.chdir("maskdino/modeling/pixel_decoder/ops") | |
run_command("sh make.sh") | |
# Optionally, build on a system without a GPU | |
# Uncomment the line below if needed | |
# run_command("TORCH_CUDA_ARCH_LIST='8.0' FORCE_CUDA=1 python setup.py build install") | |
if __name__ == "__main__": | |
main() |