SamDaLamb commited on
Commit
7715280
·
verified ·
1 Parent(s): f11b0b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -35,8 +35,7 @@ model.eval()
35
  # transforms.Resize((512,640)),
36
  # transforms.ToTensor()
37
  # ])
38
- transform = transforms.Compose([
39
- transforms.ToPILImage(), # Ensure input is a PIL image
40
  transforms.Resize((512, 640)),
41
  transforms.ToTensor()
42
  ])
@@ -49,20 +48,24 @@ OBJECT_NAMES = ['enemies']
49
 
50
 
51
  def detect_objects_in_image(image):
 
52
  print(type(image))
53
  print(np.ndarray.view(image))
54
- img_tensor = transform(image).unsqueeze(0)
 
55
  print(image.size)
56
  if isinstance(image, np.ndarray):
57
  print("Converting NumPy array to PIL Image")
58
  image = Image.fromarray(image)
59
  print(image.size)
 
60
  orig_w, orig_h = image.size
61
  print("passed1")
62
 
63
-
64
  with torch.no_grad():
65
  pred = model(img_tensor)[0]
 
66
  print("Passed2")
67
 
68
  if isinstance(pred[0], torch.Tensor):
 
35
  # transforms.Resize((512,640)),
36
  # transforms.ToTensor()
37
  # ])
38
+ transform = transforms.Compose([ # Ensure input is a PIL image
 
39
  transforms.Resize((512, 640)),
40
  transforms.ToTensor()
41
  ])
 
48
 
49
 
50
  def detect_objects_in_image(image):
51
+
52
  print(type(image))
53
  print(np.ndarray.view(image))
54
+
55
+
56
  print(image.size)
57
  if isinstance(image, np.ndarray):
58
  print("Converting NumPy array to PIL Image")
59
  image = Image.fromarray(image)
60
  print(image.size)
61
+ img_tensor = transform(image).unsqueeze(0)
62
  orig_w, orig_h = image.size
63
  print("passed1")
64
 
65
+ print(torch.no_grad())
66
  with torch.no_grad():
67
  pred = model(img_tensor)[0]
68
+
69
  print("Passed2")
70
 
71
  if isinstance(pred[0], torch.Tensor):