Guill-Bla commited on
Commit
ef5ce51
·
verified ·
1 Parent(s): de2943e

Update tasks/image.py

Browse files
Files changed (1) hide show
  1. tasks/image.py +3 -3
tasks/image.py CHANGED
@@ -50,13 +50,13 @@ class SmokeDataset(Dataset):
50
  image = example["image"]
51
  annotation = example.get("annotations", "").strip()
52
 
53
- # Resize and preprocess the image directly here
54
  image = image.resize((512, 512))
55
  image = np.array(image)[:, :, ::-1] # Convert RGB to BGR
56
  image = np.array(image, dtype=np.float32) / 255.0
57
 
58
- # Return both the preprocessed image and annotation
59
- return torch.tensor(image).permute(2, 0, 1), annotation
60
 
61
 
62
  def preprocess(image):
 
50
  image = example["image"]
51
  annotation = example.get("annotations", "").strip()
52
 
53
+ # Resize and preprocess the image
54
  image = image.resize((512, 512))
55
  image = np.array(image)[:, :, ::-1] # Convert RGB to BGR
56
  image = np.array(image, dtype=np.float32) / 255.0
57
 
58
+ # Return both the preprocessed image tensor and annotation
59
+ return torch.tensor(image, dtype=torch.float32).permute(2, 0, 1), annotation
60
 
61
 
62
  def preprocess(image):