Search code examples
pytorchpyinstallerdetectronlayout-parser

torch error : NameError name 'name' is not defined


I'm currently attempting to create an executable using PyInstaller, but I've encountered an error : NameError: name 'name' is not defined caused by the line of code below.

model = lp.Detectron2LayoutModel('lp://PubLayNet/faster_rcnn_R_50_FPN_3x/config',extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.8],label_map={0: "Text", 1: "Title", 2: "List", 3: "Table", 4: "Figure"}) 

enter image description here

Can you provide guidance on resolving this issue


Solution

  • Go to the file torch_numpy\ufuncs.py, and change the loop containing name with the following loop:

    for name in _binary:
        ufunc = getattr(_binary_ufuncs_impl, name)
        ufunc_name = name  
        vars()[ufunc_name] = deco_binary_ufunc(ufunc)
    

    And this one too :

    for name in _unary:
        ufunc = getattr(_unary_ufuncs_impl, name)
        #vars()[name] = deco_unary_ufunc(ufunc)
        ufunc_name = name  # Définir une variable avec le nom de l'ufunc
        vars()[ufunc_name] = deco_binary_ufunc(ufunc)