Spaces:
Sleeping
Sleeping
test update for png support
Browse files
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(
|
60 |
user_agent = {'User-agent': 'gradio-app'}
|
61 |
-
response = requests.get(
|
62 |
-
return
|
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 =
|
70 |
-
im
|
71 |
-
im =
|
|
|
72 |
shape = torch.from_numpy(np.array(im_shp))
|
73 |
-
return transform(im).unsqueeze(0), shape.unsqueeze(0)
|
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):
|