Conversation
jano1906
commented
Dec 21, 2023
| dataset = datasets.ImageFolder(root, transform=transform) | ||
| nb_classes = 1000 | ||
| elif args.data_set == 'HUGGINGFACE': | ||
| from datasets import load_dataset |
Collaborator
Author
There was a problem hiding this comment.
Moved import here to reduce number of dependencies
| help='use scale-aware embeds') | ||
| parser.add_argument('--grid-to-random-ratio', default=0.7, type=float, help='hybrid sampler grid to random ratio') | ||
|
|
||
| parser.add_argument('--model-type', default='deit', type=str, choices=["deit", "swin"]) |
Collaborator
Author
There was a problem hiding this comment.
Added special flag to decouple arguments of deit from "add on" models like swin (pyramid vit in future) which have vastly different config shapes.
Comment on lines
+376
to
+390
| elif args.model_type == "swin": | ||
| from swin.config import get_config | ||
| from swin.models import build_model | ||
| class _Args: | ||
| pass | ||
| _args = _Args() | ||
| cfg_path = "swin/swin_base_patch4_window7_224.yaml" | ||
| setattr(_args, "cfg", cfg_path) | ||
| setattr(_args, "opts", []) | ||
| setattr(_args, "local_rank", 0) | ||
| setattr(_args, "data_path", args.data_path) | ||
| config = get_config(_args) | ||
| model = build_model(config) | ||
| else: | ||
| assert False |
Collaborator
Author
There was a problem hiding this comment.
Hardcoded loading of swin vit of size B. We will not need other swin architectures, for simplicity implemented only this one.
Collaborator
Author
There was a problem hiding this comment.
./run.sh achevec 83.5 accuracy on imagenet - reproduces original model
Comment on lines
595
to
603
| assert keeps is None, "Swin transformer works only on merged patches with soft dropout. Set args --hard_dropout=0, --merge_patches=1 to proceed." | ||
| x = self.patch_embed(x) | ||
| if self.ape: | ||
| if coords is not None: | ||
| quantized = self.quantize_coords(coords) | ||
| x = x + self.absolute_pos_embed[[0] ,quantized, :] | ||
| else: | ||
| x = x + self.absolute_pos_embed | ||
| # ========================================== |
Collaborator
Author
There was a problem hiding this comment.
The only modification from original file.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.