diff --git a/4c_6c_regression.pt b/4c_6c_regression.pt deleted file mode 100644 index f0471117437bd625786fc310fda9fd7f1a114e53..0000000000000000000000000000000000000000 --- a/4c_6c_regression.pt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:158f2a49f42e9e3ef40c12de1d86ddff9465f834cb8c006bb38a3fd6a8f99b15 -size 5998089 diff --git a/app.py b/app.py index 532a79560552863ef2966f9734fb59cfd10582df..1cfe6600589a33245f1429317e5f9e794fe0dd2d 100644 --- a/app.py +++ b/app.py @@ -29,7 +29,7 @@ except Exception as e: ndvi_model = None try: - yolo_model = load_yolo_model("4c_6c_regression.pt") + yolo_model = load_yolo_model("best_yolo_model.pt") logger.info("YOLO model loaded successfully") except Exception as e: logger.error(f"Failed to load YOLO model: {e}") diff --git a/best_yolo_model.pt b/best_yolo_model.pt new file mode 100644 index 0000000000000000000000000000000000000000..9d20312ea2be77a088057187f94e6613ed83b009 --- /dev/null +++ b/best_yolo_model.pt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5be2b24cd635b1e8f6e6b56f0ec49ba7751f627439670597807cec7e6f6fdf3e +size 45153455 diff --git a/ultralytics/__pycache__/__init__.cpython-312.pyc b/ultralytics/__pycache__/__init__.cpython-312.pyc index f15b6272a66cb709419eca787e281a41508c62fb..caa54c782d478991c3504f30aa3fca6c10d7977c 100644 Binary files a/ultralytics/__pycache__/__init__.cpython-312.pyc and b/ultralytics/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/cfg/__pycache__/__init__.cpython-312.pyc b/ultralytics/cfg/__pycache__/__init__.cpython-312.pyc index ca402190e279bc24c5ef003ba41c67ebfbdfeafe..963ca79383fc53b2616516d2373c17f60122e342 100644 Binary files a/ultralytics/cfg/__pycache__/__init__.cpython-312.pyc and b/ultralytics/cfg/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/data/__pycache__/__init__.cpython-312.pyc b/ultralytics/data/__pycache__/__init__.cpython-312.pyc index 9a938fc3207c2c29bbca9bb7e1d843ff7d461480..6dce6f5f024852de79420b675cb0fb806c004fb1 100644 Binary files a/ultralytics/data/__pycache__/__init__.cpython-312.pyc and b/ultralytics/data/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/data/__pycache__/augment.cpython-312.pyc b/ultralytics/data/__pycache__/augment.cpython-312.pyc index 19fda87df8e8a45742bbcc578bbc9a7254260587..4ddb47b8bcc100e45c107ee9730419150a342cc1 100644 --- a/ultralytics/data/__pycache__/augment.cpython-312.pyc +++ b/ultralytics/data/__pycache__/augment.cpython-312.pyc @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e072113c34b0a95bcb988e80f9d25235235c73fdb7319f0221e197c4a50779d9 +oid sha256:9f7f6b212a14a5068a553d00be673361718d528f2e6b2e324ea2a2e113a00191 size 139583 diff --git a/ultralytics/data/__pycache__/base.cpython-312.pyc b/ultralytics/data/__pycache__/base.cpython-312.pyc index e50e9ceb550f4e291d5502d4c8a347ea065f1e1d..843d43eb1ff9fbaaa932f9462b8c9f6e853db0ae 100644 Binary files a/ultralytics/data/__pycache__/base.cpython-312.pyc and b/ultralytics/data/__pycache__/base.cpython-312.pyc differ diff --git a/ultralytics/data/__pycache__/build.cpython-312.pyc b/ultralytics/data/__pycache__/build.cpython-312.pyc index cea187c5f94c1101120807de4e9fc4dc0e73ad8c..0dc68d94dfbfcc7444bf1f1204aa38e09f07ffe3 100644 Binary files a/ultralytics/data/__pycache__/build.cpython-312.pyc and b/ultralytics/data/__pycache__/build.cpython-312.pyc differ diff --git a/ultralytics/data/__pycache__/converter.cpython-312.pyc b/ultralytics/data/__pycache__/converter.cpython-312.pyc index 88b47603dc544a79276c80c31020440167ebf0d8..905b7fb6021f91d10efd452c816193ff58209227 100644 Binary files a/ultralytics/data/__pycache__/converter.cpython-312.pyc and b/ultralytics/data/__pycache__/converter.cpython-312.pyc differ diff --git a/ultralytics/data/__pycache__/dataset.cpython-312.pyc b/ultralytics/data/__pycache__/dataset.cpython-312.pyc index 1d8c35645445da8ad69f13082ffee02debc416a8..fad6fa248069cf9be016b1318d05a3c931a8cbbf 100644 Binary files a/ultralytics/data/__pycache__/dataset.cpython-312.pyc and b/ultralytics/data/__pycache__/dataset.cpython-312.pyc differ diff --git a/ultralytics/data/__pycache__/loaders.cpython-312.pyc b/ultralytics/data/__pycache__/loaders.cpython-312.pyc index fbfe6f2c1910163edb61d473ae82776582ef4449..1ef923e8fa48f8d18aac017159f3689fdfd74e26 100644 Binary files a/ultralytics/data/__pycache__/loaders.cpython-312.pyc and b/ultralytics/data/__pycache__/loaders.cpython-312.pyc differ diff --git a/ultralytics/data/__pycache__/utils.cpython-312.pyc b/ultralytics/data/__pycache__/utils.cpython-312.pyc index e36193347505e59b9b144bb2a193822154226dea..34ec372d4708cf982805c5a5c6d6e723cc9e144a 100644 Binary files a/ultralytics/data/__pycache__/utils.cpython-312.pyc and b/ultralytics/data/__pycache__/utils.cpython-312.pyc differ diff --git a/ultralytics/data/augment.py b/ultralytics/data/augment.py index d1802aab41431f6cfbf12436b0d9a2c29120a549..d65c8523b02b165e385e6fa9cc8bb6b58eb09dfc 100644 --- a/ultralytics/data/augment.py +++ b/ultralytics/data/augment.py @@ -1541,7 +1541,12 @@ class LetterBox: self.stride = stride self.center = center # Put the image in the middle or top-left - def __call__(self, labels=None, image=None): + def __call__(self, labels=None, image=None): # gets image during inference (1544, 2064, 4) but not during validation + # during validation, labels["img"].shape = (479, 640, 4) + # function returns labels with labels["img"].shape = (512, 672, 4) + + # during inference the image is already provided, image.shape = (1544, 2064, 4) + # returns image with image.shape = (480, 640, 4) """ Resizes and pads an image for object detection, instance segmentation, or pose estimation tasks. diff --git a/ultralytics/data/base.py b/ultralytics/data/base.py index be3350ce7ee4e825d45575574281eb51e84cfc54..5467cfb8f106800b52df73166c0286b74ac9059e 100644 --- a/ultralytics/data/base.py +++ b/ultralytics/data/base.py @@ -160,8 +160,10 @@ class BaseDataset(Dataset): LOGGER.warning(f"{self.prefix}WARNING ⚠️ Removing corrupt *.npy image file {fn} due to: {e}") Path(fn).unlink(missing_ok=True) im = cv2.imread(f, cv2.IMREAD_UNCHANGED) # Load with all channels, including NDVI if present + # assert 0, '=========== Read unchanged image =============' else: # read image im = cv2.imread(f, cv2.IMREAD_UNCHANGED) # Load with all channels, including NDVI if present + # assert 0, '=========== Read unchanged image =============' if im is None: raise FileNotFoundError(f"Image Not Found {f}") @@ -208,6 +210,7 @@ class BaseDataset(Dataset): f = self.npy_files[i] if not f.exists(): np.save(f.as_posix(), cv2.imread(self.im_files[i], cv2.IMREAD_UNCHANGED), allow_pickle=False) + # assert 0, '=========== Read unchanged image =============' def check_cache_disk(self, safety_margin=0.5): @@ -219,6 +222,7 @@ class BaseDataset(Dataset): for _ in range(n): im_file = random.choice(self.im_files) im = cv2.imread(im_file, cv2.IMREAD_UNCHANGED) # Load with all channels, including NDVI if present + # assert 0, '=========== Read unchanged image =============' if im is None: continue b += im.nbytes @@ -244,6 +248,7 @@ class BaseDataset(Dataset): n = min(self.ni, 30) # extrapolate from 30 random images for _ in range(n): im = cv2.imread(random.choice(self.im_files), cv2.IMREAD_UNCHANGED) # sample image + # assert 0, '=========== Read unchanged image =============' if im is None: continue ratio = self.imgsz / max(im.shape[0], im.shape[1]) # max(h, w) # ratio diff --git a/ultralytics/data/dataset.py b/ultralytics/data/dataset.py index a5a13e4a4f52fbcb52b970b7876390ef0a08c165..6da1a06554482d3c4be264e4fcd2b9c1949320d2 100644 --- a/ultralytics/data/dataset.py +++ b/ultralytics/data/dataset.py @@ -560,12 +560,15 @@ class ClassificationDataset: if self.cache_ram: if im is None: # Warning: two separate if statements required here, do not combine this with previous line im = self.samples[i][3] = cv2.imread(f, cv2.IMREAD_UNCHANGED) + # assert 0, '=========== Read unchanged image =============' elif self.cache_disk: if not fn.exists(): # load npy np.save(fn.as_posix(), cv2.imread(f, cv2.IMREAD_UNCHANGED), allow_pickle=False) + # assert 0, '=========== Read unchanged image =============' im = np.load(fn) else: # read image im = cv2.imread(f, cv2.IMREAD_UNCHANGED) # BGR + # assert 0, '=========== Read unchanged image =============' # Convert NumPy array to PIL image im = Image.fromarray(cv2.cvtColor(im, cv2.COLOR_BGR2RGB)) sample = self.torch_transforms(im) diff --git a/ultralytics/data/loaders.py b/ultralytics/data/loaders.py index 5e649d3ec843a351dded35925d45c91e250a35b3..b6db7d5aabcf229380d647205422b0d68f2e925e 100644 --- a/ultralytics/data/loaders.py +++ b/ultralytics/data/loaders.py @@ -585,14 +585,37 @@ class LoadTensor: return self.bs -def autocast_list(source): +def autocast_list(source): # this function (as per experimentation) isn't called during validation or training, just inference """Merges a list of sources into a list of numpy arrays or PIL images for Ultralytics prediction.""" files = [] # assert 0, f'in def autocast_list() source: {source}' + # import itertools for im in source: if isinstance(im, (str, Path)): # filename or uri # assert 0, f'im -> isinstance(im, (str, Path)) = True im= {im}' - files.append(Image.open(requests.get(im, stream=True).raw if str(im).startswith("http") else im)) + # assert 0, 'is the same func used in validation?' + # if str(im).startswith("http"): + # files.append(Image.open(requests.get(im, stream=True).raw if str(im).startswith("http") else im)) + + # pilimg = Image.open(requests.get(im, stream=True).raw if str(im).startswith("http") else im) + # orig_np_im = np.array(pilimg) + + # for perm in itertools.permutations([0, 1, 2, 3]): + # np_im = orig_np_im[..., perm] + # # np_im = np.ascontiguousarray(np_im) + # files.append(Image.fromarray(np_im)) + + # np_im = orig_np_im[..., (0, 3, 2, 1)] + # np_im = np.ascontiguousarray(np_im) + # files.append(np_im) + if str(im).startswith("http"): + img = Image.open(requests.get(im, stream=True).raw) + else: + img = cv2.imread(im, cv2.IMREAD_UNCHANGED) + img = np.array(img) + img = img[..., (3,2,1,0)] + img = np.ascontiguousarray(img) + files.append(img) elif isinstance(im, (Image.Image, np.ndarray)): # PIL or np Image files.append(im) else: @@ -605,7 +628,7 @@ def autocast_list(source): # import numpy as np # np_arr = np.array(files[0]) # print(f'np_arr.shape: {np_arr.shape}') - # assert 0, 'bye bye sucker' + # assert 0, 'bye bye' return files diff --git a/ultralytics/engine/__pycache__/__init__.cpython-312.pyc b/ultralytics/engine/__pycache__/__init__.cpython-312.pyc index 6e88315446ba9b1ab10accabe9cc9599bb50269e..5ff325da99d84542d65084bc4781d217bb3ad1bb 100644 Binary files a/ultralytics/engine/__pycache__/__init__.cpython-312.pyc and b/ultralytics/engine/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/engine/__pycache__/exporter.cpython-312.pyc b/ultralytics/engine/__pycache__/exporter.cpython-312.pyc index 15623bdfa5115d5fa9a19bd0ec7940d54e9b0fde..0a53dcbbe9eaa4c5fa0b852503cc512a865a1268 100644 --- a/ultralytics/engine/__pycache__/exporter.cpython-312.pyc +++ b/ultralytics/engine/__pycache__/exporter.cpython-312.pyc @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d43eee4a96cf869121d1bc528ae7c8eed58d0f81baea7930b416f4a122dcf549 +oid sha256:b45eb6f61fa73af51b7cc3a8f73f05a4692f429d0d123cacdc8ee2af11704d11 size 101374 diff --git a/ultralytics/engine/__pycache__/model.cpython-312.pyc b/ultralytics/engine/__pycache__/model.cpython-312.pyc index 4d6631f77cfe6682c62e97b08204d7c67c3d9e7e..feb72116576f3bf86028698f946fc84457dd559a 100644 Binary files a/ultralytics/engine/__pycache__/model.cpython-312.pyc and b/ultralytics/engine/__pycache__/model.cpython-312.pyc differ diff --git a/ultralytics/engine/__pycache__/predictor.cpython-312.pyc b/ultralytics/engine/__pycache__/predictor.cpython-312.pyc index 40ce3b425c66531903831b9d17922a0b8c82d25e..e0ec21920fc001a6ab33a4a6b20dbd501d7a909a 100644 Binary files a/ultralytics/engine/__pycache__/predictor.cpython-312.pyc and b/ultralytics/engine/__pycache__/predictor.cpython-312.pyc differ diff --git a/ultralytics/engine/__pycache__/results.cpython-312.pyc b/ultralytics/engine/__pycache__/results.cpython-312.pyc index b5f6323a0d6670f5377970eea00eb9204248b1f6..5c6e139ce933a3e5f4b50263bd6c7cd202aff28f 100644 Binary files a/ultralytics/engine/__pycache__/results.cpython-312.pyc and b/ultralytics/engine/__pycache__/results.cpython-312.pyc differ diff --git a/ultralytics/engine/__pycache__/trainer.cpython-312.pyc b/ultralytics/engine/__pycache__/trainer.cpython-312.pyc index 6b068cd057591c7ee1ad82efe8f10b135e259967..cdf62f290956481055dba4aa82146afa883affc8 100644 Binary files a/ultralytics/engine/__pycache__/trainer.cpython-312.pyc and b/ultralytics/engine/__pycache__/trainer.cpython-312.pyc differ diff --git a/ultralytics/engine/__pycache__/validator.cpython-312.pyc b/ultralytics/engine/__pycache__/validator.cpython-312.pyc index a308cda4a2c7af77d5eebf180a94e5850ff5f633..cda32722b659ba5c6f425f6d7eda5e74266ef1f2 100644 Binary files a/ultralytics/engine/__pycache__/validator.cpython-312.pyc and b/ultralytics/engine/__pycache__/validator.cpython-312.pyc differ diff --git a/ultralytics/engine/model.py b/ultralytics/engine/model.py index 0416a2365efeaa7ad065d9064e4cd38d2c036928..fe4bf4261638f7f186cc9b98599532f99e5c40e6 100644 --- a/ultralytics/engine/model.py +++ b/ultralytics/engine/model.py @@ -639,7 +639,7 @@ class Model(torch.nn.Module): args = {**self.overrides, **custom, **kwargs, "mode": "val"} # highest priority args on the right validator = (validator or self._smart_load("validator"))(args=args, _callbacks=self.callbacks) - validator(model=self.model) + validator(model=self.model) # everything during validation happens here self.metrics = validator.metrics return validator.metrics diff --git a/ultralytics/engine/predictor.py b/ultralytics/engine/predictor.py index f6aa67be4a3390f1720e1dc283d8a253d55f198e..d3a76aeb4dd5f3b4bbfcb1fbcfb79c34dd8f62d1 100644 --- a/ultralytics/engine/predictor.py +++ b/ultralytics/engine/predictor.py @@ -117,7 +117,7 @@ class BasePredictor: self._lock = threading.Lock() # for automatic thread-safe inference callbacks.add_integration_callbacks(self) - def preprocess(self, im): + def preprocess(self, im): # this preprocess is called during inference # assert 0, 'def preprocess() called in predictory.py file' # the line above confirmed that this function is not called during # model.train() or model.val() @@ -140,9 +140,37 @@ class BasePredictor: im = np.stack(self.pre_transform(im)) print(f'im.shape : {im.shape} in def preprocess() predictor.py after self.pre_transform()') - # im = im[..., ::-1].transpose((0, 3, 1, 2)) # BGR to RGB, BHWC to BCHW, (n, 3, h, w) - im = im[..., [2, 1, 0, 3]].transpose((0, 3, 1, 2)) # adjusted to handle NDVI band. [B, G, R, NDVI] to [R, G, B, NDVI] - # the transpose formats BHWC to BCHW + # im = im[..., ::-1].transpose((0, 3, 1, 2)) # BGR to RGB, BHWC to BCHW, (n, 3, h, w) + # im = im.transpose((0, 3, 1, 2)) # BGR to RGB, BHWC to BCHW, (n, 3, h, w) + + im = im.transpose((0, 3, 1, 2)) # adjusted to handle NDVI band. [B, G, R, NDVI] to [R, G, B, NDVI] + # im = im[..., [0, 1, 2, 3]].transpose((0, 3, 1, 2)) # adjusted to handle NDVI band. [B, G, R, NDVI] to [R, G, B, NDVI] + + # im = im[..., [0, 1, 2, 3]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [0, 1, 3, 2]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [0, 2, 1, 3]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [0, 2, 3, 1]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [0, 3, 1, 2]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [0, 3, 2, 1]].transpose((0, 3, 1, 2)) # ✅❌ + # im = im[..., [1, 0, 2, 3]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [1, 0, 3, 2]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [1, 2, 0, 3]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [1, 2, 3, 0]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [1, 3, 0, 2]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [1, 3, 2, 0]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [2, 0, 1, 3]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [2, 0, 3, 1]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [2, 1, 0, 3]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [2, 1, 3, 0]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [2, 3, 0, 1]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [2, 3, 1, 0]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [3, 0, 1, 2]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [3, 0, 2, 1]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [3, 1, 0, 2]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [3, 1, 2, 0]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [3, 2, 0, 1]].transpose((0, 3, 1, 2)) # ❌ + # im = im[..., [3, 2, 1, 0]].transpose((0, 3, 1, 2)) # ❌ + im = np.ascontiguousarray(im) # contiguous # print(f'im.shape: {im.shape} in def preprocess() predictor.py') im = torch.from_numpy(im) @@ -276,6 +304,22 @@ class BasePredictor: # print(f'l276 pred.py im0s[0].shape: {im0s[0].shape}') im = self.preprocess(im0s) + # preds[0].shape + # torch.Size([1, 43, 6300]) + + # preds[1][0][0].shape + # torch.Size([1, 71, 60, 80]) + # preds[1][0][1].shape + # torch.Size([1, 71, 30, 40]) + # preds[1][0][2].shape + # torch.Size([1, 71, 15, 20]) + + # preds[1][1][0].shape + # torch.Size([32, 6300]) + + # preds[1][2][0].shape + # torch.Size([32, 120, 160]) + # Inference with profilers[1]: preds = self.inference(im, *args, **kwargs) diff --git a/ultralytics/engine/validator.py b/ultralytics/engine/validator.py index 1b851ee14405986fbda9a6fff57f64be3d66ca1a..f0b276cf87fad9f56dff56963b10723527a18d2d 100644 --- a/ultralytics/engine/validator.py +++ b/ultralytics/engine/validator.py @@ -177,7 +177,7 @@ class BaseValidator: self.batch_i = batch_i # Preprocess with dt[0]: - batch = self.preprocess(batch) + batch = self.preprocess(batch) # preprocessing the validation data, models hasn't done anything yet # Inference with dt[1]: @@ -190,7 +190,8 @@ class BaseValidator: # Postprocess with dt[3]: - preds = self.postprocess(preds) + preds = self.postprocess(preds) # in validation, preds does not contain the correct + # length of 39 per box, 4*coords, growth_val, 6*conf per each class, class (from 0-5, owing to 6 classes), 32*masks self.update_metrics(preds, batch) if self.args.plots and batch_i < 3: diff --git a/ultralytics/hub/__pycache__/__init__.cpython-312.pyc b/ultralytics/hub/__pycache__/__init__.cpython-312.pyc index ae37dbb905b416eff01b9242e5ffc1d4d9cca9b5..27a678cd20b5c2a179fa5ea81fda18ccc0dd9e5f 100644 Binary files a/ultralytics/hub/__pycache__/__init__.cpython-312.pyc and b/ultralytics/hub/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/hub/__pycache__/auth.cpython-312.pyc b/ultralytics/hub/__pycache__/auth.cpython-312.pyc index e181fa684f59a78ee32c82ddd3cf16d37d549024..31b9ef5c88664bc72abb7de55e1f09d29a00af25 100644 Binary files a/ultralytics/hub/__pycache__/auth.cpython-312.pyc and b/ultralytics/hub/__pycache__/auth.cpython-312.pyc differ diff --git a/ultralytics/hub/__pycache__/session.cpython-312.pyc b/ultralytics/hub/__pycache__/session.cpython-312.pyc index 514c796c3981e25c621fb6b1490271a081d16939..42cad230045789ea0a0237522a023caf362455b6 100644 Binary files a/ultralytics/hub/__pycache__/session.cpython-312.pyc and b/ultralytics/hub/__pycache__/session.cpython-312.pyc differ diff --git a/ultralytics/hub/__pycache__/utils.cpython-312.pyc b/ultralytics/hub/__pycache__/utils.cpython-312.pyc index 44e0ae66c8de5a8fd1f5a44f290c9b9e3cdf2b90..6d7ef256344099b486abbb3316616c67e6f594eb 100644 Binary files a/ultralytics/hub/__pycache__/utils.cpython-312.pyc and b/ultralytics/hub/__pycache__/utils.cpython-312.pyc differ diff --git a/ultralytics/models/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/__pycache__/__init__.cpython-312.pyc index b8aec4698f69048e1a571ba411b5f09786371ae5..9c499f3838d278d8a98b9afcdbf83ff2eb47cfff 100644 Binary files a/ultralytics/models/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/fastsam/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/fastsam/__pycache__/__init__.cpython-312.pyc index 3a11f2062f120091d995fe36c9fd9011cf56b507..0906ed148a5e11a76686f10cd045d949befbe6a4 100644 Binary files a/ultralytics/models/fastsam/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/fastsam/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/fastsam/__pycache__/model.cpython-312.pyc b/ultralytics/models/fastsam/__pycache__/model.cpython-312.pyc index f1ded2c79a73dbfe42fcd0101f0f67669f4d9331..acd1687a4a7bdadbf6bef660001249511592ee63 100644 Binary files a/ultralytics/models/fastsam/__pycache__/model.cpython-312.pyc and b/ultralytics/models/fastsam/__pycache__/model.cpython-312.pyc differ diff --git a/ultralytics/models/fastsam/__pycache__/predict.cpython-312.pyc b/ultralytics/models/fastsam/__pycache__/predict.cpython-312.pyc index 1b62d3ee9406b1318c3c991490d61fd493c6f6c2..e33fdfecca569740d1ef4914088041fe4a3aea2f 100644 Binary files a/ultralytics/models/fastsam/__pycache__/predict.cpython-312.pyc and b/ultralytics/models/fastsam/__pycache__/predict.cpython-312.pyc differ diff --git a/ultralytics/models/fastsam/__pycache__/utils.cpython-312.pyc b/ultralytics/models/fastsam/__pycache__/utils.cpython-312.pyc index 331c9f66e99c7118eb1339b12f2c8fb1823944d1..579a4c3e864e1a31fe0f7bb2724259c97c555ee7 100644 Binary files a/ultralytics/models/fastsam/__pycache__/utils.cpython-312.pyc and b/ultralytics/models/fastsam/__pycache__/utils.cpython-312.pyc differ diff --git a/ultralytics/models/fastsam/__pycache__/val.cpython-312.pyc b/ultralytics/models/fastsam/__pycache__/val.cpython-312.pyc index 2bd6e7f0562ebbd98d816ee4f5e20db38ec49516..a909583f81cdbda7607b079768d270bf16ab76c2 100644 Binary files a/ultralytics/models/fastsam/__pycache__/val.cpython-312.pyc and b/ultralytics/models/fastsam/__pycache__/val.cpython-312.pyc differ diff --git a/ultralytics/models/nas/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/nas/__pycache__/__init__.cpython-312.pyc index 7ffafb28b3d301ee572ba5c9b977c26d822f3ae3..07c91b92fec84ca162b2b14c4b08346bef86d6a9 100644 Binary files a/ultralytics/models/nas/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/nas/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/nas/__pycache__/model.cpython-312.pyc b/ultralytics/models/nas/__pycache__/model.cpython-312.pyc index 0b5c9ba32cf1e12d4674bea74b746fb0c761bf94..3f2513cf4bd69a7a5526df02be48567536bd3a35 100644 Binary files a/ultralytics/models/nas/__pycache__/model.cpython-312.pyc and b/ultralytics/models/nas/__pycache__/model.cpython-312.pyc differ diff --git a/ultralytics/models/nas/__pycache__/predict.cpython-312.pyc b/ultralytics/models/nas/__pycache__/predict.cpython-312.pyc index 0ea2d2ea8a13051f4c3f49d363a57d25a45a5ce5..5be4a3e7bea73585470916aa37e6e6f9446a0559 100644 Binary files a/ultralytics/models/nas/__pycache__/predict.cpython-312.pyc and b/ultralytics/models/nas/__pycache__/predict.cpython-312.pyc differ diff --git a/ultralytics/models/nas/__pycache__/val.cpython-312.pyc b/ultralytics/models/nas/__pycache__/val.cpython-312.pyc index 8284d1256555d8338e7c8359b5ed439d5b21d2d8..054136168db660127d4b45f1130670ead368e144 100644 Binary files a/ultralytics/models/nas/__pycache__/val.cpython-312.pyc and b/ultralytics/models/nas/__pycache__/val.cpython-312.pyc differ diff --git a/ultralytics/models/rtdetr/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/rtdetr/__pycache__/__init__.cpython-312.pyc index 1aaf6e77bc9b5a8de7b158ec393ac24368b46075..4fc6ec2c133bc05938483fcceea74bf1ea7e767c 100644 Binary files a/ultralytics/models/rtdetr/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/rtdetr/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/rtdetr/__pycache__/model.cpython-312.pyc b/ultralytics/models/rtdetr/__pycache__/model.cpython-312.pyc index 7389c9e07ad32ec5c1f8552c10cfea233a606825..3d81b2d123f3a4d5a802b7d9a2a7bc5da40a816a 100644 Binary files a/ultralytics/models/rtdetr/__pycache__/model.cpython-312.pyc and b/ultralytics/models/rtdetr/__pycache__/model.cpython-312.pyc differ diff --git a/ultralytics/models/rtdetr/__pycache__/predict.cpython-312.pyc b/ultralytics/models/rtdetr/__pycache__/predict.cpython-312.pyc index d64b166ada87f22ee332e188c29ea1582611b9a8..8e04a57957a4fa6aaa1836fd960f968ee6acf377 100644 Binary files a/ultralytics/models/rtdetr/__pycache__/predict.cpython-312.pyc and b/ultralytics/models/rtdetr/__pycache__/predict.cpython-312.pyc differ diff --git a/ultralytics/models/rtdetr/__pycache__/train.cpython-312.pyc b/ultralytics/models/rtdetr/__pycache__/train.cpython-312.pyc index 4a6a6add9ad78dd668ed246c1ff26b2848339f46..caae92eb7ff2bc596f18fb1471113fa67617779b 100644 Binary files a/ultralytics/models/rtdetr/__pycache__/train.cpython-312.pyc and b/ultralytics/models/rtdetr/__pycache__/train.cpython-312.pyc differ diff --git a/ultralytics/models/rtdetr/__pycache__/val.cpython-312.pyc b/ultralytics/models/rtdetr/__pycache__/val.cpython-312.pyc index cf6b1fc4dacea021636454e08feec0c56528d139..a0a2b52de3ffa447adfe12a0ea4fb36e2737ab9c 100644 Binary files a/ultralytics/models/rtdetr/__pycache__/val.cpython-312.pyc and b/ultralytics/models/rtdetr/__pycache__/val.cpython-312.pyc differ diff --git a/ultralytics/models/sam/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/sam/__pycache__/__init__.cpython-312.pyc index 26cc27822b2740dc4630f79a1ee682b15af3ae09..f58818b88e28383e09daff274023713a191c036c 100644 Binary files a/ultralytics/models/sam/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/sam/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/sam/__pycache__/amg.cpython-312.pyc b/ultralytics/models/sam/__pycache__/amg.cpython-312.pyc index 38c37e8c95017ebe09ebd15b6038950fc70d7668..225eaeb71d1a7799fcaf142fb9c1b5007f7c8b6c 100644 Binary files a/ultralytics/models/sam/__pycache__/amg.cpython-312.pyc and b/ultralytics/models/sam/__pycache__/amg.cpython-312.pyc differ diff --git a/ultralytics/models/sam/__pycache__/build.cpython-312.pyc b/ultralytics/models/sam/__pycache__/build.cpython-312.pyc index ec1edc7c30d0d9fac84e958940cff73ad9bcbd77..c964dc74ee5338f9271faf922a5e5465c2b31702 100644 Binary files a/ultralytics/models/sam/__pycache__/build.cpython-312.pyc and b/ultralytics/models/sam/__pycache__/build.cpython-312.pyc differ diff --git a/ultralytics/models/sam/__pycache__/model.cpython-312.pyc b/ultralytics/models/sam/__pycache__/model.cpython-312.pyc index dcbabfc3a298024e63b348fa4538ba39b05d4f04..be0f452b0f74d415eb7c6b3833d0b21389cd82a6 100644 Binary files a/ultralytics/models/sam/__pycache__/model.cpython-312.pyc and b/ultralytics/models/sam/__pycache__/model.cpython-312.pyc differ diff --git a/ultralytics/models/sam/__pycache__/predict.cpython-312.pyc b/ultralytics/models/sam/__pycache__/predict.cpython-312.pyc index 578085f86031a63d151e31799bdd6a17c9dc202b..759e9e1399894495738d04be9ce80861577c59fb 100644 Binary files a/ultralytics/models/sam/__pycache__/predict.cpython-312.pyc and b/ultralytics/models/sam/__pycache__/predict.cpython-312.pyc differ diff --git a/ultralytics/models/sam/modules/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/sam/modules/__pycache__/__init__.cpython-312.pyc index 7d3cb87382fdb4f01053b0535d654ec0e037eb65..2e47fa4c4443c42e9ab87ca087f4957d4420d70d 100644 Binary files a/ultralytics/models/sam/modules/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/sam/modules/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/sam/modules/__pycache__/blocks.cpython-312.pyc b/ultralytics/models/sam/modules/__pycache__/blocks.cpython-312.pyc index aa4a1ba3425d40d3ddace50008c38db6b9c906e7..7aeabe5b194ca82a6765d62f38581158cdfeda49 100644 Binary files a/ultralytics/models/sam/modules/__pycache__/blocks.cpython-312.pyc and b/ultralytics/models/sam/modules/__pycache__/blocks.cpython-312.pyc differ diff --git a/ultralytics/models/sam/modules/__pycache__/decoders.cpython-312.pyc b/ultralytics/models/sam/modules/__pycache__/decoders.cpython-312.pyc index 9435463a9ab179c53624e248b82b670b4255c26c..f9e9967a08c11836fa2cd5b5b535b85a46a50501 100644 Binary files a/ultralytics/models/sam/modules/__pycache__/decoders.cpython-312.pyc and b/ultralytics/models/sam/modules/__pycache__/decoders.cpython-312.pyc differ diff --git a/ultralytics/models/sam/modules/__pycache__/encoders.cpython-312.pyc b/ultralytics/models/sam/modules/__pycache__/encoders.cpython-312.pyc index 1e91be3ba14f591bac4357e2b3dc31f16d6fdd78..055ad512ad55be85d76d859501a133a5b39d3d62 100644 Binary files a/ultralytics/models/sam/modules/__pycache__/encoders.cpython-312.pyc and b/ultralytics/models/sam/modules/__pycache__/encoders.cpython-312.pyc differ diff --git a/ultralytics/models/sam/modules/__pycache__/memory_attention.cpython-312.pyc b/ultralytics/models/sam/modules/__pycache__/memory_attention.cpython-312.pyc index 6fecb91d2c6778261e25239bb5c1c8eec70472ed..de36d5e1cb0b8dc28bc0d35d50b37fcc9df62c31 100644 Binary files a/ultralytics/models/sam/modules/__pycache__/memory_attention.cpython-312.pyc and b/ultralytics/models/sam/modules/__pycache__/memory_attention.cpython-312.pyc differ diff --git a/ultralytics/models/sam/modules/__pycache__/sam.cpython-312.pyc b/ultralytics/models/sam/modules/__pycache__/sam.cpython-312.pyc index 5d6ae951969314c1a7c118b8865aa0416525f490..d0c92087673c641c207c70044205cbd34231df49 100644 Binary files a/ultralytics/models/sam/modules/__pycache__/sam.cpython-312.pyc and b/ultralytics/models/sam/modules/__pycache__/sam.cpython-312.pyc differ diff --git a/ultralytics/models/sam/modules/__pycache__/tiny_encoder.cpython-312.pyc b/ultralytics/models/sam/modules/__pycache__/tiny_encoder.cpython-312.pyc index e796fdb29b1f65360026499ba45ed3347c0a60fc..1a3e53439876362d9eedefd6e1208c2bc252c59b 100644 Binary files a/ultralytics/models/sam/modules/__pycache__/tiny_encoder.cpython-312.pyc and b/ultralytics/models/sam/modules/__pycache__/tiny_encoder.cpython-312.pyc differ diff --git a/ultralytics/models/sam/modules/__pycache__/transformer.cpython-312.pyc b/ultralytics/models/sam/modules/__pycache__/transformer.cpython-312.pyc index 273fdc31095e893286a0944ffcc975358ddd4f21..ef3206012dc562d2f91fd89f4d89da8085c5034c 100644 Binary files a/ultralytics/models/sam/modules/__pycache__/transformer.cpython-312.pyc and b/ultralytics/models/sam/modules/__pycache__/transformer.cpython-312.pyc differ diff --git a/ultralytics/models/sam/modules/__pycache__/utils.cpython-312.pyc b/ultralytics/models/sam/modules/__pycache__/utils.cpython-312.pyc index e402f7cc338f0f1edc2a9782240b28e6d72bd56f..f54ab56a4b0a9bd5846d00665ac9ded9f9bf5f33 100644 Binary files a/ultralytics/models/sam/modules/__pycache__/utils.cpython-312.pyc and b/ultralytics/models/sam/modules/__pycache__/utils.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/yolo/__pycache__/__init__.cpython-312.pyc index 979b547eef4062f75aba7c6a677bcc38bfe79171..8d7deb4226426dcfbf236c9c1c2de7376e17fc3f 100644 Binary files a/ultralytics/models/yolo/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/yolo/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/__pycache__/model.cpython-312.pyc b/ultralytics/models/yolo/__pycache__/model.cpython-312.pyc index d60dfee498c83bf0836eb2ffc69ae56c7e217caa..dd8bdc3b47756bd030757900195995c9105f2a06 100644 Binary files a/ultralytics/models/yolo/__pycache__/model.cpython-312.pyc and b/ultralytics/models/yolo/__pycache__/model.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/classify/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/yolo/classify/__pycache__/__init__.cpython-312.pyc index 63ac6ca2199a8eadfbbd57e210362e6bf88c5814..bb8d2cc8d3a4a392e6ef4ac4f51a52cdd5af097c 100644 Binary files a/ultralytics/models/yolo/classify/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/yolo/classify/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/classify/__pycache__/predict.cpython-312.pyc b/ultralytics/models/yolo/classify/__pycache__/predict.cpython-312.pyc index 67f1242e267cdaf627b1993f9dc0a6901aacf28d..c4c605689df87bdf3d6f21d9d1f477028dbb79b3 100644 Binary files a/ultralytics/models/yolo/classify/__pycache__/predict.cpython-312.pyc and b/ultralytics/models/yolo/classify/__pycache__/predict.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/classify/__pycache__/train.cpython-312.pyc b/ultralytics/models/yolo/classify/__pycache__/train.cpython-312.pyc index 7bf78597ee5bc69fbd4cbd06f7a82ce8306f53ce..5fdf37efd368c89b484a1607423f9b4ec25f1c04 100644 Binary files a/ultralytics/models/yolo/classify/__pycache__/train.cpython-312.pyc and b/ultralytics/models/yolo/classify/__pycache__/train.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/classify/__pycache__/val.cpython-312.pyc b/ultralytics/models/yolo/classify/__pycache__/val.cpython-312.pyc index 0a535b5a6a39d106f09de210aa98ed71d08fd3c3..6083ada0dc3f624ab17b29dd16069c328a35ce3a 100644 Binary files a/ultralytics/models/yolo/classify/__pycache__/val.cpython-312.pyc and b/ultralytics/models/yolo/classify/__pycache__/val.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/detect/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/yolo/detect/__pycache__/__init__.cpython-312.pyc index b8f8641cef23d18831966d5e473b44969dec9871..687bee261af8b1b16a5c5f6f614ec42e7b58000b 100644 Binary files a/ultralytics/models/yolo/detect/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/yolo/detect/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/detect/__pycache__/predict.cpython-312.pyc b/ultralytics/models/yolo/detect/__pycache__/predict.cpython-312.pyc index 2db0142d60186cec58ac0eab3cd83c9e35cac92a..e37ef7ff114d1aa739fc6c752544236a5a9b41c8 100644 Binary files a/ultralytics/models/yolo/detect/__pycache__/predict.cpython-312.pyc and b/ultralytics/models/yolo/detect/__pycache__/predict.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/detect/__pycache__/train.cpython-312.pyc b/ultralytics/models/yolo/detect/__pycache__/train.cpython-312.pyc index 38b7d6c4f0692fc7ca7366853dc2f02f8dd468cf..de9681175e1c8854bf6d5d73c11ed19bd140e547 100644 Binary files a/ultralytics/models/yolo/detect/__pycache__/train.cpython-312.pyc and b/ultralytics/models/yolo/detect/__pycache__/train.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/detect/__pycache__/val.cpython-312.pyc b/ultralytics/models/yolo/detect/__pycache__/val.cpython-312.pyc index ecd725719b4b1cce7b43ba2ef98af0ac6957258d..1aea217ffdfadd1f7bb87e5ec3d16ba8785c5914 100644 Binary files a/ultralytics/models/yolo/detect/__pycache__/val.cpython-312.pyc and b/ultralytics/models/yolo/detect/__pycache__/val.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/detect/val.py b/ultralytics/models/yolo/detect/val.py index 20fbee9b175dc7ace5cd10efed786d60d94264ff..4ea34a88a3ff4202b650bec8dd7f601e5bd20cc1 100644 --- a/ultralytics/models/yolo/detect/val.py +++ b/ultralytics/models/yolo/detect/val.py @@ -51,7 +51,7 @@ class DetectionValidator(BaseValidator): """Preprocesses batch of images for YOLO training.""" batch["img"] = batch["img"].to(self.device, non_blocking=True) batch["img"] = (batch["img"].half() if self.args.half else batch["img"].float()) / 255 - for k in ["batch_idx", "cls", "bboxes"]: + for k in ["batch_idx", "cls", "bboxes", "growth_stage"]: # also move growth stage to 'device' batch[k] = batch[k].to(self.device) if self.args.save_hybrid: diff --git a/ultralytics/models/yolo/obb/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/yolo/obb/__pycache__/__init__.cpython-312.pyc index ca7ecfb7d286d52b215550bf7d8a1d578bab4293..60b0c3e74212b6ed73b84d165b53b782d27907e0 100644 Binary files a/ultralytics/models/yolo/obb/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/yolo/obb/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/obb/__pycache__/predict.cpython-312.pyc b/ultralytics/models/yolo/obb/__pycache__/predict.cpython-312.pyc index 095c3796eeee1e666da507722111489c3ae44294..f67cc938e9adc6830289ab776532e92fc01a8651 100644 Binary files a/ultralytics/models/yolo/obb/__pycache__/predict.cpython-312.pyc and b/ultralytics/models/yolo/obb/__pycache__/predict.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/obb/__pycache__/train.cpython-312.pyc b/ultralytics/models/yolo/obb/__pycache__/train.cpython-312.pyc index e76c1a05dee5d32038c5c099ba5aa940dbcd7ed5..0c3d4cb0e1f05fee09fd1878f775da6a4b996d4c 100644 Binary files a/ultralytics/models/yolo/obb/__pycache__/train.cpython-312.pyc and b/ultralytics/models/yolo/obb/__pycache__/train.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/obb/__pycache__/val.cpython-312.pyc b/ultralytics/models/yolo/obb/__pycache__/val.cpython-312.pyc index f8ed42fe223db3df7e50b3e6728d168d684cbbd5..85f75939d8ec8e3ab6d7b86e593ae3c7a5e27147 100644 Binary files a/ultralytics/models/yolo/obb/__pycache__/val.cpython-312.pyc and b/ultralytics/models/yolo/obb/__pycache__/val.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/pose/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/yolo/pose/__pycache__/__init__.cpython-312.pyc index fbf36232edb412dd095e257f1496775f049dd93d..edc06b56503fbaf49d827bfa22909c181ed0d3e2 100644 Binary files a/ultralytics/models/yolo/pose/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/yolo/pose/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/pose/__pycache__/predict.cpython-312.pyc b/ultralytics/models/yolo/pose/__pycache__/predict.cpython-312.pyc index fb2c5272ac2599067cdb12b28291d175c795a5ed..f34e6b7135fdfad3c0681acbe09126090fe2b64c 100644 Binary files a/ultralytics/models/yolo/pose/__pycache__/predict.cpython-312.pyc and b/ultralytics/models/yolo/pose/__pycache__/predict.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/pose/__pycache__/train.cpython-312.pyc b/ultralytics/models/yolo/pose/__pycache__/train.cpython-312.pyc index 1f25440494f9100cbc1de1ab8e080c05bb84655b..873f6886dcd1f5cc9b96a5e934338ee2d0432936 100644 Binary files a/ultralytics/models/yolo/pose/__pycache__/train.cpython-312.pyc and b/ultralytics/models/yolo/pose/__pycache__/train.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/pose/__pycache__/val.cpython-312.pyc b/ultralytics/models/yolo/pose/__pycache__/val.cpython-312.pyc index 1eb2dec1f9ba3dbc7bc1fff61671adc99fa26a6f..8e8ea50d0082c7ac08855a6d5ee23fb27cb1dac1 100644 Binary files a/ultralytics/models/yolo/pose/__pycache__/val.cpython-312.pyc and b/ultralytics/models/yolo/pose/__pycache__/val.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/segment/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/yolo/segment/__pycache__/__init__.cpython-312.pyc index 3baa7696d174b26cd85173264000c40ec144250c..1ecb64d1ab6152ce18b5f61df2ffb43c01e378c0 100644 Binary files a/ultralytics/models/yolo/segment/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/yolo/segment/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/segment/__pycache__/predict.cpython-312.pyc b/ultralytics/models/yolo/segment/__pycache__/predict.cpython-312.pyc index a27444bb73dd0cbdd946591dcc5c8d058a477043..20fe745ad7edf9ab2484fd1c8a07cc7692b91296 100644 Binary files a/ultralytics/models/yolo/segment/__pycache__/predict.cpython-312.pyc and b/ultralytics/models/yolo/segment/__pycache__/predict.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/segment/__pycache__/train.cpython-312.pyc b/ultralytics/models/yolo/segment/__pycache__/train.cpython-312.pyc index e7ad0924c58223922c19e1225d6355c66655a43d..caf4e6ee7537d034919c75ea0049e54f4f732f58 100644 Binary files a/ultralytics/models/yolo/segment/__pycache__/train.cpython-312.pyc and b/ultralytics/models/yolo/segment/__pycache__/train.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/segment/__pycache__/val.cpython-312.pyc b/ultralytics/models/yolo/segment/__pycache__/val.cpython-312.pyc index 1d464e8fd6811c092e10fb81eb80981981ff4386..f450c09ba20829f60fdd5f79f0aa20fd693fa329 100644 Binary files a/ultralytics/models/yolo/segment/__pycache__/val.cpython-312.pyc and b/ultralytics/models/yolo/segment/__pycache__/val.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/segment/predict.py b/ultralytics/models/yolo/segment/predict.py index 0edddac048773b25389d7583707137645a8cae76..c919b56dacc10ee4d85b6b0fde37f26fadce9cda 100644 --- a/ultralytics/models/yolo/segment/predict.py +++ b/ultralytics/models/yolo/segment/predict.py @@ -28,8 +28,8 @@ class SegmentationPredictor(DetectionPredictor): def postprocess(self, preds, img, orig_imgs): """Applies non-max suppression and processes detections for each image in an input batch.""" # tuple if PyTorch model or array if exported - protos = preds[1][-1] if isinstance(preds[1], tuple) else preds[1] - return super().postprocess(preds[0], img, orig_imgs, protos=protos) + protos = preds[1][-1] if isinstance(preds[1], tuple) else preds[1] # preds[1][-1].shape :-> torch.Size([1, 32, 120, 160]) + return super().postprocess(preds[0], img, orig_imgs, protos=protos) # preds[0].shape :-> torch.Size([1, 43, 6300]) def construct_results(self, preds, img, orig_imgs, protos): """ diff --git a/ultralytics/models/yolo/segment/val.py b/ultralytics/models/yolo/segment/val.py index b6844cd2333fc42bb3d00de376ca3e1e7de7f6e5..21232e42a05e7022b20772097eaa30fddb8ac209 100644 --- a/ultralytics/models/yolo/segment/val.py +++ b/ultralytics/models/yolo/segment/val.py @@ -84,7 +84,9 @@ class SegmentationValidator(DetectionValidator): def _prepare_pred(self, pred, pbatch, proto): """Prepares a batch for training or inference by processing images and targets.""" predn = super()._prepare_pred(pred, pbatch) - pred_masks = self.process(proto, pred[:, 6:], pred[:, :4], shape=pbatch["imgsz"]) + pred_masks = self.process(proto, pred[:, 7:], pred[:, :4], shape=pbatch["imgsz"]) # changed the '6' to '7' + # since start index of masks is one position later due to the growth stage + # 4*coords, growth_val, conf, class, 32*mask values return predn, pred_masks def update_metrics(self, preds, batch): @@ -115,17 +117,17 @@ class SegmentationValidator(DetectionValidator): gt_masks = pbatch.pop("masks") # Predictions if self.args.single_cls: - pred[:, 5] = 0 - predn, pred_masks = self._prepare_pred(pred, pbatch, proto) - stat["conf"] = predn[:, 4] - stat["pred_cls"] = predn[:, 5] + pred[:, 6] = 0 # changed to 6 since class is at index 6 now due to gs + predn, pred_masks = self._prepare_pred(pred, pbatch, proto) # corrected indexing within this function to accomodate the additional growth stage + stat["conf"] = predn[:, 5] # conf is at '5' now. '4' previuosly + stat["pred_cls"] = predn[:, 6] # conf is at '6' now. 5 previously # Evaluate if nl: - stat["tp"] = self._process_batch(predn, bbox, cls) + stat["tp"] = self._process_batch(predn, bbox, cls) # corrected too for the 'gs' stat["tp_m"] = self._process_batch( predn, bbox, cls, pred_masks, gt_masks, self.args.overlap_mask, masks=True - ) + ) # this function has been corrected too if self.args.plots: self.confusion_matrix.process_batch(predn, bbox, cls) @@ -205,12 +207,13 @@ class SegmentationValidator(DetectionValidator): else: # boxes iou = box_iou(gt_bboxes, detections[:, :4]) - return self.match_predictions(detections[:, 5], gt_cls, iou) + return self.match_predictions(detections[:, 6], gt_cls, iou) + # changed to '6' since class now lies at index '6'. was previously '5' def plot_val_samples(self, batch, ni): """Plots validation samples with bounding box labels.""" plot_images( - batch["img"], + batch["img"], # change to batch["img"][:, :3, :, :, ] batch["batch_idx"], batch["cls"].squeeze(-1), batch["bboxes"], @@ -224,7 +227,7 @@ class SegmentationValidator(DetectionValidator): def plot_predictions(self, batch, preds, ni): """Plots batch predictions with masks and bounding boxes.""" plot_images( - batch["img"], + batch["img"], # change to batch["img"][:, :3, :, :, ] *output_to_target(preds[0], max_det=15), # not set to self.args.max_det due to slow plotting speed torch.cat(self.plot_masks, dim=0) if len(self.plot_masks) else self.plot_masks, paths=batch["im_file"], diff --git a/ultralytics/models/yolo/world/__pycache__/__init__.cpython-312.pyc b/ultralytics/models/yolo/world/__pycache__/__init__.cpython-312.pyc index 0e7475afe8502131f5ca13d06d14bfe947e0fac2..5d31031dc62307735f4d97cb733df2ab4f5ab885 100644 Binary files a/ultralytics/models/yolo/world/__pycache__/__init__.cpython-312.pyc and b/ultralytics/models/yolo/world/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/models/yolo/world/__pycache__/train.cpython-312.pyc b/ultralytics/models/yolo/world/__pycache__/train.cpython-312.pyc index e96ac3d7e87deb0a1adfb710b5b206043091e387..32d7bcc33bb1aef8f8a160fcfae6d591c973860e 100644 Binary files a/ultralytics/models/yolo/world/__pycache__/train.cpython-312.pyc and b/ultralytics/models/yolo/world/__pycache__/train.cpython-312.pyc differ diff --git a/ultralytics/nn/__pycache__/__init__.cpython-312.pyc b/ultralytics/nn/__pycache__/__init__.cpython-312.pyc index 80b44066cec8f2dffe18207c1801d8bfb44d1905..d7fc87d31a0beaa045301722119d12059e2f2145 100644 Binary files a/ultralytics/nn/__pycache__/__init__.cpython-312.pyc and b/ultralytics/nn/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/nn/__pycache__/autobackend.cpython-312.pyc b/ultralytics/nn/__pycache__/autobackend.cpython-312.pyc index 2ceeb73174485999dbdfd906343b699d0e751e9f..9793b9387ecabc704d7d2c34032f71918b33c291 100644 Binary files a/ultralytics/nn/__pycache__/autobackend.cpython-312.pyc and b/ultralytics/nn/__pycache__/autobackend.cpython-312.pyc differ diff --git a/ultralytics/nn/__pycache__/tasks.cpython-312.pyc b/ultralytics/nn/__pycache__/tasks.cpython-312.pyc index 41f98d7c40bc3de85930700a9eed0c6217a6946c..63bceef0d9d8d83e0b7c68b10fd479ff549d68a5 100644 Binary files a/ultralytics/nn/__pycache__/tasks.cpython-312.pyc and b/ultralytics/nn/__pycache__/tasks.cpython-312.pyc differ diff --git a/ultralytics/nn/autobackend.py b/ultralytics/nn/autobackend.py index b17251c6d4b57915521ab71a74d88dea11f487fa..01acf997dabeab97aed8c3c9ab2e060c62b9f9fe 100644 --- a/ultralytics/nn/autobackend.py +++ b/ultralytics/nn/autobackend.py @@ -532,7 +532,7 @@ class AutoBackend(nn.Module): self.__dict__.update(locals()) # assign all variables to self - def forward(self, im, augment=False, visualize=False, embed=None): + def forward(self, im, augment=False, visualize=False, embed=None): # used during both inference and validation , preds = model(batch["img"], augment=augment) in engine/validator.py calls this """ Runs inference on the YOLOv8 MultiBackend model. @@ -552,7 +552,7 @@ class AutoBackend(nn.Module): im = im.permute(0, 2, 3, 1) # torch BCHW to numpy BHWC shape(1,320,192,3) # PyTorch - if self.pt or self.nn_module: + if self.pt or self.nn_module: # this if statement is executed during validation (on the current config, local + cpu only) y = self.model(im, augment=augment, visualize=visualize, embed=embed) # TorchScript @@ -740,7 +740,12 @@ class AutoBackend(nn.Module): if len(self.names) == 999 and (self.task == "segment" or len(y) == 2): # segments and names not defined nc = y[0].shape[1] - y[1].shape[1] - 4 # y = (1, 32, 160, 160), (1, 116, 8400) self.names = {i: f"class{i}" for i in range(nc)} - return self.from_numpy(y[0]) if len(y) == 1 else [self.from_numpy(x) for x in y] + return self.from_numpy(y[0]) if len(y) == 1 else [self.from_numpy(x) for x in y] # this is executed during validation + # len(y) + # 2 + # y[0].shape + # torch.Size([5, 43, 7056]) + else: return self.from_numpy(y) diff --git a/ultralytics/nn/modules/__pycache__/__init__.cpython-312.pyc b/ultralytics/nn/modules/__pycache__/__init__.cpython-312.pyc index d06431b8172b470bd3fdda3623b61d61b1352c06..8957536f9da97d3b97dbb0d9b84b199afe6ac404 100644 Binary files a/ultralytics/nn/modules/__pycache__/__init__.cpython-312.pyc and b/ultralytics/nn/modules/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/nn/modules/__pycache__/block.cpython-312.pyc b/ultralytics/nn/modules/__pycache__/block.cpython-312.pyc index be262c63e31205a2be075c578fb4c33da602ab6f..a19de5d61c50cc1b354dc61435259d5c346dd223 100644 Binary files a/ultralytics/nn/modules/__pycache__/block.cpython-312.pyc and b/ultralytics/nn/modules/__pycache__/block.cpython-312.pyc differ diff --git a/ultralytics/nn/modules/__pycache__/conv.cpython-312.pyc b/ultralytics/nn/modules/__pycache__/conv.cpython-312.pyc index db3f5c0732c4a60cae52e37a6890a5df1bf6d323..a4cb3ebdc45824183b403b5154c9cacbe2cbb6a6 100644 Binary files a/ultralytics/nn/modules/__pycache__/conv.cpython-312.pyc and b/ultralytics/nn/modules/__pycache__/conv.cpython-312.pyc differ diff --git a/ultralytics/nn/modules/__pycache__/head.cpython-312.pyc b/ultralytics/nn/modules/__pycache__/head.cpython-312.pyc index f86475fdba2cc0a76f9b23e37fbe75d09e731c08..76af53c975481a35ffcabe4cf2c53b5d7aef8f73 100644 Binary files a/ultralytics/nn/modules/__pycache__/head.cpython-312.pyc and b/ultralytics/nn/modules/__pycache__/head.cpython-312.pyc differ diff --git a/ultralytics/nn/modules/__pycache__/transformer.cpython-312.pyc b/ultralytics/nn/modules/__pycache__/transformer.cpython-312.pyc index c1755eb5eceec4a80c6d53cfddc4e77ae19157e5..4674fc2d0e42cad024ff39e9d06268899f6ceaf9 100644 Binary files a/ultralytics/nn/modules/__pycache__/transformer.cpython-312.pyc and b/ultralytics/nn/modules/__pycache__/transformer.cpython-312.pyc differ diff --git a/ultralytics/nn/modules/__pycache__/utils.cpython-312.pyc b/ultralytics/nn/modules/__pycache__/utils.cpython-312.pyc index fc1bb3752d42f0d219d4da1d6166f0a6cbcc21cd..0049512def5b6a10118f4424816d056b00763508 100644 Binary files a/ultralytics/nn/modules/__pycache__/utils.cpython-312.pyc and b/ultralytics/nn/modules/__pycache__/utils.cpython-312.pyc differ diff --git a/ultralytics/nn/tasks.py b/ultralytics/nn/tasks.py index 96a366494c228db4238c14487aeea10fc82720d2..2d7afd915d5046e4448b6ac7d4d14beeedca6731 100644 --- a/ultralytics/nn/tasks.py +++ b/ultralytics/nn/tasks.py @@ -140,7 +140,7 @@ class BaseModel(torch.nn.Module): if isinstance(x, dict): # for cases of training and validating while training. temp_loss = self.loss(x, *args, **kwargs) return temp_loss - return self.predict(x, *args, **kwargs) + return self.predict(x, *args, **kwargs) # called by validation too def predict(self, x, profile=False, visualize=False, augment=False, embed=None): """ diff --git a/ultralytics/utils/__pycache__/__init__.cpython-312.pyc b/ultralytics/utils/__pycache__/__init__.cpython-312.pyc index 462356d99b6a48a83c836ef6f7b1b543a7a352de..38dfd052e406ebc1292209299a5a28ac9e8d62b7 100644 Binary files a/ultralytics/utils/__pycache__/__init__.cpython-312.pyc and b/ultralytics/utils/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/autobatch.cpython-312.pyc b/ultralytics/utils/__pycache__/autobatch.cpython-312.pyc index 26e0046c57de1dcb32da21a4a93f90decab21453..32628392f769b715e367858f6478060af2bccdcb 100644 Binary files a/ultralytics/utils/__pycache__/autobatch.cpython-312.pyc and b/ultralytics/utils/__pycache__/autobatch.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/checks.cpython-312.pyc b/ultralytics/utils/__pycache__/checks.cpython-312.pyc index d7f66d6d08d02bd60f0d8688910afed6de14c1f2..3e13d1247d6ce7ef6e2932c98e0785ee132b548d 100644 Binary files a/ultralytics/utils/__pycache__/checks.cpython-312.pyc and b/ultralytics/utils/__pycache__/checks.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/dist.cpython-312.pyc b/ultralytics/utils/__pycache__/dist.cpython-312.pyc index 4cd3e3bb07b251299fd7493cad72ca1b5c4b839d..a322bc45fd76beac769917606a9a758d960a355d 100644 Binary files a/ultralytics/utils/__pycache__/dist.cpython-312.pyc and b/ultralytics/utils/__pycache__/dist.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/downloads.cpython-312.pyc b/ultralytics/utils/__pycache__/downloads.cpython-312.pyc index 63ae7e0b1998b94daf6586ac11eb0ea67fbc81e0..3aad9c8fa9bda7d85d12cbca6df9885b9ca193c1 100644 Binary files a/ultralytics/utils/__pycache__/downloads.cpython-312.pyc and b/ultralytics/utils/__pycache__/downloads.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/errors.cpython-312.pyc b/ultralytics/utils/__pycache__/errors.cpython-312.pyc index 1b13d09c2c1577d9534cab3ca8da0cfd27eb1766..2ae317927fa6ee837bb990de19f470a5ef8d5bf5 100644 Binary files a/ultralytics/utils/__pycache__/errors.cpython-312.pyc and b/ultralytics/utils/__pycache__/errors.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/files.cpython-312.pyc b/ultralytics/utils/__pycache__/files.cpython-312.pyc index 5121935d1b01ee6c8ed84765fd0b596c30fd4d1c..4fc07c0fd139d0b635a2ec500ab755e4b13f0dd1 100644 Binary files a/ultralytics/utils/__pycache__/files.cpython-312.pyc and b/ultralytics/utils/__pycache__/files.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/instance.cpython-312.pyc b/ultralytics/utils/__pycache__/instance.cpython-312.pyc index 22afe2b21ae8fdcbab3452856cbe6d701ec587ad..541d897adfbe00e91df701f28ce608e316c6abca 100644 Binary files a/ultralytics/utils/__pycache__/instance.cpython-312.pyc and b/ultralytics/utils/__pycache__/instance.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/loss.cpython-312.pyc b/ultralytics/utils/__pycache__/loss.cpython-312.pyc index 94b79aa596d08ec1c639fde9332d5eea71795238..9881fc6a253bb5a934dd0e5aeb4c2067691eadf5 100644 Binary files a/ultralytics/utils/__pycache__/loss.cpython-312.pyc and b/ultralytics/utils/__pycache__/loss.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/metrics.cpython-312.pyc b/ultralytics/utils/__pycache__/metrics.cpython-312.pyc index 38e38f97e6b69ffbd40330e050493c195448f9b7..2cb98029e8205d07faf253a7bb19d52eae5ed1c1 100644 Binary files a/ultralytics/utils/__pycache__/metrics.cpython-312.pyc and b/ultralytics/utils/__pycache__/metrics.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/ops.cpython-312.pyc b/ultralytics/utils/__pycache__/ops.cpython-312.pyc index 4bd2ba98b79d56b88d5f651b4291692decbbe452..71e17796c841300eba46390dfdb31d60bfc99134 100644 Binary files a/ultralytics/utils/__pycache__/ops.cpython-312.pyc and b/ultralytics/utils/__pycache__/ops.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/patches.cpython-312.pyc b/ultralytics/utils/__pycache__/patches.cpython-312.pyc index 43d72881d9e24f7407c9ce65243d208d6fa2cdac..0a094777e61e92b10d94a252ba86379cc9d2c378 100644 Binary files a/ultralytics/utils/__pycache__/patches.cpython-312.pyc and b/ultralytics/utils/__pycache__/patches.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/plotting.cpython-312.pyc b/ultralytics/utils/__pycache__/plotting.cpython-312.pyc index e5cfe39ebb5ec4bfad38aabb3d501dc59c4c6c41..c472569a547982ec01bf95a6723936aef6c52268 100644 Binary files a/ultralytics/utils/__pycache__/plotting.cpython-312.pyc and b/ultralytics/utils/__pycache__/plotting.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/tal.cpython-312.pyc b/ultralytics/utils/__pycache__/tal.cpython-312.pyc index 1cb2be53f92b7addf2c35e291ae431aafac839ac..659a6e2f0795d747a9d9d81bef477520c10a3c25 100644 Binary files a/ultralytics/utils/__pycache__/tal.cpython-312.pyc and b/ultralytics/utils/__pycache__/tal.cpython-312.pyc differ diff --git a/ultralytics/utils/__pycache__/torch_utils.cpython-312.pyc b/ultralytics/utils/__pycache__/torch_utils.cpython-312.pyc index 7dc7dc9130c34f920c7e3460466ff2c31bd29a7b..d33b0497f6a0b8b43d5dd7a260fbb5e62c5f89e0 100644 Binary files a/ultralytics/utils/__pycache__/torch_utils.cpython-312.pyc and b/ultralytics/utils/__pycache__/torch_utils.cpython-312.pyc differ diff --git a/ultralytics/utils/callbacks/__pycache__/__init__.cpython-312.pyc b/ultralytics/utils/callbacks/__pycache__/__init__.cpython-312.pyc index 938e5d2851d946ce9e8ee319b478147c103a36e1..147e676703be60ad51bdd9c67eff8dd187fd59e3 100644 Binary files a/ultralytics/utils/callbacks/__pycache__/__init__.cpython-312.pyc and b/ultralytics/utils/callbacks/__pycache__/__init__.cpython-312.pyc differ diff --git a/ultralytics/utils/callbacks/__pycache__/base.cpython-312.pyc b/ultralytics/utils/callbacks/__pycache__/base.cpython-312.pyc index b1e5aeaedb87ac523cef22d31ae8e538590687b5..950dab742f25fc030455ca47f9d949959d0e32ae 100644 Binary files a/ultralytics/utils/callbacks/__pycache__/base.cpython-312.pyc and b/ultralytics/utils/callbacks/__pycache__/base.cpython-312.pyc differ diff --git a/ultralytics/utils/callbacks/__pycache__/hub.cpython-312.pyc b/ultralytics/utils/callbacks/__pycache__/hub.cpython-312.pyc index c658e3fa4e16fbf969de10058f0e58537e57354c..c8df03b88768959078cd1e36a104a4cfe7ba34d7 100644 Binary files a/ultralytics/utils/callbacks/__pycache__/hub.cpython-312.pyc and b/ultralytics/utils/callbacks/__pycache__/hub.cpython-312.pyc differ diff --git a/ultralytics/utils/loss.py b/ultralytics/utils/loss.py index dfec5ea2ec8f16193f2b9bae469bcce8b01cb7ec..3c2ac29acbb3aa34c7e5cce5247e4434b9e06ea6 100644 --- a/ultralytics/utils/loss.py +++ b/ultralytics/utils/loss.py @@ -282,6 +282,23 @@ class v8SegmentationLoss(v8DetectionLoss): (self.reg_max * 4, 1, self.nc), 1 # the 1 in (self.reg_max * 4, 1, self.nc) for extra regression scalar value ) + # for the bounding boxes + # preds[0][0].shape + # torch.Size([16, 71, 40, 40]) + # preds[0][1].shape + # torch.Size([16, 71, 20, 20]) + # preds[0][2].shape + # torch.Size([16, 71, 10, 10]) + + # shapes of pred_distri, pred_growth_val, pred_scores + # [16, 64, 2100], [16, 1, 2100], [16, 6, 2100] + # it may seem odd predictinng 64 values for one box's coordiniates + # but yolo predict something like a histogram i.e a distribution instead of a single value + # 16 values for one coordinate, so 4 coordinates * 16 per coordinate = 64 values + + # pred_masks.shape + # torch.Size([16, 2100, 32]) + # B, grids, .. pred_scores = pred_scores.permute(0, 2, 1).contiguous() pred_distri = pred_distri.permute(0, 2, 1).contiguous() @@ -295,7 +312,13 @@ class v8SegmentationLoss(v8DetectionLoss): # Targets try: batch_idx = batch["batch_idx"].view(-1, 1) - targets = torch.cat((batch_idx, batch["cls"].view(-1, 1), batch["growth_stage"].view(-1, 1), batch["bboxes"]), 1) # to accomodate the additional growth_stage + + batch_idx = batch_idx.to(self.device) + batch_cls = batch["cls"].view(-1, 1).to(self.device) + batch_growth_stage = batch["growth_stage"].view(-1, 1).to(self.device) + batch_bboxes = batch["bboxes"].to(self.device) + + targets = torch.cat((batch_idx, batch_cls, batch_growth_stage, batch_bboxes), 1) # to accomodate the additional growth_stage targets = self.preprocess(targets.to(self.device), batch_size, scale_tensor=imgsz[[1, 0, 1, 0]]) gt_labels, gt_growth, gt_bboxes = targets.split((1, 1, 4), 2) # cls, xyxy mask_gt = gt_bboxes.sum(2, keepdim=True).gt_(0.0) @@ -327,7 +350,7 @@ class v8SegmentationLoss(v8DetectionLoss): # Cls loss # loss[1] = self.varifocal_loss(pred_scores, target_scores, target_labels) / target_scores_sum # VFL way loss[2] = self.bce(pred_scores, target_scores.to(dtype)).sum() / target_scores_sum # BCE - loss[4] = self.mse(pred_growth_val, target_growth) + loss[4] = self.mse(pred_growth_val, target_growth.to(dtype)) if fg_mask.sum(): # Bbox loss @@ -357,7 +380,7 @@ class v8SegmentationLoss(v8DetectionLoss): loss[1] *= self.hyp.box # seg gain loss[2] *= self.hyp.cls # cls gain loss[3] *= self.hyp.dfl # dfl gain - loss[4] *= self.hyp.cls # growth stage regression loss + loss[4] *= self.hyp.cls * 0.5 # growth stage regression loss return loss.sum() * batch_size, loss.detach() # loss(box, cls, dfl) @staticmethod diff --git a/ultralytics/utils/metrics.py b/ultralytics/utils/metrics.py index 43e73304b1db8daef56e7d40b8f8b1773fa83011..86a8781fc5f195327ff8b8d2680d803c61b87b11 100644 --- a/ultralytics/utils/metrics.py +++ b/ultralytics/utils/metrics.py @@ -336,8 +336,8 @@ class ConfusionMatrix: """ if gt_cls.shape[0] == 0: # Check if labels is empty if detections is not None: - detections = detections[detections[:, 4] > self.conf] - detection_classes = detections[:, 5].int() + detections = detections[detections[:, 5] > self.conf] # changed to '5', was prevously '4' + detection_classes = detections[:, 6].int() # changed to '6', was previously '5'. to accomodate for the new gs for dc in detection_classes: self.matrix[dc, self.nc] += 1 # false positives return @@ -347,10 +347,11 @@ class ConfusionMatrix: self.matrix[self.nc, gc] += 1 # background FN return - detections = detections[detections[:, 4] > self.conf] + detections = detections[detections[:, 5] > self.conf] # changed to '5', was prevously '4' gt_classes = gt_cls.int() - detection_classes = detections[:, 5].int() - is_obb = detections.shape[1] == 7 and gt_bboxes.shape[1] == 5 # with additional `angle` dimension + detection_classes = detections[:, 6].int() # changed to '6', was previously '5' + is_obb = detections.shape[1] == 8 and gt_bboxes.shape[1] == 6 # with additional `angle` dimension + # 7 and 5 changed to 8 and 6 in the above line iou = ( batch_probiou(gt_bboxes, torch.cat([detections[:, :4], detections[:, -1:]], dim=-1)) if is_obb diff --git a/ultralytics/utils/ops.py b/ultralytics/utils/ops.py index e37e8834ed953d0a3eeb8da1845049486fc00a4d..e96bd752a7ae5f6c49016f81aa6bfe5e786671d7 100644 --- a/ultralytics/utils/ops.py +++ b/ultralytics/utils/ops.py @@ -179,7 +179,7 @@ def nms_rotated(boxes, scores, threshold=0.45, use_triu=True): def non_max_suppression( - prediction, + prediction, conf_thres=0.25, iou_thres=0.45, classes=None, @@ -236,13 +236,13 @@ def non_max_suppression( prediction = prediction[0] # select only inference output if classes is not None: classes = torch.tensor(classes, device=prediction.device) - - if prediction.shape[-1] == 6 or end2end: # end-to-end model (BNC, i.e. 1,300,6) - output = [pred[pred[:, 4] > conf_thres][:max_det] for pred in prediction] + # prediction shape [1, 43, 6300], the 43 is as follows. 4 coords, growth val, 6 pseudo probs, 32 masks + if prediction.shape[-1] == 7 or end2end: # end-to-end model (BNC, i.e. 1,300,6) # changed '6' to '7' since a box is now represented by 7 values + output = [pred[pred[:, 5] > conf_thres][:max_det] for pred in prediction] # changed '4' to '5' since confidence is one position ahead, growth_val is at index 4 if classes is not None: - output = [pred[(pred[:, 5:6] == classes).any(1)] for pred in output] + output = [pred[(pred[:, 6:7] == classes).any(1)] for pred in output] # changed '5:6' to '6:7', class is one position ahead return output - + # preds.shape = [1, 43, 6300], one vector of length 43 == on bbox + it's mask. 43 = 4*coords + growth_val + 6*classes pseudo probs, 32*masks bs = prediction.shape[0] # batch size (BCN, i.e. 1,84,6300) nc = nc or (prediction.shape[1] - 4) # number of classes nm = prediction.shape[1] - nc - 4 - 1 # number of masks # -1 is done since an extra channel is for the growth stage @@ -263,7 +263,7 @@ def non_max_suppression( prediction = torch.cat((xywh2xyxy(prediction[..., :4]), prediction[..., 4:]), dim=-1) # xywh to xyxy t = time.time() - output = [torch.zeros((0, 6 + nm), device=prediction.device)] * bs + output = [torch.zeros((0, 7 + nm), device=prediction.device)] * bs # '6' changed to '7' for the additional scalar growth stage value for xi, x in enumerate(prediction): # image index, image inference # Apply constraints # x[((x[:, 2:4] < min_wh) | (x[:, 2:4] > max_wh)).any(1), 4] = 0 # width-height @@ -273,6 +273,7 @@ def non_max_suppression( if labels and len(labels[xi]) and not rotated: # since this code wasn't executed while testing, it won't be changed # it could be possible that configuration might change and this might be executed in which case byzantine faults might occur # or the code could crash too + assert 0, 'Code point reached not executed in normal code flow while debugging locally' lb = labels[xi] v = torch.zeros((len(lb), nc + nm + 4), device=x.device) v[:, :4] = xywh2xyxy(lb[:, 1:5]) # box @@ -288,7 +289,26 @@ def non_max_suppression( if multi_label: # False in 'normal' execution i, j = torch.where(cls > conf_thres) - x = torch.cat((box[i], x[i, 4 + j, None], j[:, None].float(), mask[i]), 1) + """ As seen below, torch.where returns two tensors which tell the + positions in cls (a 2D array) which are greater than confidence threshold (a scalar) + >>> arr1 = torch.randn(3, 2) + >>> arr2 = torch.ones(3,2) * 0.5 + >>> arr1 + tensor([[ 1.4419, 1.5131], + [-0.0594, 0.6871], + [-1.1018, 0.2445]]) + >>> arr2 + tensor([[0.5000, 0.5000], + [0.5000, 0.5000], + [0.5000, 0.5000]]) + >>> torch.where (arr1 > arr2) + (tensor([0, 0, 1]), tensor([0, 1, 1])) + """ # The line below can increase the number of boxes since a box can belong + #to more than one classes at the same time (assumed by the line below), + # boxes can increase by a factor of 'nc' at max + # '4' changed to '5' since the class indices start one step later due to gs + x = torch.cat((box[i], x[i, 4, None], x[i, 5 + j, None], j[:, None].float(), mask[i]), 1) + # 4 box coords ^^^ else: # best class only conf, j = cls.max(1, keepdim=True) x = torch.cat((box, gr_val, conf, j.float(), mask), 1)[conf.view(-1) > conf_thres] # adding the growth val @@ -297,7 +317,7 @@ def non_max_suppression( # Filter by class if classes is not None: - x = x[(x[:, 5:6] == classes).any(1)] + x = x[(x[:, 6:7] == classes).any(1)] # changed from '5:6' to '6:7' # Check shape n = x.shape[0] # number of boxes @@ -312,6 +332,7 @@ def non_max_suppression( # index 5 is taken by growth value scores = x[:, 5] # scores # '4' changed to 5 since conf score is at index 5 now if rotated: + assert 0, 'Code point reached not executed in normal code flow while debugging locally' boxes = torch.cat((x[:, :2] + c, x[:, 2:4], x[:, -1:]), dim=-1) # xywhr i = nms_rotated(boxes, scores, iou_thres) else: diff --git a/ultralytics/utils/plotting.py b/ultralytics/utils/plotting.py index 12fb6b583903061fbea3e637459fcbc5424eb3db..3384b699f88e1fd12a2a41eaa35c36fe2c51a7d5 100644 --- a/ultralytics/utils/plotting.py +++ b/ultralytics/utils/plotting.py @@ -420,10 +420,10 @@ class Annotator: im_gpu = im_gpu.flip(dims=[0]) # flip channel im_gpu = im_gpu.permute(1, 2, 0).contiguous() # shape(h,w,3) - im_gpu = im_gpu * inv_alpha_masks[-1] + mcs + im_gpu = im_gpu[:, :, :3] * inv_alpha_masks[-1] + mcs # the image contains 4 channels and we only want the rgb channels, not the .tiff channel im_mask = im_gpu * 255 im_mask_np = im_mask.byte().cpu().numpy() - self.im[:] = im_mask_np if retina_masks else ops.scale_image(im_mask_np, self.im.shape) + self.im[:, :, :3] = im_mask_np if retina_masks else ops.scale_image(im_mask_np, self.im.shape) # the image contains 4 channels and we only want the rgb channels, not the .tiff channel if self.pil: # Convert im back to PIL and update draw self.fromarray(self.im) @@ -544,7 +544,7 @@ class Annotator: def save(self, filename="image.jpg"): """Save the annotated image to 'filename'.""" - cv2.imwrite(filename, np.asarray(self.im)) + cv2.imwrite(filename, np.asarray(self.im[:, :, :3])) # the image contains 4 channels and we only want the rgb channels, not the .tiff channel @staticmethod def get_bbox_dimension(bbox=None): @@ -981,7 +981,7 @@ def save_one_box(xyxy, im, file=Path("im.jpg"), gain=1.02, pad=10, square=False, Image.fromarray(crop[..., ::-1]).save(f, quality=95, subsampling=0) # save RGB return crop - +# images, [batch_id, class_id, x, y, w, h, conf, growth_stage], ........ @threaded def plot_images( images: Union[torch.Tensor, np.ndarray], @@ -989,6 +989,7 @@ def plot_images( cls: Union[torch.Tensor, np.ndarray], bboxes: Union[torch.Tensor, np.ndarray] = np.zeros(0, dtype=np.float32), confs: Optional[Union[torch.Tensor, np.ndarray]] = None, + # growth_stage: Union[torch.Tensor, np.ndarray], masks: Union[torch.Tensor, np.ndarray] = np.zeros(0, dtype=np.uint8), kpts: Union[torch.Tensor, np.ndarray] = np.zeros((0, 51), dtype=np.float32), paths: Optional[List[str]] = None, @@ -1279,15 +1280,16 @@ def plot_tune_results(csv_file="tune_results.csv"): def output_to_target(output, max_det=300): - """Convert model output to target format [batch_id, class_id, x, y, w, h, conf] for plotting.""" + """Convert model output to target format [batch_id, class_id, x, y, w, h, conf, growth_stage] for plotting.""" targets = [] for i, o in enumerate(output): - box, conf, cls = o[:max_det, :6].cpu().split((4, 1, 1), 1) + box, growth_stage, conf, cls = o[:max_det, :7].cpu().split((4, 1, 1, 1), 1) # was previously box, conf, cls = o[:max_det, :6].cpu().split((4, 1, 1), 1), changed for the additional growth stage j = torch.full((conf.shape[0], 1), i) - targets.append(torch.cat((j, cls, ops.xyxy2xywh(box), conf), 1)) + targets.append(torch.cat((j, cls, ops.xyxy2xywh(box), conf, growth_stage), 1)) targets = torch.cat(targets, 0).numpy() - return targets[:, 0], targets[:, 1], targets[:, 2:-1], targets[:, -1] - + return targets[:, 0], targets[:, 1], targets[:, 2:-2], targets[:, -2] # this works too if you don't want the growth stage in the output plot + # return targets[:, 0], targets[:, 1], targets[:, 2:-2], targets[:, -2], targets[:, -1] + # batch ids ^^^ ^^^ class_ids ^^^ bboxes ^^^ confs ^^^ growth_stages def output_to_rotated_target(output, max_det=300): """Convert model output to target format [batch_id, class_id, x, y, w, h, conf] for plotting."""