PyInstaller Issue: torchvision\io\image.py:13 UserWarning and Continuous Reloading

337 views Asked by At

I am currently working on a Python project involving FastAPI, PyTorch, and torchvision. I have successfully developed my application and it works as expected in my development environment. However, when I use PyInstaller to compile my application into an executable (.exe),

I encounter a UserWarning in the torchvision\io\image.py module:

torchvision\io\image.py:13: UserWarning: Failed to load image Python extension: ''If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?
torch\_jit_internal.py:857: UserWarning: Unable to retrieve source for @torch.jit._overload function: <function _DenseLayer.forward at 0x00000210ADB52660>.
  warnings.warn(
torch\_jit_internal.py:857: UserWarning: Unable to retrieve source for @torch.jit._overload function: <function _DenseLayer.forward at 0x00000210ADB52700>.
  warnings.warn(

including the DLLs directly in PyInstaller is not resolving the issue

a = Analysis(
['src\\main.py'],
pathex=[],
binaries = [
('C:\\Users\\jafha\\anaconda3\\pkgs\\libpng-1.6.39-h19919ed_0\\Library\\bin\\libpng16.dll', '.'),
('C:\\Users\\jafha\\anaconda3\\pkgs\\jpeg-9e-h2bbff1b_1\\Library\\bin\\libjpeg.dll', '.')],
datas=[],
hiddenimports=[***],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=excluded_modules,
noarchive=False,

)

and i try to using monkey path from this https://github.com/pytorch/vision/issues/1899

def script_method(fn, _rcb=None):
return fn
def script(obj, optimize=True, _frames_up=0, _rcb=None):
    return obj

import torch.jit
torch.jit.script_method = script_method 
torch.jit.script = script

i follow this solution but not working

0

There are 0 answers