我的 Vision Transformer (ViT) 模型 rshrott/vit-base-renovation2 的推理 API 遇到问题。
https://huggingface.co/rshrott/vit-base-renovation2
当我尝试使用 API 时,收到以下错误:
{
“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)))”
}
有趣的是,当我直接在 Python 中使用 Transformers 管道时,模型按预期工作:
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)
此代码运行没有任何问题并返回预期的预测。但是,通过推理 API 使用同一模型时会遇到错误。我怀疑可能存在与预期任务类型相关的配置问题,但我不确定如何解决它。
为什么会出现此错误以及如何修复它?我已经检查了型号卡和配置,但我似乎无法找到“图像特征提取”的来源或原因。
我不知道到底发生了什么,但我遇到了同样的问题,并重新训练了我的模型,但名称不同,并且没有模型名称,就像这样
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,
)
并且成功了! 抱歉,没有关于此问题的更详细信息^_^