-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
45 lines (42 loc) · 1.43 KB
/
setup.py
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
from setuptools import setup, find_packages
import subprocess
def check_gpu_availability():
"""Check if a GPU is available and return the appropriate ONNX Runtime package."""
try:
# Try to run a command that checks for GPU availability
# The 'nvidia-smi' command is specific to NVIDIA GPUs.
subprocess.check_output(['nvidia-smi'])
return 'onnxruntime-gpu'
except (subprocess.CalledProcessError, FileNotFoundError):
# If the command fails, assume no GPU is available
return 'onnxruntime'
# Determine the correct ONNX Runtime package
onnx_runtime_package = check_gpu_availability()
setup(
name='ton_ocr',
version='0.2.3',
packages=find_packages(),
install_requires=[
'numpy',
'opencv-python',
onnx_runtime_package, # Conditionally install the appropriate ONNX Runtime
'shapely',
'pyclipper'
],
package_data={
'ton_ocr': [
'models/text_detection.onnx',
'models/text_recognition.onnx',
'rec/ppocr_keys_v1.txt',
], # Include the ONNX files
},
description='A description of your project',
author='Tung Nguyen',
author_email='[email protected]',
url='https://github.com/tungedng2710/TonAI-OCR',
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
],
)