Imadsarvm commited on
Commit
e4f1a57
·
verified ·
1 Parent(s): 07463bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -52,10 +52,15 @@ class GOSNormalize(object):
52
 
53
 
54
  transform = transforms.Compose([GOSNormalize([0.5,0.5,0.5],[1.0,1.0,1.0])])
 
 
 
 
 
55
 
56
  def load_image(im_path, hypar):
57
- im_path = BytesIO(requests.get(im_path).content)
58
- im = im_reader(im_path)
59
  im, im_shp = im_preprocess(im, hypar["cache_size"])
60
  im = torch.divide(im,255.0)
61
  shape = torch.from_numpy(np.array(im_shp))
@@ -155,7 +160,7 @@ article = "<div><center><img src='https://visitor-badge.glitch.me/badge?page_id=
155
 
156
  interface = gr.Interface(
157
  fn=inference,
158
- inputs="textbox",
159
  outputs=["image","image","image"],
160
  title=title,
161
  description=description,
 
52
 
53
 
54
  transform = transforms.Compose([GOSNormalize([0.5,0.5,0.5],[1.0,1.0,1.0])])
55
+ def get_url_im(t):
56
+ user_agent = {'User-agent': 'gradio-app'}
57
+ response = requests.get(t, headers=user_agent)
58
+ return Image.open(BytesIO(response.content))
59
+
60
 
61
  def load_image(im_path, hypar):
62
+ # im_path = BytesIO(requests.get(im_path).content)
63
+ im = get_url_im(im_path)
64
  im, im_shp = im_preprocess(im, hypar["cache_size"])
65
  im = torch.divide(im,255.0)
66
  shape = torch.from_numpy(np.array(im_shp))
 
160
 
161
  interface = gr.Interface(
162
  fn=inference,
163
+ inputs=gr.Textbox(label="Text or Image URL", visible=False, interactive=True),
164
  outputs=["image","image","image"],
165
  title=title,
166
  description=description,