Change no trainer image_classification test (#17635)
* Adjust test arguments and use a new example test
This commit is contained in:
@@ -300,19 +300,25 @@ class ExamplesTestsNoTrainer(TestCasePlus):
|
|||||||
tmp_dir = self.get_auto_remove_tmp_dir()
|
tmp_dir = self.get_auto_remove_tmp_dir()
|
||||||
testargs = f"""
|
testargs = f"""
|
||||||
{self.examples_dir}/pytorch/image-classification/run_image_classification_no_trainer.py
|
{self.examples_dir}/pytorch/image-classification/run_image_classification_no_trainer.py
|
||||||
--dataset_name huggingface/image-classification-test-sample
|
--model_name_or_path google/vit-base-patch16-224-in21k
|
||||||
--output_dir {tmp_dir}
|
--dataset_name hf-internal-testing/cats_vs_dogs_sample
|
||||||
--num_warmup_steps=8
|
--learning_rate 1e-4
|
||||||
--learning_rate=3e-3
|
--per_device_train_batch_size 2
|
||||||
--per_device_train_batch_size=2
|
--per_device_eval_batch_size 1
|
||||||
--per_device_eval_batch_size=1
|
--max_train_steps 2
|
||||||
--checkpointing_steps epoch
|
--train_val_split 0.1
|
||||||
--with_tracking
|
|
||||||
--seed 42
|
--seed 42
|
||||||
|
--output_dir {tmp_dir}
|
||||||
|
--with_tracking
|
||||||
|
--checkpointing_steps 1
|
||||||
""".split()
|
""".split()
|
||||||
|
|
||||||
|
if is_cuda_and_apex_available():
|
||||||
|
testargs.append("--fp16")
|
||||||
|
|
||||||
_ = subprocess.run(self._launch_args + testargs, stdout=subprocess.PIPE)
|
_ = subprocess.run(self._launch_args + testargs, stdout=subprocess.PIPE)
|
||||||
result = get_results(tmp_dir)
|
result = get_results(tmp_dir)
|
||||||
self.assertGreaterEqual(result["eval_accuracy"], 0.50)
|
# The base model scores a 25%
|
||||||
self.assertTrue(os.path.exists(os.path.join(tmp_dir, "epoch_0")))
|
self.assertGreaterEqual(result["eval_accuracy"], 0.625)
|
||||||
|
self.assertTrue(os.path.exists(os.path.join(tmp_dir, "step_1")))
|
||||||
self.assertTrue(os.path.exists(os.path.join(tmp_dir, "image_classification_no_trainer")))
|
self.assertTrue(os.path.exists(os.path.join(tmp_dir, "image_classification_no_trainer")))
|
||||||
|
|||||||
Reference in New Issue
Block a user