Model Card for HazardNet-unsloth-v0.4
This model is a fine-tuned version of Qwen/Qwen2-VL-2B-Instruct.
It has been trained using TRL.
Quick start
from transformers import pipeline
from PIL import Image
import requests
from io import BytesIO
hazard_vqa = pipeline(
"visual-question-answering",
model="Tami3/HazardNet"
)
def load_image(image_path=None, image_url=None):
if image_path:
return Image.open(image_path).convert("RGB")
elif image_url:
response = requests.get(image_url)
response.raise_for_status()
return Image.open(BytesIO(response.content)).convert("RGB")
else:
raise ValueError("Provide either image_path or image_url.")
try:
image_path = "path_to_your_ego_car_image.jpg"
image = load_image(image_path=image_path)
except Exception as e:
print(f"Error loading image from path: {e}")
question = "Is there a pedestrian crossing the road ahead?"
try:
result = hazard_vqa(question=question, image=image)
answer = result.get('answer', 'No answer provided.')
score = result.get('score', 0.0)
print("Question:", question)
print("Answer:", answer)
print("Confidence Score:", score)
except Exception as e:
print(f"Error during inference: {e}")
Training procedure
This model was trained with SFT.
Framework versions
- TRL: 0.13.0
- Transformers: 4.47.1
- Pytorch: 2.5.1+cu121
- Datasets: 3.2.0
- Tokenizers: 0.21.0
Citations
Cite TRL as:
@misc{vonwerra2022trl,
title = {{TRL: Transformer Reinforcement Learning}},
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallouédec},
year = 2020,
journal = {GitHub repository},
publisher = {GitHub},
howpublished = {\url{https://github.com/huggingface/trl}}
}