Spaces:
Sleeping
Sleeping
yansong1616
commited on
Commit
•
99c3d60
1
Parent(s):
faca4a5
Update setup.py
Browse files
setup.py
CHANGED
@@ -1,73 +1,30 @@
|
|
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 |
-
"pillow>=9.4.0",
|
32 |
-
]
|
33 |
-
|
34 |
-
EXTRA_PACKAGES = {
|
35 |
-
"demo": ["matplotlib>=3.9.1", "jupyter>=1.0.0", "opencv-python>=4.7.0"],
|
36 |
-
"dev": ["black==24.2.0", "usort==1.0.2", "ufmt==2.0.0b2"],
|
37 |
-
}
|
38 |
-
|
39 |
-
|
40 |
-
def get_extensions():
|
41 |
-
srcs = ["sam2/csrc/connected_components.cu"]
|
42 |
-
compile_args = {
|
43 |
-
"cxx": [],
|
44 |
-
"nvcc": [
|
45 |
-
"-DCUDA_HAS_FP16=1",
|
46 |
-
"-D__CUDA_NO_HALF_OPERATORS__",
|
47 |
-
"-D__CUDA_NO_HALF_CONVERSIONS__",
|
48 |
-
"-D__CUDA_NO_HALF2_OPERATORS__",
|
49 |
-
"-allow-unsupported-compiler",
|
50 |
-
],
|
51 |
-
}
|
52 |
-
ext_modules = [CUDAExtension("sam2._C", srcs, extra_compile_args=compile_args)]
|
53 |
-
return ext_modules
|
54 |
-
|
55 |
-
|
56 |
-
# Setup configuration
|
57 |
-
setup(
|
58 |
-
name=NAME,
|
59 |
-
version=VERSION,
|
60 |
-
description=DESCRIPTION,
|
61 |
-
long_description=LONG_DESCRIPTION,
|
62 |
-
long_description_content_type="text/markdown",
|
63 |
-
url=URL,
|
64 |
-
author=AUTHOR,
|
65 |
-
author_email=AUTHOR_EMAIL,
|
66 |
-
license=LICENSE,
|
67 |
-
packages=find_packages(exclude="notebooks"),
|
68 |
-
install_requires=REQUIRED_PACKAGES,
|
69 |
-
extras_require=EXTRA_PACKAGES,
|
70 |
-
python_requires=">=3.10.0",
|
71 |
-
ext_modules=get_extensions(),
|
72 |
-
cmdclass={"build_ext": BuildExtension.with_options(no_python_abi_suffix=True)},
|
73 |
-
)
|
|
|
1 |
+
from setuptools import find_packages, setup
|
2 |
+
from torch.utils.cpp_extension import BuildExtension, CppExtension
|
3 |
+
|
4 |
+
def get_extensions():
|
5 |
+
# 使用 CPU 的 C++ 扩展
|
6 |
+
srcs = ["sam2/csrc/connected_components.cpp"] # 使用 `.cpp` 文件而不是 `.cu` 文件
|
7 |
+
compile_args = {
|
8 |
+
"cxx": [],
|
9 |
+
# nvcc 编译器标志可以删除或注释掉
|
10 |
+
# "nvcc": [
|
11 |
+
# "-DCUDA_HAS_FP16=1",
|
12 |
+
# "-D__CUDA_NO_HALF_OPERATORS__",
|
13 |
+
# "-D__CUDA_NO_HALF_CONVERSIONS__",
|
14 |
+
# "-D__CUDA_NO_HALF2_OPERATORS__",
|
15 |
+
# "-allow-unsupported-compiler",
|
16 |
+
# ],
|
17 |
+
}
|
18 |
+
# 使用 CppExtension 而不是 CUDAExtension
|
19 |
+
ext_modules = [CppExtension("sam2._C", srcs, extra_compile_args=compile_args["cxx"])]
|
20 |
+
return ext_modules
|
21 |
+
|
22 |
+
# Setup configuration
|
23 |
+
setup(
|
24 |
+
name="SAM2",
|
25 |
+
version="1.0",
|
26 |
+
description="SAM 2: Segment Anything in Images and Videos",
|
27 |
+
packages=find_packages(),
|
28 |
+
ext_modules=get_extensions(),
|
29 |
+
cmdclass={"build_ext": BuildExtension.with_options(no_python_abi_suffix=True)},
|
30 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|