Imadsarvm commited on
Commit
0ce70fb
·
verified ·
1 Parent(s): 032f16e
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -13,14 +13,20 @@ net = BriaRMBG.from_pretrained("briaai/RMBG-1.4")
13
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
14
  net.to(device)
15
 
16
-
 
 
 
 
 
17
  def resize_image(image):
 
 
18
  image = image.convert('RGB')
19
  model_input_size = (1024, 1024)
20
  image = image.resize(model_input_size, Image.BILINEAR)
21
  return image
22
 
23
-
24
  def process(image):
25
 
26
  # prepare input
 
13
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
14
  net.to(device)
15
 
16
+ @functools.lru_cache()
17
+ def get_url_im(url):
18
+ user_agent = {'User-agent': 'gradio-app'}
19
+ response = requests.get(url, headers=user_agent)
20
+ return BytesIO(response.content)
21
+
22
  def resize_image(image):
23
+ image_path = get_url_im(image_path)
24
+ image = Image.open(image_path)
25
  image = image.convert('RGB')
26
  model_input_size = (1024, 1024)
27
  image = image.resize(model_input_size, Image.BILINEAR)
28
  return image
29
 
 
30
  def process(image):
31
 
32
  # prepare input