umuthopeyildirim commited on
Commit
f92af9d
1 Parent(s): bd2c8ae

Update image preprocessing in app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -78,7 +78,8 @@ with gr.Blocks(css=css) as demo:
78
  # image = transform({'image': image})['image']
79
  # image = torch.from_numpy(image).unsqueeze(0).to(DEVICE)
80
 
81
- image = torch.from_numpy(image.transpose((2, 0, 1))).to(DEVICE)
 
82
  image = Normalize(mean=[0.485, 0.456, 0.406], std=[
83
  0.229, 0.224, 0.225])(image)
84
  image = torch.from_numpy(image).unsqueeze(0).to(DEVICE)
 
78
  # image = transform({'image': image})['image']
79
  # image = torch.from_numpy(image).unsqueeze(0).to(DEVICE)
80
 
81
+ image = np.asarray(Image.open(image), dtype=np.float32) / 255.0
82
+ image = torch.from_numpy(image.transpose((2, 0, 1)))
83
  image = Normalize(mean=[0.485, 0.456, 0.406], std=[
84
  0.229, 0.224, 0.225])(image)
85
  image = torch.from_numpy(image).unsqueeze(0).to(DEVICE)