Hali5 commited on
Commit
4990e66
·
1 Parent(s): 7d56ac1

moved resize to tf compose

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -35,6 +35,7 @@ model.eval()
35
 
36
  tf = v2.Compose([
37
  v2.ToImage(),
 
38
  v2.ToDtype(torch.float32, scale=True),
39
  ])
40
 
@@ -42,10 +43,11 @@ tf = v2.Compose([
42
  def predict(image):
43
  if image is None:
44
  return None
45
-
46
- img_resized = image.resize((64, 64), Image.Resampling.LANCZOS)
47
-
48
- img_tensor = tf(img_resized).unsqueeze(0).to(device)
 
49
 
50
  with torch.no_grad():
51
  outputs = model(img_tensor)
 
35
 
36
  tf = v2.Compose([
37
  v2.ToImage(),
38
+ v2.Resize((64, 64)),
39
  v2.ToDtype(torch.float32, scale=True),
40
  ])
41
 
 
43
  def predict(image):
44
  if image is None:
45
  return None
46
+
47
+
48
+ pil_img = Image.fromarray(image.astype('uint8'), 'RGB')
49
+
50
+ img_tensor = tf(pil_img).unsqueeze(0).to(device)
51
 
52
  with torch.no_grad():
53
  outputs = model(img_tensor)