-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
91 lines (80 loc) · 2.58 KB
/
setup.py
File metadata and controls
91 lines (80 loc) · 2.58 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# setup.py
from setuptools import setup, find_packages
import platform
import subprocess
import torch
# Function to detect OS and GPU type
def detect_gpu_or_acceleration():
try:
# Check for NVIDIA GPU
result = subprocess.run(["nvidia-smi"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if result.returncode == 0:
return "NVIDIA"
except FileNotFoundError:
pass
try:
# Check for AMD GPU
result = subprocess.run(["rocm-smi"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if result.returncode == 0:
return "AMD"
except FileNotFoundError:
pass
if platform.system() == "Darwin":
# Check for MPS (Metal Performance Shaders) support on macOS
if torch.backends.mps.is_available():
return "MPS"
return "NONE"
# Get the acceleration type (GPU or MPS)
acceleration_type = detect_gpu_or_acceleration()
# Specify dependencies based on OS and acceleration type
if platform.system() == "Windows" and acceleration_type == "NVIDIA":
torch_dependencies = [
"torch==2.5.1+cu126",
"torchvision==0.20.1+cu126",
"torchaudio==2.5.1+cu126",
]
elif platform.system() == "Windows" and acceleration_type == "AMD":
torch_dependencies = [
"torch==2.5.1+rocm5.5",
"torchvision==0.20.1+rocm5.5",
"torchaudio==2.5.1+rocm5.5",
]
elif platform.system() == "Darwin" and acceleration_type == "MPS":
torch_dependencies = [
"torch>=2.5.1,<3.0.0", # Standard PyTorch works with MPS
"torchvision>=0.20.0,<0.21.0",
"torchaudio>=2.5.0,<3.0.0",
]
else:
# Default CPU dependencies
torch_dependencies = [
"torch>=2.5.1,<3.0.0",
"torchvision>=0.20.0,<0.21.0",
"torchaudio>=2.5.0,<3.0.0",
]
# General dependencies
general_dependencies = [
"Pillow>=11.1.0,<12.0.0",
"transformers>=4.48.0,<5.0.0",
]
# Combine dependencies
dependencies = general_dependencies + torch_dependencies
setup(
name="AltTextGenerator",
version="1.0.0",
description="A Python tool to generate alt text for images using the BLIP2 model.",
author="fvarghese99",
url="https://github.com/fvarghese99/AltTextGenerator",
packages=find_packages(),
python_requires=">=3.12", # Require Python 3.12 or above
install_requires=dependencies,
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
entry_points={
"console_scripts": [
"alttextgenerator=src.main:main",
],
},
)