diff --git a/MangaManager/MangaManagerCuda.spec b/MangaManager/MangaManagerCuda.spec index 5b7d1e3..30e2a84 100644 --- a/MangaManager/MangaManagerCuda.spec +++ b/MangaManager/MangaManagerCuda.spec @@ -1,3 +1,5 @@ +# from update_version import update_version_file +# update_version_file() from MangaManager.src.__version__ import __version__ as version_ from platform import system from datetime import date @@ -13,7 +15,9 @@ release_name = "_".join( str(datetime.now().minute).zfill(2), str(datetime.now().second).zfill(2), system(), build_version, "_Cuda"]) +# from PyInstaller.utils.hooks import collect_all +# datas = collect_all('open_clip') a = Analysis( ['main.py'], pathex=[], @@ -23,10 +27,8 @@ a = Analysis( ('ExternalSources', 'ExternalSources'), ('Extensions', 'Extensions'), # THe following are picked from env variable. Please run python to include possible missing files - ('../venv_3.11/Lib/site-packages/sv_ttk/*','sv_ttk'), # To save the sv_ttk.tcl file - MISSING IMPORT - ('../venv_3.11/Lib/site-packages/sv_ttk/theme*','sv_ttk/theme'), # To save the sv_ttk.tcl file - MISSING IMPORT - ('../venv_3.11/Lib/site-packages/open_clip/model_configs/ViT-B-16-plus-240.json','open_clip/model_configs'), # To save the sv_ttk.tcl file - MISSING IMPORT - ('../venv_3.11/Lib/site-packages/open_clip/bpe_simple_vocab_16e6.txt.gz','open_clip') # To save the sv_ttk.tcl file - MISSING IMPORT + ('../.venv/Lib/site-packages/open_clip/model_configs/ViT-B-16-plus-240.json','open_clip/model_configs'), # To save the sv_ttk.tcl file - MISSING IMPORT + ('../.venv/Lib/site-packages/open_clip/bpe_simple_vocab_16e6.txt.gz','open_clip') # To save the sv_ttk.tcl file - MISSING IMPORT ], hiddenimports=['PIL._tkinter_finder','tkinterdnd2.TkinterDnD','slugify'], diff --git a/MangaManager/MangaManagerNoCuda.spec b/MangaManager/MangaManagerNoCuda.spec index 53cb7fc..6c7a30d 100644 --- a/MangaManager/MangaManagerNoCuda.spec +++ b/MangaManager/MangaManagerNoCuda.spec @@ -1,3 +1,5 @@ +# from update_version import update_version_file +# update_version_file() import os import pathlib import platform @@ -12,6 +14,7 @@ if platform.system() == "Windows": venv_path = VENV + "/Lib" else: venv_path = VENV + "/lib/python3.11" + release_name = "_".join( ["MangaManager", str(build_date.year), @@ -21,8 +24,9 @@ release_name = "_".join( str(datetime.now().minute).zfill(2), str(datetime.now().second).zfill(2), system(), build_version, "_NoCuda"]) -open_clip_libs = [(venv_path + '/site-packages/open_clip/model_configs/ViT-B-16-plus-240.json','open_clip/model_configs'), # To save the sv_ttk.tcl file - MISSING IMPORT - (venv_path + '/site-packages/open_clip/bpe_simple_vocab_16e6.txt.gz','open_clip')] if pathlib.Path(venv_path,"site-packages","open_clip").exists() else [] # To save the sv_ttk.tcl file - MISSING IMPORT], +open_clip_libs = [] + # (venv_path + '/site-packages/open_clip/model_configs/ViT-B-16-plus-240.json','open_clip/model_configs'), # To save the sv_ttk.tcl file - MISSING IMPORT + # (venv_path + '/site-packages/open_clip/bpe_simple_vocab_16e6.txt.gz','open_clip')] if pathlib.Path(venv_path,"site-packages","open_clip").exists() else [] # To save the sv_ttk.tcl file - MISSING IMPORT], a = Analysis( ['main.py'], pathex=[], @@ -31,19 +35,16 @@ a = Analysis( ( 'res/*', 'res'), ('ExternalSources', 'ExternalSources'), ('Extensions', 'Extensions'), - # THe following are picked from env variable. Please run python to include possible missing files - (venv_path + '/site-packages/sv_ttk/*','sv_ttk'), # To save the sv_ttk.tcl file - MISSING IMPORT - (venv_path + '/site-packages/sv_ttk/theme*','sv_ttk/theme'), # To save the sv_ttk.tcl file - MISSING IMPORT ] + open_clip_libs, hiddenimports=['PIL._tkinter_finder','tkinterdnd2.TkinterDnD','slugify'], hookspath=['MangaManager/pyinstaller_hooks'], hooksconfig={}, runtime_hooks=[], - excludes=['torch','numpy','cv2'''], + excludes=['torch','numpy','cv2','open_clip','torchvision','torchaudio','tensorflow'], win_no_prefer_redirects=False, win_private_assemblies=False, noarchive=False, - paths=[venv_path +"/site-packages"] # So it loads libraries from dev env first + # paths=[venv_path +"/site-packages"] # So it loads libraries from dev env first # collect_all=True ) diff --git a/MangaManager/src/MetadataManager/CoverManager/torchlib.py b/MangaManager/src/MetadataManager/CoverManager/torchlib.py index d362b6c..d482515 100644 --- a/MangaManager/src/MetadataManager/CoverManager/torchlib.py +++ b/MangaManager/src/MetadataManager/CoverManager/torchlib.py @@ -1,16 +1,21 @@ -import logging - +""" # pip requirements: # OpenCV-Python # sentence_transformers # open_clip_torch # requests # git+https://github.com/openai/CLIP.git +# torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 + +""" +import logging + + logger = logging.getLogger() try: - raise ImportError + # raise ImportError import PIL import torch import open_clip @@ -23,6 +28,8 @@ logger.info("Torch libraries successfully imported") # image processing model device = "cuda" if torch.cuda.is_available() else "cpu" + if device == "cuda": + logger.warning("Using CUDA") model, _, preprocess = open_clip.create_model_and_transforms('ViT-B-16-plus-240', pretrained="laion400m_e32") model.to(device) def imageEncoder(img): @@ -50,6 +57,7 @@ def convert_PIL(pil_img: PIL.Image.Image): return cvtColor(array(pil_img), COLOR_BGR2RGB) except ImportError: logger.warning("Missing dependecies for torch. disabling similarity") + logger.exception("Please install") def convert_PIL(*_):