Я пытаюсь преобразовать проект глубокого обучения на основе GUI в файл .exe, ниже приведена программа python, которую я хочу преобразовать:
from numpy import *
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image
from tkinter import *
from PIL import ImageTk, Image
from tkinter import filedialog
from tkinter.ttk import *
def wrt(st,fname):
file = open(fname,"w+")
file.write(st)
file.close()
def red(fname):
file = open(fname,"r")
f=file.read()
file.close()
return f
def open_img():
try:
x = openfilename()
wrt(x,"upload");print(x);
img =Image.open(x)
except:
x = 'error.png'
print(x);
img =Image.open(x)
img = img.resize((325, 200), Image.ANTIALIAS)
img = ImageTk.PhotoImage(img)
panel = Label(root, image = img)
panel.image = img
panel.place(x=455, y=100)
def toggle ():
global shown
if shown: l.grid_remove ()
else: l.grid ()
shown = not shown
def openfilename():
filename = filedialog.askopenfilename(title ='"pen')
return filename
def callback():
cell="\n IMAGE FILE NOT UPLOADED..."
try:
model = load_model('a95e25model.h5')
#model.summary()
test_image=image.load_img(red("upload"),target_size=(50,50,3))
#imgplot = plt.imshow(test_image)
#plt.show()
test_image=image.img_to_array(test_image)
test_image=expand_dims(test_image,axis=0)
result = model.predict(test_image)
cell="PARASITIZED" if result[0][1]==1 else "UNINFECTED"
output.set("\n "+cell+" CELL DETECTED !\n");print(cell)
except:
output.set(cell);print("EXCEPTION")
root = Tk()
root.title("R2J")
output=StringVar();
root.attributes('-fullscreen',True)
#root.geometry("500x500")
#root['bg'] = 'black'
background = PhotoImage(file = "cover.png")
Label(root,image = background).place(x=0, y=0)
#root.resizable(width = True, height = True)
img =Image.open("input.png")
img = img.resize((325, 200), Image.ANTIALIAS)
img = ImageTk.PhotoImage(img)
panel = Label(root, image = img)
panel.image = img
panel.place(x=455, y=100)
upload = PhotoImage(file = r"upload.png")
Button(root, text = "upload",image = upload,
command = open_img).place(x=150, y=150)
Label(root, text="\n OUTPUT\n",
width=25,
font=("Bauhaus 93", 20)).place(x=432, y=335)
Label(root, text="",textvariable = output,
font=("Bauhaus 93", 20)).place(x=432, y=335)
detect = PhotoImage(file = r"detect.png")
Button(root, text="detect",image = detect,
command = callback).place(x=150,y=340)
close = PhotoImage(file = r"close.png")
Button(root, text = "close",image = close,
command = root.destroy).place(x=0,y=0)
root.mainloop()
Я ранее преобразовал обычный tkinter программы в .exe-файлы успешно, используя pyinstaller, но после преобразования вышеупомянутой программы полученный exe-файл не работает должным образом.
Использовалась следующая команда:
pyinstaller -y "D:/Project/MINOR_PROJECT/application_bc.py"
Это вывод cmd:
Running auto-py-to-exe v2.6.6
Building in the current instances temporary directory at C:\Users\KIIT\AppData\Local\Temp\tmpq0upgcxw
To get a new temporary directory, restart this application
Recursion Limit is set to 5000
Executing: pyinstaller -y "D:/Project/MINOR_PROJECT/application_bc.py"
15980 INFO: PyInstaller: 3.6
15980 INFO: Python: 3.7.6 (conda)
15982 INFO: Platform: Windows-10-10.0.18362-SP0
15986 INFO: wrote C:\Users\KIIT\AppData\Local\Temp\tmpq0upgcxw\application_bc.spec
15991 INFO: UPX is not available.
16004 INFO: Extending PYTHONPATH with paths
['D:\\Project\\MINOR_PROJECT',
'C:\\Users\\KIIT\\AppData\\Local\\Temp\\tmpq0upgcxw']
16005 INFO: checking Analysis
16007 INFO: Building Analysis because Analysis-00.toc is non existent
16008 INFO: Initializing module dependency graph...
16061 INFO: Caching module graph hooks...
16103 INFO: Analyzing base_library.zip ...
23459 INFO: Caching module dependency graph...
23703 INFO: running Analysis Analysis-00.toc
23840 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by d:\software\anaconda\python.exe
25665 INFO: Analyzing D:\Project\MINOR_PROJECT\application_bc.py
30354 INFO: Processing pre-find module path hook distutils
30362 INFO: distutils: retargeting to non-venv dir 'd:\\software\\anaconda\\lib'
31324 INFO: Processing pre-find module path hook site
31326 INFO: site: retargeting to fake-dir 'd:\\software\\anaconda\\lib\\site-packages\\PyInstaller\\fake-modules'
38369 INFO: Processing pre-safe import module hook setuptools.extern.six.moves
65797 INFO: Processing pre-safe import module hook six.moves
112365 INFO: Processing pre-safe import module hook urllib3.packages.six.moves
342724 INFO: Processing module hooks...
342724 INFO: Loading module hook "hook-babel.py"...
343057 INFO: Loading module hook "hook-certifi.py"...
343061 INFO: Loading module hook "hook-cryptography.py"...
343965 INFO: Loading module hook "hook-distutils.py"...
343982 INFO: Loading module hook "hook-docutils.py"...
349828 INFO: Loading module hook "hook-encodings.py"...
350051 INFO: Loading module hook "hook-gevent.py"...
350598 INFO: Determining a mapping of distributions to packages...
537892 WARNING: Unable to find package for requirement greenlet from package gevent.
537893 INFO: Packages required by gevent:
['cffi']
543345 INFO: Loading module hook "hook-h5py.py"...
543357 INFO: Loading module hook "hook-importlib_metadata.py"...
543366 INFO: Loading module hook "hook-IPython.py"...
546173 INFO: Excluding import 'gtk'
546186 INFO: Excluding import 'tkinter'
546212 INFO: Removing import of tkinter from module IPython.lib.clipboard
546224 INFO: Excluding import 'PyQt4'
546249 INFO: Removing import of PyQt4 from module IPython.external.qt_loaders
546255 INFO: Excluding import 'matplotlib'
546291 INFO: Removing import of matplotlib.pyplot from module IPython.core.pylabtools
546292 INFO: Removing import of matplotlib._pylab_helpers from module IPython.core.pylabtools
546295 INFO: Removing import of matplotlib from module IPython.core.pylabtools
546296 INFO: Removing import of matplotlib.backend_bases from module IPython.core.pylabtools
546296 INFO: Removing import of matplotlib.figure from module IPython.core.pylabtools
546299 INFO: Excluding import 'PyQt5'
546335 INFO: Removing import of PyQt5.QtCore from module IPython.external.qt_loaders
546336 INFO: Removing import of PyQt5.QtSvg from module IPython.external.qt_loaders
546336 INFO: Removing import of PyQt5.QtWidgets from module IPython.external.qt_loaders
546336 INFO: Removing import of PyQt5 from module IPython.external.qt_loaders
546336 INFO: Removing import of PyQt5.QtGui from module IPython.external.qt_loaders
546338 INFO: Excluding import 'PySide'
546354 INFO: Removing import of PySide from module IPython.external.qt_loaders
546357 INFO: Loading module hook "hook-jedi.py"...
546947 INFO: Loading module hook "hook-jinja2.py"...
546992 INFO: Loading module hook "hook-jsonschema.py"...
547088 INFO: Loading module hook "hook-lib2to3.py"...
547108 INFO: Loading module hook "hook-lxml.etree.py"...
547112 INFO: Loading module hook "hook-matplotlib.backends.py"...
549314 INFO: Matplotlib backend "GTK3Agg": ignored
cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
550154 INFO: Matplotlib backend "GTK3Cairo": ignored
cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
551573 INFO: Matplotlib backend "MacOSX": ignored
cannot import name '_macosx' from 'matplotlib.backends' (d:\software\anaconda\lib\site-packages\matplotlib\backends\__init__.py)
553684 INFO: Matplotlib backend "nbAgg": added
556155 INFO: Matplotlib backend "Qt4Agg": added
557042 INFO: Matplotlib backend "Qt4Cairo": ignored
cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
558324 INFO: Matplotlib backend "Qt5Agg": added
559173 INFO: Matplotlib backend "Qt5Cairo": ignored
cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
560491 INFO: Matplotlib backend "TkAgg": added
561653 INFO: Matplotlib backend "TkCairo": ignored
cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
563075 INFO: Matplotlib backend "WebAgg": added
564179 INFO: Matplotlib backend "WX": ignored
No module named 'wx'
565061 INFO: Matplotlib backend "WXAgg": ignored
No module named 'wx'
565866 INFO: Matplotlib backend "WXCairo": ignored
No module named 'wx'
566692 INFO: Matplotlib backend "agg": added
567514 INFO: Matplotlib backend "cairo": ignored
cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
568681 INFO: Matplotlib backend "pdf": added
569873 INFO: Matplotlib backend "pgf": added
570790 INFO: Matplotlib backend "ps": added
571635 INFO: Matplotlib backend "svg": added
572696 INFO: Matplotlib backend "template": added
573851 INFO: Loading module hook "hook-matplotlib.py"...
574669 INFO: Loading module hook "hook-nacl.py"...
574683 INFO: Loading module hook "hook-nbconvert.py"...
574751 INFO: Loading module hook "hook-nbformat.py"...
574774 INFO: Loading module hook "hook-notebook.py"...
579038 INFO: Loading module hook "hook-numpy.core.py"...
579275 INFO: MKL libraries found when importing numpy. Adding MKL to binaries
579284 INFO: Loading module hook "hook-numpy.py"...
579286 INFO: Loading module hook "hook-openpyxl.py"...
579298 INFO: Loading module hook "hook-pandas.py"...
581160 INFO: Loading module hook "hook-PIL.Image.py"...
582591 INFO: Loading module hook "hook-PIL.py"...
582604 INFO: Import to be excluded not found: 'FixTk'
582605 INFO: Excluding import 'tkinter'
582615 INFO: Removing import of tkinter from module PIL.ImageTk
582617 INFO: Excluding import 'PyQt4'
582641 INFO: Excluding import 'PyQt5'
582666 INFO: Removing import of PyQt5.QtGui from module PIL.ImageQt
582667 INFO: Removing import of PyQt5.QtCore from module PIL.ImageQt
582668 INFO: Excluding import 'PySide'
582684 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
582694 INFO: Import to be excluded not found: 'FixTk'
582698 INFO: Excluding import 'tkinter'
582719 INFO: Loading module hook "hook-pkg_resources.py"...
584351 INFO: Processing pre-safe import module hook win32com
585416 INFO: Excluding import '__main__'
585425 INFO: Removing import of __main__ from module pkg_resources
585428 INFO: Loading module hook "hook-pycparser.py"...
585429 INFO: Loading module hook "hook-pydoc.py"...
585430 INFO: Loading module hook "hook-pygments.py"...
590428 INFO: Loading module hook "hook-PyQt5.py"...
591714 WARNING: Hidden import "PyQt5.sip" not found!
591714 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
592077 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
592598 INFO: Loading module hook "hook-PyQt5.QtSvg.py"...
593861 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
594315 INFO: Loading module hook "hook-pytest.py"...
597382 INFO: Loading module hook "hook-pythoncom.py"...
598733 INFO: Loading module hook "hook-pytz.py"...
598989 INFO: Loading module hook "hook-pywintypes.py"...
600256 INFO: Loading module hook "hook-scipy.linalg.py"...
600258 INFO: Loading module hook "hook-scipy.py"...
600290 INFO: Loading module hook "hook-scipy.sparse.csgraph.py"...
600310 INFO: Loading module hook "hook-scipy.special._ellip_harm_2.py"...
600311 INFO: Loading module hook "hook-scipy.special._ufuncs.py"...
600313 INFO: Loading module hook "hook-setuptools.py"...
602622 INFO: Loading module hook "hook-sphinx.py"...
616547 INFO: Loading module hook "hook-sqlalchemy.py"...
617429 INFO: Found 4 sqlalchemy hidden imports
617433 WARNING: Hidden import "MySQLdb" not found!
617436 WARNING: Hidden import "psycopg2" not found!
622852 WARNING: Hidden import "sqlalchemy.sql.functions.func" not found!
622860 INFO: Import to be excluded not found: 'sqlalchemy.testing'
622861 INFO: Loading module hook "hook-sqlite3.py"...
623106 INFO: Loading module hook "hook-sysconfig.py"...
623109 INFO: Loading module hook "hook-tables.py"...
623111 INFO: Loading module hook "hook-win32com.py"...
623464 INFO: Loading module hook "hook-xml.dom.domreg.py"...
623478 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
623485 INFO: Loading module hook "hook-xml.py"...
623487 INFO: Loading module hook "hook-zmq.py"...
626581 INFO: Loading module hook "hook-_tkinter.py"...
627022 INFO: checking Tree
627022 INFO: Building Tree because Tree-00.toc is non existent
627023 INFO: Building Tree Tree-00.toc
627113 INFO: checking Tree
627114 INFO: Building Tree because Tree-01.toc is non existent
627114 INFO: Building Tree Tree-01.toc
627581 INFO: Looking for ctypes DLLs
628148 INFO: Analyzing run-time hooks ...
628207 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
628229 INFO: Including run-time hook 'pyi_rth_pkgres.py'
628238 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
628242 INFO: Including run-time hook 'pyi_rth__tkinter.py'
628244 INFO: Including run-time hook 'pyi_rth_traitlets.py'
628247 INFO: Including run-time hook 'pyi_rth_certifi.py'
628253 INFO: Including run-time hook 'pyi_rth_pyqt5.py'
628255 INFO: Including run-time hook 'pyi_rth_mplconfig.py'
628259 INFO: Including run-time hook 'pyi_rth_mpldata.py'
628363 INFO: Looking for dynamic libraries
628914 WARNING: lib not found: mpich2mpi.dll dependency of d:\software\anaconda\Library\bin\mkl_blacs_mpich2_ilp64.dll
630475 WARNING: lib not found: mpich2mpi.dll dependency of d:\software\anaconda\Library\bin\mkl_blacs_mpich2_lp64.dll
630504 WARNING: lib not found: msmpi.dll dependency of d:\software\anaconda\Library\bin\mkl_blacs_msmpi_ilp64.dll
631238 WARNING: lib not found: pgf90.dll dependency of d:\software\anaconda\Library\bin\mkl_pgi_thread.dll
631242 WARNING: lib not found: pgc14.dll dependency of d:\software\anaconda\Library\bin\mkl_pgi_thread.dll
631243 WARNING: lib not found: pgf90rtl.dll dependency of d:\software\anaconda\Library\bin\mkl_pgi_thread.dll
632694 WARNING: lib not found: impi.dll dependency of d:\software\anaconda\Library\bin\mkl_blacs_intelmpi_ilp64.dll
633223 WARNING: lib not found: impi.dll dependency of d:\software\anaconda\Library\bin\mkl_blacs_intelmpi_lp64.dll
633233 WARNING: lib not found: msmpi.dll dependency of d:\software\anaconda\Library\bin\mkl_blacs_msmpi_lp64.dll
639939 INFO: Looking for eggs
639940 INFO: Using Python library d:\software\anaconda\python37.dll
639940 INFO: Found binding redirects:
[]
640024 INFO: Warnings written to C:\Users\KIIT\AppData\Local\Temp\tmpq0upgcxw\build\application_bc\warn-application_bc.txt
641436 INFO: Graph cross-reference written to C:\Users\KIIT\AppData\Local\Temp\tmpq0upgcxw\build\application_bc\xref-application_bc.html
642775 INFO: checking PYZ
642776 INFO: Building PYZ because PYZ-00.toc is non existent
642777 INFO: Building PYZ (ZlibArchive) C:\Users\KIIT\AppData\Local\Temp\tmpq0upgcxw\build\application_bc\PYZ-00.pyz
654420 INFO: Building PYZ (ZlibArchive) C:\Users\KIIT\AppData\Local\Temp\tmpq0upgcxw\build\application_bc\PYZ-00.pyz completed successfully.
654617 INFO: checking PKG
654618 INFO: Building PKG because PKG-00.toc is non existent
654619 INFO: Building PKG (CArchive) PKG-00.pkg
654815 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
654817 INFO: Bootloader d:\software\anaconda\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
654818 INFO: checking EXE
654818 INFO: Building EXE because EXE-00.toc is non existent
654818 INFO: Building EXE from EXE-00.toc
654819 INFO: Appending archive to EXE C:\Users\KIIT\AppData\Local\Temp\tmpq0upgcxw\build\application_bc\application_bc.exe
654838 INFO: Building EXE from EXE-00.toc completed successfully.
654885 INFO: checking COLLECT
654886 INFO: Building COLLECT because COLLECT-00.toc is non existent
654889 INFO: Building COLLECT COLLECT-00.toc
771763 INFO: Building COLLECT COLLECT-00.toc completed successfully.
Moving project to: D:\Project\MINOR_PROJECT\output
Complete.