wangjin2000 commited on
Commit
cd8d5e0
·
verified ·
1 Parent(s): 5f65abf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -48,9 +48,11 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # Use GPU
48
  model = attempt_load(model_path, device=device) # Placeholder for model loading
49
  model.eval() # Set the model to evaluation mode
50
 
51
- def preprocess_image(image_path):
52
- img0 = cv2.imread(image_path)
53
- img = letterbox(img0, 640, stride=32, auto=True)[0] # Resize and pad to 640x640
 
 
54
  img = img.transpose(2, 0, 1)[::-1] # Convert BGR to RGB, to 3x416x416
55
  img = np.ascontiguousarray(img)
56
  img = torch.from_numpy(img).to(device)
 
48
  model = attempt_load(model_path, device=device) # Placeholder for model loading
49
  model.eval() # Set the model to evaluation mode
50
 
51
+ #def preprocess_image(image_path):
52
+ def preprocess_image(image):
53
+ #img0 = cv2.imread(image_path)
54
+ #img = letterbox(img0, 640, stride=32, auto=True)[0] # Resize and pad to 640x640
55
+ img0 = letterbox(img, 640, stride=32, auto=True)[0] # Resize and pad to 640x640
56
  img = img.transpose(2, 0, 1)[::-1] # Convert BGR to RGB, to 3x416x416
57
  img = np.ascontiguousarray(img)
58
  img = torch.from_numpy(img).to(device)