KingNish commited on
Commit
22b8c91
1 Parent(s): 0af2d38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -14,10 +14,12 @@ import uuid
14
 
15
  torch.set_float32_matmul_precision("medium")
16
 
 
 
17
  birefnet = AutoModelForImageSegmentation.from_pretrained(
18
  "ZhengPeng7/BiRefNet", trust_remote_code=True
19
  )
20
- birefnet.to("cuda")
21
  transform_image = transforms.Compose(
22
  [
23
  transforms.Resize((1024, 1024)),
@@ -132,6 +134,7 @@ def process(image, bg):
132
 
133
 
134
  with gr.Blocks(theme=gr.themes.Ocean()) as demo:
 
135
  with gr.Row():
136
  in_video = gr.Video(label="Input Video", interactive=True)
137
  stream_image = gr.Image(label="Streaming Output", visible=False)
 
14
 
15
  torch.set_float32_matmul_precision("medium")
16
 
17
+ device = "cuda" if torch.cuda.is_available() else "cpu"
18
+
19
  birefnet = AutoModelForImageSegmentation.from_pretrained(
20
  "ZhengPeng7/BiRefNet", trust_remote_code=True
21
  )
22
+ birefnet.to(device)
23
  transform_image = transforms.Compose(
24
  [
25
  transforms.Resize((1024, 1024)),
 
134
 
135
 
136
  with gr.Blocks(theme=gr.themes.Ocean()) as demo:
137
+ gr.Markdown("# Video Background Remover & Changer\n### You can replace image background with any color, image or video.\nNOTE: As this Space is running on ZERO GPU it has limit. It can handle approx 200frmaes at once. So, if you have big video than use small chunks or Duplicate this space.")
138
  with gr.Row():
139
  in_video = gr.Video(label="Input Video", interactive=True)
140
  stream_image = gr.Image(label="Streaming Output", visible=False)