fffiloni commited on
Commit
1417c59
·
verified ·
1 Parent(s): 8ec2392

change gradio matte api behavior

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -6,11 +6,12 @@ import cv2
6
  from PIL import Image
7
  from moviepy.editor import *
8
  from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
9
- from gradio_client import Client
10
  import gradio as gr
11
 
 
12
 
13
- matte_client = Client("https://fffiloni-video-matting-anything.hf.space/")
14
 
15
  # execute a CLI command
16
  def execute_command(command: str) -> None:
@@ -160,11 +161,12 @@ def get_frames(video_in, img_type):
160
 
161
  def get_matte(video_in, subject_to_remove):
162
  print("Trying to call video matting")
 
163
  result = matte_client.predict(
164
- f"{video_in}", # str (filepath on your computer (or URL) of file) in 'parameter_4' Video component
165
- 10, # int | float (numeric value between 0 and 10) in 'Cut video at (s)' Slider component
166
- f"{subject_to_remove}", # str in 'Text prompt' Textbox component
167
- "", # str in 'Background prompt' Textbox component
168
  api_name="/go_matte"
169
  )
170
  print(result)
 
6
  from PIL import Image
7
  from moviepy.editor import *
8
  from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
9
+
10
  import gradio as gr
11
 
12
+ from gradio_client import Client, handle_file
13
 
14
+ matte_client = Client("fffiloni/Video-Matting-Anything")
15
 
16
  # execute a CLI command
17
  def execute_command(command: str) -> None:
 
161
 
162
  def get_matte(video_in, subject_to_remove):
163
  print("Trying to call video matting")
164
+
165
  result = matte_client.predict(
166
+ video_in={"video":handle_file(video_in)},
167
+ trim_value=10,
168
+ prompt=subject_to_remove,
169
+ background_prompt="",
170
  api_name="/go_matte"
171
  )
172
  print(result)