Segmentation fault in docker
#10
by
borisgorelik
- opened
Below is a short snippet that uses detr-resnet-50
. The code works ok on my Mac, but when I run it in a docker image (Ubuntu) I get a segmentation fault. Any ideas what's wrong?
##
import requests
from PIL import Image
from transformers import DetrImageProcessor, DetrForObjectDetection
import torch
model_name: str = "facebook/detr-resnet-50"
processor = DetrImageProcessor.from_pretrained(model_name)
model = DetrForObjectDetection.from_pretrained(model_name)
img_url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Celebrating_Raas_lila_festival_in_Bangladesh_11.jpg/640px-Celebrating_Raas_lila_festival_in_Bangladesh_11.jpg'
image = Image.open(requests.get(img_url, stream=True).raw)
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs) # <===== fails with segmentation fault
##
# target_sizes = torch.tensor([image.size[::-1]])
# results = processor.post_process_object_detection(
# outputs, target_sizes=target_sizes, threshold=0.8
# )[0]
# results = {k: v.tolist() for k, v in results.items()}
# results["labels_str"] = [model.config.id2label[l] for l in results["labels"]]
# print(results)