Replies: 6 comments
-
The models on huggingface hub are not TorchScript model. You need trace the model into TorchScript or convert it to onnx before it can be loaded with DJL. See: https://docs.djl.ai/master/docs/pytorch/how_to_convert_your_model_to_torchscript.html |
Beta Was this translation helpful? Give feedback.
-
djl://ai.djl.huggingface.pytorch/ is a model zoo that we manually traced the model from Huggingface into torchscript model. It only covers a limited set of models. |
Beta Was this translation helpful? Give feedback.
-
thank you, i am trying the tracing tutorial now
could you please give me any hint for line: example = torch.rand(1, 3, 224, 224) ? |
Beta Was this translation helpful? Give feedback.
-
The example we provide is specific for image classification model. We use You need use an input that matches your model. Here is another example for NLP models: https://github.com/deepjavalibrary/djl/blob/master/extensions/tokenizers/src/main/python/huggingface_converter.py#L87 |
Beta Was this translation helpful? Give feedback.
-
I have followed different urls in net using the trace version i managed to generate a pt file with example=input_values, but i think it was badly generated using return_dict = false at model, or strict=False at trace --> logits isnt there, then some ndarray or list was null when using in djl. i also managed to generate some onnx model, but it wasn't usable somehow (also same null ndarray i think)
|
Beta Was this translation helpful? Give feedback.
-
I found a tool to generate onnx model from huggingface
so export worked and created onnxOptimum folder, in there was the onnx model, also vocab.json, which are the vietnamese alphabet. i checked with predicted_ids , replace predicted ids with number in vocab.json gave me the correct sentence from audio file. from above console i saw this: -[x] values not close enough, max diff: 4.9054622650146484e-05 (atol: 1e-05) so i zipped the file and load it using djl
SpeechRecognitionTranslatorFactory will create SpeechRecognitionTranslator which extends NoBatchifyTranslator processOutput(TranslatorContext ctx, NDList list) throws Exception { in python: in djl processOutput the NDList has tensor something during debug, and i saw the shape there is similar to logits shape in python. so i guess here instead of return list.get(0).toStringArray()[0] any idea? |
Beta Was this translation helpful? Give feedback.
-
Hi DJl Community,
I'm trying to do the speech to text stuff. I saw that using djl one can load huggingface model which use pretrained wav2vec.
from example of speech recognisation i saw that this model was use:
Link1: https://resources.djl.ai/test-models/pytorch/wav2vec2.zip
Beta Was this translation helpful? Give feedback.
All reactions