Imadsarvm commited on
Commit
73c2ebf
·
verified ·
1 Parent(s): c893e79

test update for png support

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -56,21 +56,19 @@ class GOSNormalize(object):
56
  transform = transforms.Compose([GOSNormalize([0.5,0.5,0.5],[1.0,1.0,1.0])])
57
 
58
  @functools.lru_cache()
59
- def get_url_im(t):
60
  user_agent = {'User-agent': 'gradio-app'}
61
- response = requests.get(t, headers=user_agent)
62
- return (BytesIO(response.content))
63
-
64
 
65
  def load_image(im_path, hypar):
66
- # im_path = BytesIO(requests.get(im_path).content)
67
-
68
  im_path = get_url_im(im_path)
69
- im = im_reader(im_path)
70
- im, im_shp = im_preprocess(im, hypar["cache_size"])
71
- im = torch.divide(im,255.0)
 
72
  shape = torch.from_numpy(np.array(im_shp))
73
- return transform(im).unsqueeze(0), shape.unsqueeze(0) # make a batch of image, shape
74
 
75
 
76
  def build_model(hypar,device):
 
56
  transform = transforms.Compose([GOSNormalize([0.5,0.5,0.5],[1.0,1.0,1.0])])
57
 
58
  @functools.lru_cache()
59
+ def get_url_im(url):
60
  user_agent = {'User-agent': 'gradio-app'}
61
+ response = requests.get(url, headers=user_agent)
62
+ return BytesIO(response.content)
 
63
 
64
  def load_image(im_path, hypar):
 
 
65
  im_path = get_url_im(im_path)
66
+ im = Image.open(im_path)
67
+ im = im.convert("RGB") # Convert image to RGB
68
+ im, im_shp = im_preprocess(np.array(im), hypar["cache_size"])
69
+ im = torch.divide(im, 255.0)
70
  shape = torch.from_numpy(np.array(im_shp))
71
+ return transform(im).unsqueeze(0), shape.unsqueeze(0)
72
 
73
 
74
  def build_model(hypar,device):