Skip to content

Commit 38b03c6

Browse files
committed
Fix for an import error caused by ultralytics
1 parent d27f500 commit 38b03c6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/attacks/evasion/test_steal_now_attack_later.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import numpy as np
2121
import pytest
2222

23-
from ultralytics import YOLO
2423
from art.attacks.evasion import SNAL
2524
from art.estimators.object_detection import PyTorchYolo
2625
from tests.utils import ARTTestException
@@ -31,8 +30,11 @@
3130
@pytest.mark.only_with_platform("pytorch")
3231
def test_generate(art_warning):
3332
try:
33+
# The ultralytics package does not support Python versions earlier than 3.8.
34+
# To avoid an import error with the TF 1.x pipeline, it is imported only within the function scope.
3435
import torch
3536
import requests
37+
from ultralytics import YOLO
3638

3739
model = YOLO("yolov8m")
3840
py_model = PyTorchYolo(model=model, input_shape=(3, 640, 640), channels_first=True, is_yolov8=True)
@@ -191,6 +193,10 @@ def _loader(self, path):
191193
@pytest.mark.only_with_platform("pytorch")
192194
def test_check_params(art_warning):
193195
try:
196+
# The ultralytics package does not support Python versions earlier than 3.8.
197+
# To avoid an import error with the TF 1.x pipeline, it is imported only within the function scope.
198+
from ultralytics import YOLO
199+
194200
model = YOLO("yolov8m")
195201
py_model = PyTorchYolo(model=model, input_shape=(3, 640, 640), channels_first=True, is_yolov8=True)
196202

0 commit comments

Comments
 (0)