Nesne tespiti
Bu egzersizde, daha önce kullandığın flickr veri kümesini tekrar kullanacaksın; bu veri kümesinde 30.000 görüntü ve bunlara ait altyazılar bulunur. Şimdi modelin tespit ettiği nesnelerin sınırlayıcı kutularını bulacaksın.

Örnek görüntü (image) ve boru hattı modülü (pipeline) yüklendi.
Bu egzersiz, kursun bir parçasıdır
Hugging Face ile Multi-Modal Modeller
Egzersiz talimatları
facebook/detr-resnet-50önceden eğitilmiş modeliyleobject-detectionboru hattını yükle.- Tespit edilen nesnenin
labelbilgisini bul. - Tespit edilen nesnenin ilgili güven puanını (
score) bul. - Tespit edilen nesnenin sınırlayıcı kutu (
box) koordinatlarını bul.
Uygulamalı etkileşimli egzersiz
Bu egzersizi bu örnek kodu tamamlayarak deneyin.
# Load the object-detection pipeline
pipe = pipeline("____", "____", revision="no_timm")
pred = pipe(image)
outputs = pipe(image)
for n, obj in enumerate(outputs):
# Find the detected label
label = ____
# Find the confidence score of the prediction
confidence = ____
# Obtain the bounding box coordinates
box = ____
plot_args = {"linewidth": 1, "edgecolor": colors[n], "facecolor": 'none'}
rect = patches.Rectangle((box['xmin'], box['ymin']), box['xmax']-box['xmin'], box['ymax']-box['ymin'], **plot_args)
ax.add_patch(rect)
print(f"Detected {label} with confidence {confidence:.2f} at ({box['xmin']}, {box['ymin']}) to ({box['xmax']}, {box['ymax']})")
plt.show()