yansong1616 commited on
Commit
faca4a5
1 Parent(s): 378f315

Upload setup.py

Browse files
Files changed (1) hide show
  1. setup.py +73 -0
setup.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+
4
+ # This source code is licensed under the license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ from setuptools import find_packages, setup
8
+ from torch.utils.cpp_extension import BuildExtension, CUDAExtension
9
+
10
+ # Package metadata
11
+ NAME = "SAM 2"
12
+ VERSION = "1.0"
13
+ DESCRIPTION = "SAM 2: Segment Anything in Images and Videos"
14
+ URL = "https://github.com/facebookresearch/segment-anything-2"
15
+ AUTHOR = "Meta AI"
16
+ AUTHOR_EMAIL = "segment-anything@meta.com"
17
+ LICENSE = "Apache 2.0"
18
+
19
+ # Read the contents of README file
20
+ with open("README.md", "r") as f:
21
+ LONG_DESCRIPTION = f.read()
22
+
23
+ # Required dependencies
24
+ REQUIRED_PACKAGES = [
25
+ "torch>=2.3.1",
26
+ "torchvision>=0.18.1",
27
+ "numpy>=1.24.4",
28
+ "tqdm>=4.66.1",
29
+ "hydra-core>=1.3.2",
30
+ "iopath>=0.1.10",
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
+ )