Views
No views yet
image: Global scene understanding queriesregion: Localized object detection queriespixel: Fine-grained segmentation queries1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4# Load model and tokenizer
5tokenizer = AutoTokenizer.from_pretrained("beingamanforever/MagCrop-TMRA-v2")
6model = AutoModelForSequenceClassification.from_pretrained("beingamanforever/MagCrop-TMRA-v2")
7
8# Classify query
9query = "Count the number of white cars in the parking lot"
10inputs = tokenizer(query, return_tensors="pt", padding=True, truncation=True)
11
12with torch.no_grad():
13 outputs = model(**inputs)
14 prediction = outputs.logits.argmax(-1).item()
15
16granularity_map = {0: "image", 1: "region", 2: "pixel"}
17print(f"Predicted Granularity: {granularity_map[prediction]}")| Query | Predicted Granularity |
|---|---|
| "Describe the overall landscape" | image |
| "Locate the industrial buildings" | region |
| "Segment individual vehicles in the parking area" | pixel |
| "Count the number of tennis courts" | region |
| "What is the color of the central building's roof?" | pixel |