@@ -162,70 +162,12 @@ def restricted_getattr(obj, name, *args):
162162 from numpy import dtype
163163 from numpy .dtypes import Float64DType
164164 except :
165- logging .error ("[Impact Subpack] installed 'numpy' is outdated. Please update 'numpy' to 1.26.4" )
166- raise Exception ("[Impact Subpack] installed 'numpy' is outdated. Please update 'numpy' to 1.26.4" )
165+ logging .error ("[Impact Subpack] installed 'numpy' is outdated. Please update 'numpy>= 1.26.4' " )
166+ raise Exception ("[Impact Subpack] installed 'numpy' is outdated. Please update 'numpy>= 1.26.4' " )
167167
168168
169169 torch_whitelist = []
170170
171- # https://github.com/comfyanonymous/ComfyUI/issues/5516#issuecomment-2466152838
172- def build_torch_whitelist ():
173- """
174- For security, only a limited set of namespaces is allowed during loading.
175-
176- Since the same module may be identified by different namespaces depending on the model,
177- some modules are additionally registered with aliases to ensure backward compatibility.
178- """
179- global torch_whitelist
180-
181- for name , obj in inspect .getmembers (modules ):
182- if inspect .isclass (obj ) and obj .__module__ .startswith ("ultralytics.nn.modules" ):
183- aliasObj = type (name , (obj ,), {})
184- aliasObj .__module__ = "ultralytics.nn.modules"
185-
186- torch_whitelist .append (obj )
187- torch_whitelist .append (aliasObj )
188-
189- for name , obj in inspect .getmembers (block_modules ):
190- if inspect .isclass (obj ) and obj .__module__ .startswith ("ultralytics.nn.modules" ):
191- aliasObj = type (name , (obj ,), {})
192- aliasObj .__module__ = "ultralytics.nn.modules.block"
193-
194- torch_whitelist .append (obj )
195- torch_whitelist .append (aliasObj )
196-
197- for name , obj in inspect .getmembers (loss_modules ):
198- if inspect .isclass (obj ) and obj .__module__ .startswith ("ultralytics.utils.loss" ):
199- aliasObj = type (name , (obj ,), {})
200- aliasObj .__module__ = "ultralytics.yolo.utils.loss"
201-
202- torch_whitelist .append (obj )
203- torch_whitelist .append (aliasObj )
204-
205- for name , obj in inspect .getmembers (torch_modules ):
206- if inspect .isclass (obj ) and obj .__module__ .startswith ("torch.nn.modules" ):
207- torch_whitelist .append (obj )
208-
209- aliasIterableSimpleNamespace = type ("IterableSimpleNamespace" , (IterableSimpleNamespace ,), {})
210- aliasIterableSimpleNamespace .__module__ = "ultralytics.yolo.utils"
211-
212- aliasTaskAlignedAssigner = type ("TaskAlignedAssigner" , (TaskAlignedAssigner ,), {})
213- aliasTaskAlignedAssigner .__module__ = "ultralytics.yolo.utils.tal"
214-
215- aliasYOLOv10DetectionModel = type ("YOLOv10DetectionModel" , (DetectionModel ,), {})
216- aliasYOLOv10DetectionModel .__module__ = "ultralytics.nn.tasks"
217- aliasYOLOv10DetectionModel .__name__ = "YOLOv10DetectionModel"
218-
219- aliasv10DetectLoss = type ("v10DetectLoss" , (loss_modules .E2EDetectLoss ,), {})
220- aliasv10DetectLoss .__name__ = "v10DetectLoss"
221- aliasv10DetectLoss .__module__ = "ultralytics.utils.loss"
222-
223- torch_whitelist += [DetectionModel , aliasYOLOv10DetectionModel , SegmentationModel , IterableSimpleNamespace ,
224- aliasIterableSimpleNamespace , TaskAlignedAssigner , aliasTaskAlignedAssigner , aliasv10DetectLoss ,
225- restricted_getattr , dill ._dill ._load_type , scalar , dtype , Float64DType ]
226-
227- build_torch_whitelist ()
228-
229171except Exception as e :
230172 logging .error (e )
231173 logging .error ("\n !!!!!\n \n [ComfyUI-Impact-Subpack] If this error occurs, please check the following link:\n \t https://github.com/ltdrdata/ComfyUI-Impact-Pack/blob/Main/troubleshooting/TROUBLESHOOTING.md\n \n !!!!!\n " )
@@ -372,22 +314,8 @@ def torch_wrapper(*args, **kwargs):
372314
373315
374316def load_yolo (model_path : str ):
375- # https://github.com/comfyanonymous/ComfyUI/issues/5516#issuecomment-2466152838
376- if hasattr (torch .serialization , 'safe_globals' ):
377- with torch .serialization .safe_globals (torch_whitelist ):
378- try :
379- return YOLO (model_path )
380- except ModuleNotFoundError :
381- # https://github.com/ultralytics/ultralytics/issues/3856
382- YOLO ("yolov8n.pt" )
383- return YOLO (model_path )
384- else :
385- try :
386- return YOLO (model_path )
387- except ModuleNotFoundError :
388- YOLO ("yolov8n.pt" )
389- return YOLO (model_path )
390-
317+ return YOLO (model_path )
318+
391319
392320def inference_bbox (
393321 model ,
0 commit comments