Issue with HuggingFace Inference API for ViT Model - “image-feature-extraction” Error

41 views Asked by At

I’m experiencing an issue with the inference API for my Vision Transformer (ViT) model, rshrott/vit-base-renovation2.

https://huggingface.co/rshrott/vit-base-renovation2

When I attempt to use the API, I receive the following error:

{
“error”: "HfApiJson(Deserialize(Error(“unknown variant image-feature-extraction, expected one of audio-classification, audio-to-audio, audio-source-separation, automatic-speech-recognition, feature-extraction, text-classification, token-classification, question-answering, translation, summarization, text-generation, text2text-generation, fill-mask, zero-shot-classification, zero-shot-image-classification, conversational, table-question-answering, image-classification, image-segmentation, image-to-text, text-to-speech, … visual-question-answering, video-classification, document-question-answering, image-to-image, depth-estimation, line: 1, column: 318)))”
}

Interestingly, when I use the transformers pipeline directly in Python, the model works as expected:

from transformers import pipeline
from PIL import Image
import requests

pipe = pipeline(model=“rshrott/vit-base-renovation2”)
url = 'https://example.com/image.jpeg'
image = Image.open(requests.get(url, stream=True).raw)
preds = pipe(image)

This code runs without any issues and returns the expected predictions. However, the same model encounters an error when used through the inference API. I suspect there might be a configuration issue related to the expected task type, but I’m not sure how to resolve it.

Why is this error occurring and how can I fix it? I’ve checked the model card and configuration, but I can’t seem to find where “image-feature-extraction” is coming from or why it’s expected.

1

There are 1 answers

0
Hossam_Asr On

i don't know what really happen but i had same issue and retrained my model but with different name and without name of model it self like this

args = TrainingArguments(
    f"NameOfYourModel",
    remove_unused_columns=False,
    evaluation_strategy = "epoch",
    save_strategy = "epoch",
    learning_rate=5e-5,
    per_device_train_batch_size=batch_size,
    gradient_accumulation_steps=4,
    per_device_eval_batch_size=batch_size,
    num_train_epochs=4,
    warmup_ratio=0.1,
    logging_steps=10,
    load_best_model_at_end=True,
    metric_for_best_model="accuracy",
    push_to_hub=True,
)

AND it worked! sorry for no more detailed info about this issue^_^