-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate CLIP into refactored test structure
- Loading branch information
Showing
6 changed files
with
114 additions
and
143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from tests.test_methods.generator import * | ||
from transformers import CLIPTextConfig, CLIPTextModel | ||
|
||
|
||
class CLIPTextAdapterTestBase(TextAdapterTestBase): | ||
model_class = CLIPTextModel | ||
config_class = CLIPTextConfig | ||
config = make_config( | ||
CLIPTextConfig, | ||
hidden_size=32, | ||
num_hidden_layers=4, | ||
num_attention_heads=4, | ||
intermediate_size=37, | ||
) | ||
tokenizer_name = "openai/clip-vit-base-patch32" | ||
|
||
|
||
method_tests = generate_method_tests( | ||
model_test_base=CLIPTextAdapterTestBase, | ||
excluded_tests=["Embeddings", "Heads", "Composition", "ClassConversion", "PromptTuning", "ConfigUnion"], | ||
) | ||
|
||
|
||
for test_class_name, test_class in method_tests.items(): | ||
globals()[test_class_name] = test_class |
25 changes: 25 additions & 0 deletions
25
tests/test_methods/test_on_clip/test_textwithprojectionmodel.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,25 @@ | ||
from tests.test_methods.generator import * | ||
from transformers import CLIPTextConfig, CLIPTextModelWithProjection | ||
|
||
|
||
class CLIPTextWithProjectionAdapterTestBase(TextAdapterTestBase): | ||
model_class = CLIPTextModelWithProjection | ||
config_class = CLIPTextConfig | ||
config = make_config( | ||
CLIPTextConfig, | ||
hidden_size=32, | ||
num_hidden_layers=4, | ||
num_attention_heads=4, | ||
intermediate_size=37, | ||
) | ||
tokenizer_name = "openai/clip-vit-base-patch32" | ||
|
||
|
||
method_tests = generate_method_tests( | ||
model_test_base=CLIPTextWithProjectionAdapterTestBase, | ||
excluded_tests=["Embeddings", "Heads", "Composition", "ClassConversion", "PromptTuning", "ConfigUnion"], | ||
) | ||
|
||
|
||
for test_class_name, test_class in method_tests.items(): | ||
globals()[test_class_name] = test_class |
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,26 @@ | ||
from tests.test_methods.generator import * | ||
from transformers import CLIPVisionConfig, CLIPVisionModel | ||
|
||
|
||
class CLIPVisionAdapterTestBase(VisionAdapterTestBase): | ||
model_class = CLIPVisionModel | ||
config_class = CLIPVisionConfig | ||
config = make_config( | ||
CLIPVisionConfig, | ||
image_size=224, | ||
hidden_size=32, | ||
num_hidden_layers=4, | ||
num_attention_heads=4, | ||
intermediate_size=37, | ||
) | ||
feature_extractor_name = "openai/clip-vit-base-patch32" | ||
|
||
|
||
method_tests = generate_method_tests( | ||
model_test_base=CLIPVisionAdapterTestBase, | ||
excluded_tests=["Embeddings", "Heads", "Composition", "ClassConversion", "PromptTuning", "ConfigUnion"], | ||
) | ||
|
||
|
||
for test_class_name, test_class in method_tests.items(): | ||
globals()[test_class_name] = test_class |
26 changes: 26 additions & 0 deletions
26
tests/test_methods/test_on_clip/test_visionwithprojectionmodel.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,26 @@ | ||
from tests.test_methods.generator import * | ||
from transformers import CLIPVisionConfig, CLIPVisionModelWithProjection | ||
|
||
|
||
class CLIPVisionWithProjectionAdapterTestBase(VisionAdapterTestBase): | ||
model_class = CLIPVisionModelWithProjection | ||
config_class = CLIPVisionConfig | ||
config = make_config( | ||
CLIPVisionConfig, | ||
image_size=224, | ||
hidden_size=32, | ||
num_hidden_layers=4, | ||
num_attention_heads=4, | ||
intermediate_size=37, | ||
) | ||
feature_extractor_name = "openai/clip-vit-base-patch32" | ||
|
||
|
||
method_tests = generate_method_tests( | ||
model_test_base=CLIPVisionWithProjectionAdapterTestBase, | ||
excluded_tests=["Embeddings", "Heads", "Composition", "ClassConversion", "PromptTuning", "ConfigUnion"], | ||
) | ||
|
||
|
||
for test_class_name, test_class in method_tests.items(): | ||
globals()[test_class_name] = test_class |
This file was deleted.
Oops, something went wrong.