Imadsarvm commited on
Commit
b2e3a42
·
verified ·
1 Parent(s): 7e73e0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -21,7 +21,7 @@ import gdown
21
  import matplotlib.pyplot as plt
22
  import warnings
23
  warnings.filterwarnings("ignore")
24
-
25
  os.system("git clone https://github.com/xuebinqin/DIS")
26
  os.system("mv DIS/IS-Net/* .")
27
 
@@ -53,7 +53,7 @@ class GOSNormalize(object):
53
  transform = transforms.Compose([GOSNormalize([0.5,0.5,0.5],[1.0,1.0,1.0])])
54
 
55
  def load_image(im_path, hypar):
56
- im = im_reader(im_path)
57
  im, im_shp = im_preprocess(im, hypar["cache_size"])
58
  im = torch.divide(im,255.0)
59
  shape = torch.from_numpy(np.array(im_shp))
@@ -132,8 +132,7 @@ net = build_model(hypar, device)
132
 
133
 
134
  def inference(image):
135
- image_path = "1.jpg"
136
- gdown.download(image, image_path, quiet=False)
137
  image_tensor, orig_size = load_image(image_path, hypar)
138
  mask = predict(net, image_tensor, orig_size, hypar, device)
139
 
 
21
  import matplotlib.pyplot as plt
22
  import warnings
23
  warnings.filterwarnings("ignore")
24
+ import requests
25
  os.system("git clone https://github.com/xuebinqin/DIS")
26
  os.system("mv DIS/IS-Net/* .")
27
 
 
53
  transform = transforms.Compose([GOSNormalize([0.5,0.5,0.5],[1.0,1.0,1.0])])
54
 
55
  def load_image(im_path, hypar):
56
+ im = Image.open(requests.get(im_path, stream=True).raw)
57
  im, im_shp = im_preprocess(im, hypar["cache_size"])
58
  im = torch.divide(im,255.0)
59
  shape = torch.from_numpy(np.array(im_shp))
 
132
 
133
 
134
  def inference(image):
135
+ image_path = image
 
136
  image_tensor, orig_size = load_image(image_path, hypar)
137
  mask = predict(net, image_tensor, orig_size, hypar, device)
138