-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hotfix/sg 000 fix predict loading from np torch (#1419)
* fix * Added table with all supported input types to predict() and improved load_image method to get rid of hard-coded number of input channels * Improve spelling * Improve type alias --------- Co-authored-by: Shay Aharon <80472096+shaydeci@users.noreply.github.com> Co-authored-by: Eugene Khvedchenya <ekhvedchenya@gmail.com> (cherry picked from commit 4536d2d)
- Loading branch information
1 parent
1c64e1c
commit c04daec
Showing
4 changed files
with
126 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import unittest | ||
|
||
import numpy as np | ||
import torch | ||
|
||
from super_gradients.training.utils.media.image import load_images | ||
|
||
|
||
class TrainingParamsTest(unittest.TestCase): | ||
def test_load_images(self): | ||
|
||
# list - numpy | ||
list_images = [np.zeros((3, 100, 100)) for _ in range(15)] | ||
loaded_images = load_images(list_images) | ||
self.assertEqual(len(loaded_images), 15) | ||
for image in loaded_images: | ||
self.assertIsInstance(image, np.ndarray) | ||
self.assertEqual(image.shape, (100, 100, 3)) | ||
|
||
# numpy - batch | ||
np_images = np.zeros((15, 3, 100, 100)) | ||
loaded_images = load_images(np_images) | ||
self.assertEqual(len(loaded_images), 15) | ||
for image in loaded_images: | ||
self.assertIsInstance(image, np.ndarray) | ||
self.assertEqual(image.shape, (100, 100, 3)) | ||
|
||
# list - torcj | ||
list_images = [torch.zeros((3, 100, 100)) for _ in range(15)] | ||
loaded_images = load_images(list_images) | ||
self.assertEqual(len(loaded_images), 15) | ||
for image in loaded_images: | ||
self.assertIsInstance(image, np.ndarray) | ||
self.assertEqual(image.shape, (100, 100, 3)) | ||
|
||
# torch - batch | ||
torch_images = torch.zeros((15, 3, 100, 100)) | ||
loaded_images = load_images(torch_images) | ||
self.assertEqual(len(loaded_images), 15) | ||
for image in loaded_images: | ||
self.assertIsInstance(image, np.ndarray) | ||
self.assertEqual(image.shape, (100, 100, 3)) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |