Views
No views yet
| Task | Validation Accuracy |
|---|---|
| Weather | 68.44% |
| Time of day | 82.57% |
| Scene type | 63.49% |
| Average | 71.50% |
pip install torch torchvision transformers pillow1from transformers import AutoModel, AutoConfig
2from PIL import Image
3import torch
4
5# Load the model
6model = AutoModel.from_pretrained("your-username/bdd100k-multitask-resnet18", trust_remote_code=True)
7
8# Load and predict on an image
9image = Image.open("path/to/your/image.jpg")
10predictions = model.predict(image)
11
12print(f"Weather: {predictions['weather']['label']} (confidence: {predictions['weather']['confidence']:.3f})")
13print(f"Time of day: {predictions['timeofday']['label']} (confidence: {predictions['timeofday']['confidence']:.3f})")
14print(f"Scene: {predictions['scene']['label']} (confidence: {predictions['scene']['confidence']:.3f})")1from PIL import Image
2
3# Load multiple images
4images = [Image.open(f"image_{i}.jpg") for i in range(3)]
5
6# Predict on batch
7predictions = model.predict(images)
8
9for i, pred in enumerate(predictions):
10 print(f"Image {i+1}:")
11 print(f" Weather: {pred['weather']['label']}")
12 print(f" Time of day: {pred['timeofday']['label']}")
13 print(f" Scene: {pred['scene']['label']}")1import torch
2from torchvision import transforms
3
4# Prepare image
5transform = transforms.Compose([
6 transforms.Resize((224, 224)),
7 transforms.ToTensor(),
8 transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
9])
10
11image_tensor = transform(image).unsqueeze(0)
12
13# Forward pass
14model.eval()
15with torch.no_grad():
16 outputs = model(image_tensor)
17
18 weather_probs = torch.softmax(outputs['weather_logits'], dim=1)
19 timeofday_probs = torch.softmax(outputs['timeofday_logits'], dim=1)
20 scene_probs = torch.softmax(outputs['scene_logits'], dim=1)1@inproceedings{yu2020bdd100k,
2 title={BDD100K: A diverse driving dataset for heterogeneous multitask learning},
3 author={Yu, Fisher and Chen, Haofeng and Wang, Xin and Xian, Wenqi and Chen, Yingying and Liu, Fangchen and Madhavan, Vashisht and Darrell, Trevor},
4 booktitle={Proceedings of the IEEE/CVF conference on computer vision and pattern recognition},
5 pages={2636--2645},
6 year={2020}
7}