New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug with train class method for MobileViTForSemanticSegmentation #30676
Comments
Hi @travisddavies, can you please specify what is going wrong or provide an error traceback? I was able to run the following code import numpy as np
from transformers import MobileViTImageProcessor, MobileViTForSemanticSegmentation
image = np.ones((512, 512, 3), dtype=np.uint8)
mask = np.ones((512, 512), dtype=np.uint8)
image_processor = MobileViTImageProcessor(do_reduce_labels=False)
id2label = {
0: "background",
1: "object",
}
label2id = {v: k for k, v in id2label.items()}
model = MobileViTForSemanticSegmentation.from_pretrained(
"apple/mobilevit-small",
num_labels=2,
id2label=id2label,
label2id=label2id)
# for training mode we need batch size > 1 for batch norm layer, duplicate image and mask
inputs = image_processor(images=[image, image], segmentation_maps=[mask, mask], return_tensors="pt")
model.train()
outputs = model(pixel_values=inputs["pixel_values"], labels=inputs['labels'])
print(outputs.keys())
# >>> odict_keys(['loss', 'logits']) |
That seemed to have worked with that input /usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_token.py:88: UserWarning: |
System Info
transformers
version: 4.38.2Who can help?
@amyeroberts @pacman100
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Expected behavior
outputs should be returned with logits and loss.
The text was updated successfully, but these errors were encountered: