-
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.
Merge branch 'master' into featuer/SG-000-improve-notebook-checks
# Conflicts: # Makefile
- Loading branch information
Showing
23 changed files
with
954 additions
and
44 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
612 changes: 612 additions & 0 deletions
612
notebooks/how_to_use_knowledge_distillation_for_classification.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
39 changes: 39 additions & 0 deletions
39
src/super_gradients/training/datasets/classification_datasets/torchvision_utils.py
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,39 @@ | ||
from typing import List, Any, Dict | ||
|
||
from torchvision.datasets.vision import StandardTransform | ||
from torchvision.transforms import Resize, ToTensor, Normalize, CenterCrop, Compose | ||
|
||
from super_gradients.common.object_names import Processings | ||
|
||
|
||
def get_torchvision_transforms_equivalent_processing(transforms: List[Any]) -> List[Dict[str, Any]]: | ||
""" | ||
Get the equivalent processing pipeline for torchvision transforms. | ||
:return: List of Processings operations | ||
""" | ||
# Since we are using cv2.imread to read images, our model in fact is trained on BGR images. | ||
# In our pipelines the convention that input images are RGB, so we need to reverse the channels to get BGR | ||
# to match with the expected input of the model. | ||
pipeline = [] | ||
|
||
if isinstance(transforms, StandardTransform): | ||
transforms = transforms.transform | ||
|
||
if isinstance(transforms, Compose): | ||
transforms = transforms.transforms | ||
|
||
for transform in transforms: | ||
if isinstance(transform, ToTensor): | ||
pipeline.append({Processings.StandardizeImage: {"max_value": 255}}) | ||
elif isinstance(transform, Normalize): | ||
pipeline.append({Processings.NormalizeImage: {"mean": tuple(map(float, transform.mean)), "std": tuple(map(float, transform.std))}}) | ||
elif isinstance(transform, Resize): | ||
pipeline.append({Processings.Resize: {"size": int(transform.size)}}) | ||
elif isinstance(transform, CenterCrop): | ||
pipeline.append({Processings.CenterCrop: {"size": int(transform.size)}}) | ||
else: | ||
raise ValueError(f"Unsupported transform: {transform}") | ||
|
||
pipeline.append({Processings.ImagePermute: {"permutation": (2, 0, 1)}}) | ||
return pipeline |
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
Oops, something went wrong.