Я хотел запустить свою простую программу обнаружения объектов, но я столкнулся с этой ошибкой < /p>
Я пытаюсь запустить программу Python, которая использует Owl-Vit и устанавливал трансформаторы для этого
, но она дает эту «modulenotfounderror: no module with transformers util» < /p>
Я установил, что это задача.import requests
from PIL import Image
import torch
from transformers import OwlViTProcessor, OwlViTForObjectDetection
import os
fcontent = os.listdir("..\imgs")
processor = OwlViTProcessor.from_pretrained("google/owlvit-base-patch32")
model = OwlViTForObjectDetection.from_pretrained("google/owlvit-base-patch32")
def result(a):
for imag in fcontent:
image = Image.open(imag)
texts = [[a]]
inputs = processor(text=texts, images=image, return_tensors="pt")
outputs = model(**inputs)
# Target image sizes (height, width) to rescale box predictions [batch_size, 2]
target_sizes = torch.Tensor([image.size[::-1]])
# Convert outputs (bounding boxes and class logits) to Pascal VOC format (xmin, ymin, xmax, ymax)
results = processor.post_process_object_detection(outputs=outputs, target_sizes=target_sizes, threshold=0.1)
i = 0 # Retrieve predictions for the first image for the corresponding text queries
text = texts
boxes, scores, labels = results["boxes"], results["scores"], results["labels"]
for box, score, label in zip(boxes, scores, labels):
box = [round(i, 2) for i in box.tolist()]
print(f"Detected {text[label]} with confidence {round(score.item(), 3)} at location {box}")
Подробнее здесь: https://stackoverflow.com/questions/779 ... mers-utils
Modulenotfounderror: нет модуля с именем "transformers.utils" ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Невозможно подавить предупреждение из Transformers/src/transformers/modeling_utils.py.
Anonymous » » в форуме Python - 0 Ответы
- 29 Просмотры
-
Последнее сообщение Anonymous
-