YoloV8 deploy (EXE/WINDOWS) #1356
-
Hi, currently have a model trained, working correctly, with an user interface using Tkinter for Python.. im using linux but my target audience use windows so need create an exe, i already try with pyinstaller but doesn't work... any solution or option for create an executable app with a yolov8 predictor running inside... thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 16 comments 59 replies
-
Have you packaged the code with pyinstaller in Windows? |
Beta Was this translation helpful? Give feedback.
-
I'm having an issue with running an application in .exe format that i've exported. After launching, a lot of text appears on the black console, and the last line contains an error message: Additionally, I have a separate weight file for a network named "best.pt". Everything works fine in the project and I'm using the import command for the network: |
Beta Was this translation helpful? Give feedback.
-
@SanNnnn8 Have you solved the problem? I meet the same problem. |
Beta Was this translation helpful? Give feedback.
-
I too encountered the same error while converting my application into an EXE file and landed on this page. The advice from @dh031200 was particularly useful. Today, I'd like to share an alternative solution that I found. For context, I am using pyinstaller, YOLO v8, and Tkinter on a Windows system. Step 1: Install Required Libraries
Step 2: Edit the Pyinstaller spec File
Step 3: Package Using the spec File
Step 4: Let's make sure your program works. Conclusion I hope this helps. Feel free to use it as a reference. |
Beta Was this translation helpful? Give feedback.
-
Hey |
Beta Was this translation helpful? Give feedback.
-
How to solve this problem, |
Beta Was this translation helpful? Give feedback.
-
Hello, I've tried to generate a standalone .exe of my Yolov8 project with a Python graphical interface, but I haven't been entirely successful. When I create the .exe, a folder called _internal is generated (which seems to contain folders for each library), and without this folder in the same directory, it cannot be executed. For example, if I drag the .exe to the desktop, it no longer works and throws a file path error. Here's what I've done:
script.spec-- mode: python ; coding: utf-8 --import sys ultra_files = collect_data_files('ultralytics') block_cipher = None a = Analysis(
I don't think de script.py content is important but here it is: import os Function to get the path of the bundled best.pt filedef resource_path(relative_path): Initialize YOLO model with the bundled best.ptmodel_path = resource_path("best.pt") Function to load and process imagedef load_image():
Setup GUIroot = tk.Tk() canvas = tk.Canvas(root, width=800, height=600) load_button = tk.Button(root, text="Load Image", command=load_image) root.mainloop() |
Beta Was this translation helpful? Give feedback.
-
Seems like it is not working anymore for me
I used this line:
pyinstaller.exe --icon=bisturi.ico divider.py --onefile
And when executing got this
Traceback (most recent call last):
File "divider.py", line 2, in <module>
import playsolver
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "playsolver.py", line 1, in <module>
from ultralytics import YOLO
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\__init__.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\hub\__init__.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\hub\auth.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\hub\utils.py", line 14, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\yolo\__init__.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\yolo\v8\__init__.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\yolo\v8\classify\__init__.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\yolo\v8\classify\predict.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\yolo\engine\predictor.py", line 37, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\nn\__init__.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\nn\tasks.py", line 10, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\nn\modules\__init__.py", line 20, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\nn\modules\head.py", line 12, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "ultralytics\yolo\utils\__init__.py", line 314, in <module>
File "ultralytics\yolo\utils\__init__.py", line 287, in yaml_load
FileNotFoundError: [Errno 2] No such file or directory:
'C:\\Users\\fluff\\AppData\\Local\\Temp\\_MEI245522\\ultralytics\\yolo\\cfg\\default.yaml'
[21100] Failed to execute script 'divider' due to unhandled exception!
…On Tue, May 21, 2024 at 7:05 PM Paula Derrenger ***@***.***> wrote:
@fluffytid <https://github.com/fluffytid> hi Eduardo,
It sounds like you're encountering issues with dependencies when moving
your executable created with PyInstaller. One common solution is to ensure
that all necessary files are included in the single executable. You can
specify additional files or directories to be included in the build using
the --add-data option in PyInstaller.
Here's a basic example of how you might use this option:
pyinstaller --onefile --add-data 'path/to/internal/folder;internal/folder' your_script.py
This command tells PyInstaller to include the 'internal folder' in the
root of the executable. Adjust the paths according to your project
structure.
If the issue persists, consider checking the PyInstaller hooks for your
libraries, or manually specifying paths in your code to be relative to the
executable path.
Hope this helps!
—
Reply to this email directly, view it on GitHub
<#1356 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIPOYUZCXLM5AYZ4AYDM7NLZDN5GNAVCNFSM6AAAAAAVVYN3MCVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TKMJRGIZTS>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
hello , I have a problem with pyinstaller and my script.It has been written with pyside2(pyqt5) and when the exported exe from script runs, it seems good until it comes to from ultralytics import yolo , it crashes down with no warning!. I appreciate any suggestion or guide to export an exe file for my script. |
Beta Was this translation helpful? Give feedback.
-
Hi there, I having a problem with my script, I followed the instructions of above but when I make the .exe file and modify the .spec file, my .exe won't run, it opens the console but it closes immediately in 5 seconds, how can I solve this problem? (also I make my own training model) |
Beta Was this translation helpful? Give feedback.
-
How to separate the predicted functional code from each other |
Beta Was this translation helpful? Give feedback.
-
Hello @glenn-jocher |
Beta Was this translation helpful? Give feedback.
-
I have been using auto-py-to-exe to build executable files for GUL applications for a long time, and it has been working well for me. To build your own GUI applications, simply add the ultralytics file to the additional files and select your main.py file. |
Beta Was this translation helpful? Give feedback.
Have you packaged the code with pyinstaller in Windows?
If not I recommend using pyinstaller in a Windows environment.