Fix: Align model and input data types to float16 for inference
#9
by
anon-repair-bot
- opened
Description
This PR fixes a runtime error in the example code caused by a mismatch between the input tensor type and the model weights during inference.
Changes
Converted the model to float16:
model = model.to("cuda").half()Converted float32 input tensors from the processor to float16:
inputs = {k: v.half() if isinstance(v, torch.Tensor) and v.dtype == torch.float32 else v for k, v in inputs.items()}
Testing
The code has been successfully tested and runs without error.
Note
This contribution is part of an ongoing research initiative to systematically identify and correct faulty example code in Hugging Face Model Cards.
We would appreciate a timely review and integration of this patch to support code reliability and enhance reproducibility for downstream users.