-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstallUltralytics.m
101 lines (80 loc) · 2.36 KB
/
installUltralytics.m
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
92
93
94
95
96
97
98
99
100
101
arch = computer('arch');
installLocation = string(pwd) + filesep + arch;
mkdir(installLocation)
%%
% Using https://github.com/indygreg/python-build-standalone/releases/tag/20211017
pyVersion = "3.11";
switch arch
case 'glnxa64'
% zstd is not a standard install :(
pySource = 'https://github.com/indygreg/python-build-standalone/releases/download/20230826/cpython-3.11.5+20230826-x86_64_v2-unknown-linux-gnu-install_only.tar.gz';
case 'win64'
pySource = "https://github.com/indygreg/python-build-standalone/releases/download/20230826/cpython-3.11.5+20230826-x86_64-pc-windows-msvc-shared-install_only.tar.gz";
case 'maca64'
Error('Installation not supported');
end
%% Download Python
disp("Downloading Python: " + pyVersion)
pydlLoc = websave(installLocation+filesep+"pydl", pySource);
%% Extract Python
tic
disp("Extracting Python: " + pydlLoc)
untar(pydlLoc, installLocation);
delete(pydlLoc)
toc
%% Save to settings
if ispc
pyInterpreter = installLocation+filesep+"python\python";
else
pyInterpreter = installLocation+filesep+"python/bin/python3.11";
end
if ispc
pipPath = installLocation+filesep+"python\pip3";
else
pipPath = installLocation+filesep+"python/bin/pip3";
end
pyModules = installLocation+filesep+"modules";
s = settings;
if ~hasGroup(s, 'python')
addGroup(s,'python');
end
if hasSetting(s.python,"Python")
s.python.Python.PersonalValue = pyInterpreter;
else
addSetting(s.python,"Python","PersonalValue",pyInterpreter);
end
%% Install Ultralytics using pip
disp("Downloading and installing Ultralytics and it's dependencies: Take ~5 mins")
tic
[status, cmdout] = system(pyInterpreter...
+" -m pip install ultralytics==8.2.66");
if status==0
disp('Done')
else
disp(cmdout)
end
[status, cmdout] = system(pyInterpreter...
+" -m pip install dill==0.3.8");
if status==0
disp('Done')
else
disp(cmdout)
end
[status, cmdout] = system(pyInterpreter...
+" -m pip install onnx==1.16.1");
if status==0
disp('Done')
else
disp(cmdout)
end
toc
if ispc
!win64\python\Scripts\ultralytics.exe settings datasets_dir=datasets
else
!./glnxa64/python/bin/ultralytics settings datasets_dir=datasets
end
terminate(pyenv);
pyenv(Version=pyInterpreter,ExecutionMode="OutOfProcess")
if isunix
py.sys.setdlopenflags(int32(bitor(int64(py.os.RTLD_LAZY),int64(py.os.RTLD_DEEPBIND))));
end