-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor tests #1011
Merged
+1,046
−223
Merged
Refactor tests #1011
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
f62e968
Add parallel test deps
qubvel 7e08ed3
Update signature
qubvel 053db25
Add encoders tests
qubvel ebe261a
Update gitignore
qubvel e8f7a4e
Update encoders for timm-universal
qubvel 988c85f
Add parallel tests run
qubvel ae0977e
Disable models tests
qubvel f590d9d
Add uv to CI
qubvel bd48d9e
Add uv to minimum
qubvel cc79c8e
Add show-install-packages
qubvel dba99f8
Increase to 3 workers
qubvel 2bb41b4
Fix show-packages
qubvel 527799e
Change back for 2 workers
qubvel 0474e77
Add coverage
qubvel 61a5496
Basic model test
qubvel e97ce92
Fix
qubvel 7c947f8
Move model archs
qubvel 1d5e1ea
Add base params test
qubvel ede9942
Fix timm test for minimum version
qubvel b0c9289
Remove deprecated utils from coverage
qubvel d58d1fd
Fix
qubvel 18ee80d
Fix
qubvel 2b113f0
Exclude conversion script
qubvel b7ce422
Add save-load test, add aux head test
qubvel 23bfce6
Remove custom encoder
qubvel 4d7fed0
Set encoder for models tests
qubvel eadfe1f
Docs + flag for anyres
qubvel 66bc2c8
Fix loading from config
qubvel d4b82b3
Bump min hf-hub to 0.25.0
qubvel 6346405
Fix minimal
qubvel 8d06cba
Add test with hub checkpoint
qubvel a83a5e9
Fixing minimum
qubvel 10993bb
Fix
qubvel 4446730
Fix torch for minimum tests
qubvel 914fc6e
Update torch version and run-slow
qubvel 3eb9900
run-slow
qubvel 15b0658
Show skipped
qubvel 238dd11
[run-slow] Fixing minimum
qubvel 63ba1c4
[run-slow] Fixing minimum
qubvel 8181888
Fix decorator
qubvel e41d480
Raise error
qubvel e1caeb9
[run-slow] Fixing run slow
qubvel 101b487
[run-slow] Fixing run slow
qubvel 13563a6
Run slow tests in separate job
qubvel d4d8508
FIx
qubvel a17bb6a
Fixes
qubvel 58afe1b
Add device
qubvel 4d51fac
Bum tolerance
qubvel aa2cf99
Add device
qubvel 3e8d703
Fixup
qubvel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -93,6 +93,7 @@ venv/ | |
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
.vscode/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
|
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,41 @@ | ||
import os | ||
import torch | ||
import tempfile | ||
import huggingface_hub | ||
import segmentation_models_pytorch as smp | ||
|
||
HUB_REPO = "smp-test-models" | ||
ENCODER_NAME = "tu-resnet18" | ||
|
||
api = huggingface_hub.HfApi(token=os.getenv("HF_TOKEN")) | ||
|
||
for model_name, model_class in smp.MODEL_ARCHITECTURES_MAPPING.items(): | ||
model = model_class(encoder_name=ENCODER_NAME) | ||
model = model.eval() | ||
|
||
# generate test sample | ||
torch.manual_seed(423553) | ||
sample = torch.rand(1, 3, 256, 256) | ||
|
||
with torch.no_grad(): | ||
output = model(sample) | ||
|
||
with tempfile.TemporaryDirectory() as tmpdir: | ||
# save model | ||
model.save_pretrained(f"{tmpdir}") | ||
|
||
# save input and output | ||
torch.save(sample, f"{tmpdir}/input-tensor.pth") | ||
torch.save(output, f"{tmpdir}/output-tensor.pth") | ||
|
||
# create repo | ||
repo_id = f"{HUB_REPO}/{model_name}-{ENCODER_NAME}" | ||
if not api.repo_exists(repo_id=repo_id): | ||
api.create_repo(repo_id=repo_id, repo_type="model") | ||
|
||
# upload to hub | ||
api.upload_folder( | ||
folder_path=tmpdir, | ||
repo_id=f"{HUB_REPO}/{model_name}-{ENCODER_NAME}", | ||
repo_type="model", | ||
) |
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 |
---|---|---|
|
@@ -8,3 +8,4 @@ timm==0.9.0 | |
torch==1.9.0 | ||
torchvision==0.10.0 | ||
tqdm==4.42.1 | ||
Jinja2==3.0.0 | ||
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pytest==8.3.4 | ||
ruff==0.8.4 | ||
pytest-xdist==3.6.1 | ||
pytest-cov==6.0.0 | ||
ruff==0.8.4 |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is Jinja2 required? I don't see any code that uses it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
save/load pretrained raises an error on huggingface_hub 0.24 and asks to install
Jinja2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively we can bump minimum version for
huggingface_hub