doevent commited on
Commit
1781b6f
β€’
1 Parent(s): afd2efd

update gradio

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -25,8 +25,6 @@ device = 'cuda' if torch.cuda.is_available() else 'cpu'
25
  # Download official weights
26
  if not os.path.exists("saved_models"):
27
  os.mkdir("saved_models")
28
- # MODEL_PATH_URL = "https://drive.google.com/uc?id=1KyMpRjewZdyYfxHPYcd-ZbanIXtin0Sn"
29
- # gdown.download(MODEL_PATH_URL, "saved_models/isnet.pth", use_cookies=False)
30
  os.system("mv isnet.pth saved_models/")
31
 
32
  class GOSNormalize(object):
@@ -123,13 +121,13 @@ hypar["model"] = ISNetDIS()
123
  net = build_model(hypar, device)
124
 
125
 
126
- def inference(image: Image):
127
  image_path = image
128
 
129
  image_tensor, orig_size = load_image(image_path, hypar)
130
  mask = predict(net, image_tensor, orig_size, hypar, device)
131
 
132
- pil_mask = Image.fromarray(mask).convert("L")
133
  im_rgb = Image.open(image).convert("RGB")
134
 
135
  im_rgba = im_rgb.copy()
@@ -140,7 +138,7 @@ def inference(image: Image):
140
 
141
  title = "Highly Accurate Dichotomous Image Segmentation"
142
  description = "This is an unofficial demo for DIS, a model that can remove the background from a given image. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below.<br>GitHub: https://github.com/xuebinqin/DIS<br>Telegram bot: https://t.me/restoration_photo_bot<br>[![](https://img.shields.io/twitter/follow/DoEvent?label=@DoEvent&style=social)](https://twitter.com/DoEvent)"
143
- article = "<div><center><img src='https://visitor-badge.glitch.me/badge?page_id=max_skobeev_dis_public' alt='visitor badge'></center></div>"
144
 
145
  interface = gr.Interface(
146
  fn=inference,
@@ -151,6 +149,5 @@ interface = gr.Interface(
151
  description=description,
152
  article=article,
153
  allow_flagging='never',
154
- theme="default",
155
  cache_examples=False,
156
- ).launch(enable_queue=True, debug=True)
 
25
  # Download official weights
26
  if not os.path.exists("saved_models"):
27
  os.mkdir("saved_models")
 
 
28
  os.system("mv isnet.pth saved_models/")
29
 
30
  class GOSNormalize(object):
 
121
  net = build_model(hypar, device)
122
 
123
 
124
+ def inference(image):
125
  image_path = image
126
 
127
  image_tensor, orig_size = load_image(image_path, hypar)
128
  mask = predict(net, image_tensor, orig_size, hypar, device)
129
 
130
+ pil_mask = Image.fromarray(mask).convert('L')
131
  im_rgb = Image.open(image).convert("RGB")
132
 
133
  im_rgba = im_rgb.copy()
 
138
 
139
  title = "Highly Accurate Dichotomous Image Segmentation"
140
  description = "This is an unofficial demo for DIS, a model that can remove the background from a given image. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below.<br>GitHub: https://github.com/xuebinqin/DIS<br>Telegram bot: https://t.me/restoration_photo_bot<br>[![](https://img.shields.io/twitter/follow/DoEvent?label=@DoEvent&style=social)](https://twitter.com/DoEvent)"
141
+ article = "<div><center><img src='https://visitor-badge.glitch.me/badge?page_id=max_skobeev_dis_cmp_public' alt='visitor badge'></center></div>"
142
 
143
  interface = gr.Interface(
144
  fn=inference,
 
149
  description=description,
150
  article=article,
151
  allow_flagging='never',
 
152
  cache_examples=False,
153
+ ).queue(concurrency_count=1, api_open=True).launch(show_api=True, show_error=True)