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

SparseZoo V2 Compatibility #1233

Merged
merged 6 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions src/deepsparse/transformers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
_LOGGER = get_main_logger()

_MODEL_DIR_ONNX_NAME = "model.onnx"
_MODEL_DIR_CONFIG_NAME = "config.json"
_MODEL_DIR_TOKENIZER_NAME = "tokenizer.json"
_MODEL_DIR_TOKENIZER_CONFIG_NAME = "tokenizer_config.json"
_MODEL_DIR_CONFIG_NAME = "deployment/config.json"
_MODEL_DIR_TOKENIZER_NAME = "deployment/tokenizer.json"
_MODEL_DIR_TOKENIZER_CONFIG_NAME = "deployment/tokenizer_config.json"


def get_onnx_path(model_path: str) -> str:
Expand Down
11 changes: 6 additions & 5 deletions tests/deepsparse/image_classification/test_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ def test_image_classification_pipeline_preprocessing(
ic_pipeline = Pipeline.create("image_classification", model_path=zoo_stub)
zoo_model = Model(zoo_stub)
data_originals_path = None
if zoo_model.sample_originals is not None:
if not zoo_model.sample_originals.files:
zoo_model.sample_originals.unzip()
data_originals_path = zoo_model.sample_originals.path
if zoo_model.sample_inputs is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not have sample_originals anymore?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some models do not have originals.

if not zoo_model.sample_inputs.files:
zoo_model.sample_inputs.unzip()
data_originals_path = zoo_model.sample_inputs.path
for idx, sample in enumerate(load_numpy_list(data_originals_path)):
image_raw = list(sample.values())[0]
image_raw = list(sample.values())[0].astype(numpy.uint8)
image_raw = numpy.transpose(image_raw, axes=[1, 2, 0])
image_raw = Image.fromarray(image_raw)

preprocessed_image_pipeline = ic_pipeline.process_inputs(
Expand Down
6 changes: 4 additions & 2 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ def predownload_stub(stub: str, copy_framework_files: bool = False) -> Model:
model_path = model.path
if copy_framework_files:
# required for `deepsparse.transformers.run_inference` on local model files
config_path = model.deployment.default.get_file("config.json").path
tokenizer_config_path = model.deployment.default.get_file("tokenizer.json").path
config_path = model.deployment.default.get_file("deployment/config.json").path
tokenizer_config_path = model.deployment.default.get_file(
"deployment/tokenizer.json"
).path
shutil.copy(config_path, model_path)
shutil.copy(tokenizer_config_path, model_path)

Expand Down
Loading