From b529e979b4849422d667293c560c9961e8276d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Deltheil?= Date: Tue, 30 Jan 2024 08:35:25 +0000 Subject: [PATCH 1/3] mkdocs.yml: fix typo --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 4ebbf04a2..92fb1b772 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,5 +1,5 @@ site_name: Refiners -site_decription: A micro framework on top of PyTorch with first class citizen APIs for foundation model adaptation +site_description: A micro framework on top of PyTorch with first class citizen APIs for foundation model adaptation repo_name: Refiners repo_url: https://github.com/finegrain-ai/refiners edit_uri: edit/main/docs/ From 161b33de09011f557024f6189448f52763ae80f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Deltheil?= Date: Tue, 30 Jan 2024 08:44:49 +0000 Subject: [PATCH 2/3] segment-anything: fix class name typo Note: weights are impacted --- scripts/prepare_test_weights.py | 2 +- src/refiners/foundationals/segment_anything/mask_decoder.py | 4 ++-- src/refiners/foundationals/segment_anything/transformer.py | 2 +- tests/foundationals/segment_anything/test_sam.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/prepare_test_weights.py b/scripts/prepare_test_weights.py index 19f942375..f611e1ef9 100644 --- a/scripts/prepare_test_weights.py +++ b/scripts/prepare_test_weights.py @@ -581,7 +581,7 @@ def convert_sam(): "convert_segment_anything.py", "tests/weights/sam_vit_h_4b8939.pth", "tests/weights/segment-anything-h.safetensors", - expected_hash="3b73b2fd", + expected_hash="b62ad5ed", ) diff --git a/src/refiners/foundationals/segment_anything/mask_decoder.py b/src/refiners/foundationals/segment_anything/mask_decoder.py index cd196683e..0f9c4778e 100644 --- a/src/refiners/foundationals/segment_anything/mask_decoder.py +++ b/src/refiners/foundationals/segment_anything/mask_decoder.py @@ -5,7 +5,7 @@ from refiners.fluxion.context import Contexts from refiners.foundationals.segment_anything.transformer import ( SparseCrossDenseAttention, - TwoWayTranformerLayer, + TwoWayTransformerLayer, ) @@ -210,7 +210,7 @@ def __init__( EmbeddingsAggregator(num_output_mask=num_output_mask), Transformer( *( - TwoWayTranformerLayer( + TwoWayTransformerLayer( embedding_dim=embedding_dim, num_heads=8, feed_forward_dim=feed_forward_dim, diff --git a/src/refiners/foundationals/segment_anything/transformer.py b/src/refiners/foundationals/segment_anything/transformer.py index 5fb13d76e..7abe2f5a5 100644 --- a/src/refiners/foundationals/segment_anything/transformer.py +++ b/src/refiners/foundationals/segment_anything/transformer.py @@ -116,7 +116,7 @@ def __init__( ) -class TwoWayTranformerLayer(fl.Chain): +class TwoWayTransformerLayer(fl.Chain): def __init__( self, embedding_dim: int, diff --git a/tests/foundationals/segment_anything/test_sam.py b/tests/foundationals/segment_anything/test_sam.py index 8b21c1592..1a62217d0 100644 --- a/tests/foundationals/segment_anything/test_sam.py +++ b/tests/foundationals/segment_anything/test_sam.py @@ -21,7 +21,7 @@ from refiners.fluxion.utils import image_to_tensor, load_tensors, no_grad from refiners.foundationals.segment_anything.image_encoder import FusedSelfAttention from refiners.foundationals.segment_anything.model import SegmentAnythingH -from refiners.foundationals.segment_anything.transformer import TwoWayTranformerLayer +from refiners.foundationals.segment_anything.transformer import TwoWayTransformerLayer # See predictor_example.ipynb official notebook PROMPTS: list[SAMPrompt] = [ @@ -188,7 +188,7 @@ def test_two_way_transformer(facebook_sam_h: FacebookSAM) -> None: dense_positional_embedding = torch.randn(1, 64 * 64, 256, device=facebook_sam_h.device) sparse_embedding = torch.randn(1, 3, 256, device=facebook_sam_h.device) - refiners_layer = TwoWayTranformerLayer( + refiners_layer = TwoWayTransformerLayer( embedding_dim=256, feed_forward_dim=2048, num_heads=8, device=facebook_sam_h.device ) facebook_layer = facebook_sam_h.mask_decoder.transformer.layers[1] # type: ignore From 7614c5d1055bf18f4443408da8441b9dd063c830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Deltheil?= Date: Tue, 30 Jan 2024 08:48:46 +0000 Subject: [PATCH 3/3] fix minor typos in code and docs --- src/refiners/fluxion/layers/chain.py | 2 +- src/refiners/foundationals/latent_diffusion/image_prompt.py | 6 +++--- src/refiners/training_utils/config.py | 2 +- src/refiners/training_utils/trainer.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/refiners/fluxion/layers/chain.py b/src/refiners/fluxion/layers/chain.py index 497cac962..2543e9b39 100644 --- a/src/refiners/fluxion/layers/chain.py +++ b/src/refiners/fluxion/layers/chain.py @@ -215,7 +215,7 @@ def find_state_dict_key(module: Module, /) -> str | None: @staticmethod def _pretty_print_args(*args: Any) -> str: """ - Flatten nested tuples and print tensors with their shape and other informations. + Flatten nested tuples and print tensors with their shape and other information. """ def _flatten_tuple(t: Tensor | tuple[Any, ...], /) -> list[Any]: diff --git a/src/refiners/foundationals/latent_diffusion/image_prompt.py b/src/refiners/foundationals/latent_diffusion/image_prompt.py index bd1c8d4b1..3738698ad 100644 --- a/src/refiners/foundationals/latent_diffusion/image_prompt.py +++ b/src/refiners/foundationals/latent_diffusion/image_prompt.py @@ -447,7 +447,7 @@ def convert_to_grid_features(clip_image_encoder: CLIPImageEncoderH) -> CLIPImage assert isinstance(encoder_clone[-3], fl.Lambda) # pooling (classif token) for _ in range(3): encoder_clone.pop() - transfomer_layers = encoder_clone[-1] - assert isinstance(transfomer_layers, fl.Chain) and len(transfomer_layers) == 32 - transfomer_layers.pop() + transformer_layers = encoder_clone[-1] + assert isinstance(transformer_layers, fl.Chain) and len(transformer_layers) == 32 + transformer_layers.pop() return encoder_clone diff --git a/src/refiners/training_utils/config.py b/src/refiners/training_utils/config.py index 6b61c1a70..8af1ddf22 100644 --- a/src/refiners/training_utils/config.py +++ b/src/refiners/training_utils/config.py @@ -178,7 +178,7 @@ class ModelConfig(BaseModel): class GyroDropoutConfig(BaseModel): total_subnetworks: int = 512 - concurent_subnetworks: int = 64 + concurrent_subnetworks: int = 64 iters_per_epoch: int = 512 num_features_threshold: float = 5e5 diff --git a/src/refiners/training_utils/trainer.py b/src/refiners/training_utils/trainer.py index 9c2ee1707..021a168c1 100644 --- a/src/refiners/training_utils/trainer.py +++ b/src/refiners/training_utils/trainer.py @@ -213,7 +213,7 @@ def time_elapsed(self) -> int: return int(time.time() - self.start_time) @cached_property - def evalution_interval_steps(self) -> int: + def evaluation_interval_steps(self) -> int: return self.convert_time_unit_to_steps( number=self.evaluation_interval["number"], unit=self.evaluation_interval["unit"] ) @@ -244,7 +244,7 @@ def done(self) -> bool: @property def is_evaluation_step(self) -> bool: - return self.step % self.evalution_interval_steps == 0 + return self.step % self.evaluation_interval_steps == 0 @property def is_checkpointing_step(self) -> bool: