Я прочитал документацию по API Torchvision с использованием предварительно обученных моделей для обнаружения объектов. Это пример, который они включили: < /p>
from torchvision.io.image import decode_image
from torchvision.models.detection import fasterrcnn_resnet50_fpn_v2, FasterRCNN_ResNet50_FPN_V2_Weights
from torchvision.utils import draw_bounding_boxes
from torchvision.transforms.functional import to_pil_image
img = decode_image("test/assets/encode_jpeg/grace_hopper_517x606.jpg")
# Step 1: Initialize model with the best available weights
weights = FasterRCNN_ResNet50_FPN_V2_Weights.DEFAULT
model = fasterrcnn_resnet50_fpn_v2(weights=weights, box_score_thresh=0.9)
model.eval()
# Step 2: Initialize the inference transforms
preprocess = weights.transforms()
# Step 3: Apply inference preprocessing transforms
batch = [preprocess(img)]
# Step 4: Use the model and visualize the prediction
prediction = model(batch)[0]
labels = [weights.meta["categories"] for i in prediction["labels"]]
box = draw_bounding_boxes(img, boxes=prediction["boxes"],
labels=labels,
colors="red",
width=4, font_size=30)
im = to_pil_image(box.detach())
im.show()
< /code>
На основе этой строки: < /p>
img = decode_image("test/assets/encode_jpeg/grace_hopper_517x606.jpg")
< /code>
Модель использует только одно изображение. Есть ли способ настроить это, чтобы я мог обучить эту модель на нескольких изображениях?
Подробнее здесь: https://stackoverflow.com/questions/796 ... ned-models
Как обучить модель обнаружения объектов, используя предварительно обученные модели Torchvision? ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Получение меток классов моделей из предварительно обученных моделей torchvision
Anonymous » » в форуме Python - 0 Ответы
- 26 Просмотры
-
Последнее сообщение Anonymous
-