Skip to content
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

Fix format #615

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ REAL_CLONE_URL = $(if $(CLONE_URL),$(CLONE_URL),$(DEFAULT_CLONE_URL))
# Run code quality checks
style_check:
black --check .
ruff .
ruff check .

style:
black .
ruff . --fix
ruff check . --fix

# Run tests for the library
test:
Expand Down
131 changes: 66 additions & 65 deletions examples/openvino/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import unittest
from unittest.mock import patch


SRC_DIRS = [
os.path.join(os.path.dirname(__file__), dirname)
for dirname in [
Expand All @@ -29,39 +30,39 @@
sys.path.extend(SRC_DIRS)

if SRC_DIRS is not None:
import run_image_classification
import run_audio_classification
import run_glue
import run_image_classification
import run_qa


class TestExamples(unittest.TestCase):
def test_audio_classification(self):
with tempfile.TemporaryDirectory() as tmp_dir:
test_args = f"""
run_audio_classification.py
--model_name_or_path hf-internal-testing/tiny-random-Wav2Vec2Model
--nncf_compression_config examples/openvino/audio-classification/configs/wav2vec2-base-qat.json
--dataset_name superb
--dataset_config_name ks
--max_train_samples 10
--max_eval_samples 2
--remove_unused_columns False
--do_train
--learning_rate 3e-5
--max_length_seconds 1
--attention_mask False
--warmup_ratio 0.1
--num_train_epochs 1
--gradient_accumulation_steps 1
--dataloader_num_workers 1
--logging_strategy steps
--logging_steps 1
--evaluation_strategy epoch
--save_strategy epoch
--load_best_model_at_end False
run_audio_classification.py
--model_name_or_path hf-internal-testing/tiny-random-Wav2Vec2Model
--nncf_compression_config examples/openvino/audio-classification/configs/wav2vec2-base-qat.json
--dataset_name superb
--dataset_config_name ks
--max_train_samples 10
--max_eval_samples 2
--remove_unused_columns False
--do_train
--learning_rate 3e-5
--max_length_seconds 1
--attention_mask False
--warmup_ratio 0.1
--num_train_epochs 1
--gradient_accumulation_steps 1
--dataloader_num_workers 1
--logging_strategy steps
--logging_steps 1
--evaluation_strategy epoch
--save_strategy epoch
--load_best_model_at_end False
--seed 42
--output_dir {tmp_dir}
--output_dir {tmp_dir}
--overwrite_output_dir
""".split()

Expand All @@ -71,21 +72,21 @@ def test_audio_classification(self):
def test_image_classification(self):
with tempfile.TemporaryDirectory() as tmp_dir:
test_args = f"""
run_image_classification.py
--model_name_or_path nateraw/vit-base-beans
--dataset_name beans
--max_train_samples 10
--max_eval_samples 2
--remove_unused_columns False
run_image_classification.py
--model_name_or_path nateraw/vit-base-beans
--dataset_name beans
--max_train_samples 10
--max_eval_samples 2
--remove_unused_columns False
--do_train
--do_eval
--learning_rate 2e-5
--num_train_epochs 1
--logging_strategy steps
--logging_steps 1
--evaluation_strategy epoch
--save_strategy epoch
--save_total_limit 1
--do_eval
--learning_rate 2e-5
--num_train_epochs 1
--logging_strategy steps
--logging_steps 1
--evaluation_strategy epoch
--save_strategy epoch
--save_total_limit 1
--seed 1337
--output_dir {tmp_dir}
""".split()
Expand All @@ -95,23 +96,23 @@ def test_image_classification(self):

def test_text_classification(self):
with tempfile.TemporaryDirectory() as tmp_dir:
test_args = f"""
run_glue.py
--model_name_or_path hf-internal-testing/tiny-random-DistilBertForSequenceClassification
--task_name sst2
--max_train_samples 10
--max_eval_samples 2
--overwrite_output_dir
test_args = f"""
run_glue.py
--model_name_or_path hf-internal-testing/tiny-random-DistilBertForSequenceClassification
--task_name sst2
--max_train_samples 10
--max_eval_samples 2
--overwrite_output_dir
--do_train
--do_eval
--max_seq_length 128
--learning_rate 1e-5
--optim adamw_torch
--num_train_epochs 1
--logging_steps 1
--evaluation_strategy steps
--eval_steps 1
--save_strategy epoch
--do_eval
--max_seq_length 128
--learning_rate 1e-5
--optim adamw_torch
--num_train_epochs 1
--logging_steps 1
--evaluation_strategy steps
--eval_steps 1
--save_strategy epoch
--seed 42
--output_dir {tmp_dir}
""".split()
Expand All @@ -122,17 +123,17 @@ def test_text_classification(self):
def test_question_answering(self):
with tempfile.TemporaryDirectory() as tmp_dir:
test_args = f"""
run_qa.py
--model_name_or_path hf-internal-testing/tiny-random-DistilBertForQuestionAnswering
--dataset_name squad
--do_train
--do_eval
--max_train_samples 10
--max_eval_samples 2
--learning_rate 3e-5
--num_train_epochs 1
--max_seq_length 384
--doc_stride 128
run_qa.py
--model_name_or_path hf-internal-testing/tiny-random-DistilBertForQuestionAnswering
--dataset_name squad
--do_train
--do_eval
--max_train_samples 10
--max_eval_samples 2
--learning_rate 3e-5
--num_train_epochs 1
--max_seq_length 384
--doc_stride 128
--overwrite_output_dir
--output_dir {tmp_dir}
""".split()
Expand All @@ -142,4 +143,4 @@ def test_question_answering(self):


if __name__ == "__main__":
unittest.main()
unittest.main()
8 changes: 2 additions & 6 deletions notebooks/openvino/stable_diffusion_optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@
"metadata": {},
"outputs": [],
"source": [
"quantized_pipe = OVStableDiffusionPipeline.from_pretrained(\n",
" \"OpenVINO/Stable-Diffusion-Pokemon-en-quantized\", compile=False\n",
")\n",
"quantized_pipe = OVStableDiffusionPipeline.from_pretrained(\"OpenVINO/Stable-Diffusion-Pokemon-en-quantized\", compile=False)\n",
"quantized_pipe.reshape(batch_size=1, height=512, width=512, num_images_per_prompt=1)\n",
"quantized_pipe.compile()"
]
Expand Down Expand Up @@ -104,9 +102,7 @@
"metadata": {},
"outputs": [],
"source": [
"optimized_pipe = OVStableDiffusionPipeline.from_pretrained(\n",
" \"OpenVINO/stable-diffusion-pokemons-tome-quantized\", compile=False\n",
")\n",
"optimized_pipe = OVStableDiffusionPipeline.from_pretrained(\"OpenVINO/stable-diffusion-pokemons-tome-quantized\", compile=False)\n",
"optimized_pipe.reshape(batch_size=1, height=512, width=512, num_images_per_prompt=1)\n",
"optimized_pipe.compile()"
]
Expand Down
Loading