generated from dopt-python/py311
src/dopt_sensor_anomalies/detection.py aktualisiert
This commit is contained in:
parent
cac37a3946
commit
f2302dc90b
@ -265,16 +265,12 @@ def infer_image(
|
||||
torch_device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
||||
model.to(torch_device)
|
||||
|
||||
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # this is optional
|
||||
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
||||
pil_image = Image.fromarray(image_rgb)
|
||||
pil_image = pil_image.convert("RGB")
|
||||
input_tensor = (
|
||||
to_dtype(to_image(pil_image), torch.float32, scale=True)
|
||||
if torch.as_tensor # ?? Question: Wie passt diese Funktion hier rein?
|
||||
# ?? Konvertiert, aber wird zur Evaluation der Aussage genutzt (sollte immer wahr sein?)
|
||||
else np.array(pil_image) / 255.0
|
||||
)
|
||||
# ?? Ist das immer ein Torch-Tensor? Falls nicht, müsste die Methode geändert werden
|
||||
image_np = np.array(pil_image).astype(np.float32) / 255.0
|
||||
input_tensor = torch.from_numpy(image_np).permute(2, 0, 1)
|
||||
|
||||
input_tensor = input_tensor.unsqueeze(0)
|
||||
input_tensor = input_tensor.to(torch_device)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user