wangjin2000 commited on
Commit
548271e
·
verified ·
1 Parent(s): 80511dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -53,13 +53,14 @@ def preprocess_image(image):
53
  #img0 = cv2.imread(image_path)
54
  img0 = letterbox(image, 640, stride=32, auto=True)[0] # Resize and pad to 640x640
55
  img = letterbox(img0, 640, stride=32, auto=True)[0] # Resize and pad to 640x640
56
- print("in preprocess:",img.shape)
57
- img = img.transpose(2, 0, 1)[::-1] # Convert BGR to RGB, to 3x416x416
58
  img = np.ascontiguousarray(img)
59
  img = torch.from_numpy(img).to(device)
60
  img = img.float() # uint8 to fp16/32
61
  img /= 255.0 # 0 - 255 to 0.0 - 1.0
62
  if img.ndimension() == 3:
 
63
  img = img.unsqueeze(0)
64
  return img, img0
65
 
 
53
  #img0 = cv2.imread(image_path)
54
  img0 = letterbox(image, 640, stride=32, auto=True)[0] # Resize and pad to 640x640
55
  img = letterbox(img0, 640, stride=32, auto=True)[0] # Resize and pad to 640x640
56
+ #print("in preprocess:",img.shape)
57
+ #img = img.transpose(2, 0, 1)[::-1] # Convert BGR to RGB, to 3x416x416
58
  img = np.ascontiguousarray(img)
59
  img = torch.from_numpy(img).to(device)
60
  img = img.float() # uint8 to fp16/32
61
  img /= 255.0 # 0 - 255 to 0.0 - 1.0
62
  if img.ndimension() == 3:
63
+ img = img.transpose(2, 0, 1)[::-1] # Convert BGR to RGB,
64
  img = img.unsqueeze(0)
65
  return img, img0
66