Fix sample code to deploy and inference tasks using audio/image files
I noticed that automated generated snippet on Hugging Face model’s page doesn’t work for models of images/audios.For example, at automatic-speech-recognition task following snippet is produced.Screen Shot 0004-11-04 at 19.06.34927×941 128 KBI use below models for example.huggingface.cofacebook/wav2vec2-large-960h · Hugging FaceWe’re on a journey to advance and democratize artificial intelligence through open source and open science.from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'facebook/wav2vec2-large-960h',
	'HF_TASK':'automatic-speech-recognition'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
	transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
	'inputs': "sample1.flac"
})However, prediction part doesn’t work.For audio/image data, we should use DataSerializer.# deploy model to SageMaker Inference
audio_serializer = DataSerializer(content_type='audio/x-audio')
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge', # ec2 instance type
    serializer=audio_serializer
)

audio_path = "sample1.flac"

res = predictor.predict(data=audio_path)
print(res)How can I update this snippet?
2022-11-15T00:30:53Z
Does anyone know where to contribute that?
2022-11-21T12:53:45Z
@philschmid- what’s the best way to do this?@sohohais happy to provide the correct code snippet, he just needs to know how … Is it possible to raise issues or PRs for this?