Fix img classification tests (#13456)
* ✅ Update image-classification example's tests * 🔥 remove cats_and_dogs test samples * 💄 fix flake8
@ -19,7 +19,6 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from unittest.case import skip
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
@ -344,7 +343,6 @@ class ExamplesTests(TestCasePlus):
|
|||||||
result = get_results(tmp_dir)
|
result = get_results(tmp_dir)
|
||||||
self.assertGreaterEqual(result["eval_bleu"], 30)
|
self.assertGreaterEqual(result["eval_bleu"], 30)
|
||||||
|
|
||||||
@skip("The test is failing as accuracy is 0, re-enable when fixed.")
|
|
||||||
def test_run_image_classification(self):
|
def test_run_image_classification(self):
|
||||||
stream_handler = logging.StreamHandler(sys.stdout)
|
stream_handler = logging.StreamHandler(sys.stdout)
|
||||||
logger.addHandler(stream_handler)
|
logger.addHandler(stream_handler)
|
||||||
@ -354,19 +352,19 @@ class ExamplesTests(TestCasePlus):
|
|||||||
run_image_classification.py
|
run_image_classification.py
|
||||||
--output_dir {tmp_dir}
|
--output_dir {tmp_dir}
|
||||||
--model_name_or_path google/vit-base-patch16-224-in21k
|
--model_name_or_path google/vit-base-patch16-224-in21k
|
||||||
--train_dir tests/fixtures/tests_samples/cats_and_dogs/
|
--dataset_name hf-internal-testing/cats_vs_dogs_sample
|
||||||
--do_train
|
--do_train
|
||||||
--do_eval
|
--do_eval
|
||||||
--learning_rate 2e-5
|
--learning_rate 1e-4
|
||||||
--per_device_train_batch_size 2
|
--per_device_train_batch_size 2
|
||||||
--per_device_eval_batch_size 1
|
--per_device_eval_batch_size 1
|
||||||
--remove_unused_columns False
|
--remove_unused_columns False
|
||||||
--overwrite_output_dir True
|
--overwrite_output_dir True
|
||||||
--dataloader_num_workers 16
|
--dataloader_num_workers 16
|
||||||
--metric_for_best_model accuracy
|
--metric_for_best_model accuracy
|
||||||
--max_steps 30
|
--max_steps 10
|
||||||
--train_val_split 0.1
|
--train_val_split 0.1
|
||||||
--seed 7
|
--seed 42
|
||||||
""".split()
|
""".split()
|
||||||
|
|
||||||
if is_cuda_and_apex_available():
|
if is_cuda_and_apex_available():
|
||||||
|
BIN
tests/fixtures/tests_samples/cats_and_dogs/Cat/1.jpg
vendored
Before Width: | Height: | Size: 16 KiB |
BIN
tests/fixtures/tests_samples/cats_and_dogs/Cat/2.jpg
vendored
Before Width: | Height: | Size: 26 KiB |
BIN
tests/fixtures/tests_samples/cats_and_dogs/Cat/3.jpg
vendored
Before Width: | Height: | Size: 37 KiB |
BIN
tests/fixtures/tests_samples/cats_and_dogs/Cat/4.jpg
vendored
Before Width: | Height: | Size: 20 KiB |
BIN
tests/fixtures/tests_samples/cats_and_dogs/Cat/5.jpg
vendored
Before Width: | Height: | Size: 5.6 KiB |
BIN
tests/fixtures/tests_samples/cats_and_dogs/Dog/1.jpg
vendored
Before Width: | Height: | Size: 26 KiB |
BIN
tests/fixtures/tests_samples/cats_and_dogs/Dog/2.jpg
vendored
Before Width: | Height: | Size: 15 KiB |
BIN
tests/fixtures/tests_samples/cats_and_dogs/Dog/3.jpg
vendored
Before Width: | Height: | Size: 30 KiB |
BIN
tests/fixtures/tests_samples/cats_and_dogs/Dog/4.jpg
vendored
Before Width: | Height: | Size: 106 KiB |
BIN
tests/fixtures/tests_samples/cats_and_dogs/Dog/5.jpg
vendored
Before Width: | Height: | Size: 39 KiB |