Spaces:
Runtime error
Runtime error
jhj0517
commited on
Commit
•
e1db3fe
1
Parent(s):
8ce80f3
Enable image as input
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ from modules.model_downloader import DEFAULT_MODEL_TYPE
|
|
10 |
from modules.paths import (OUTPUT_DIR, OUTPUT_PSD_DIR, SAM2_CONFIGS_DIR, TEMP_DIR, OUTPUT_FILTER_DIR)
|
11 |
from modules.utils import open_folder
|
12 |
from modules.constants import (AUTOMATIC_MODE, BOX_PROMPT_MODE, PIXELIZE_FILTER, COLOR_FILTER, DEFAULT_COLOR,
|
13 |
-
DEFAULT_PIXEL_SIZE)
|
14 |
from modules.video_utils import extract_frames, extract_sound, get_frames_from_dir, clean_temp_dir
|
15 |
|
16 |
|
@@ -28,12 +28,12 @@ class App:
|
|
28 |
self.default_pixel_size = DEFAULT_PIXEL_SIZE
|
29 |
default_param_config_path = os.path.join(SAM2_CONFIGS_DIR, "default_hparams.yaml")
|
30 |
with open(default_param_config_path, 'r') as file:
|
31 |
-
self.
|
32 |
|
33 |
def mask_parameters(self,
|
34 |
hparams: Optional[Dict] = None):
|
35 |
if hparams is None:
|
36 |
-
hparams = self.
|
37 |
mask_components = [
|
38 |
gr.Number(label="points_per_side ", value=hparams["points_per_side"], interactive=True),
|
39 |
gr.Number(label="points_per_batch ", value=hparams["points_per_batch"], interactive=True),
|
@@ -135,10 +135,7 @@ class App:
|
|
135 |
|
136 |
with gr.TabItem("Pixelize Filter"):
|
137 |
with gr.Column():
|
138 |
-
file_vid_input = gr.File(label="Input
|
139 |
-
'.flv', '.webm', '.mkv', '.mpeg',
|
140 |
-
'.mpg', '.m4v', '.3gp', '.ts',
|
141 |
-
'.vob'])
|
142 |
with gr.Row(equal_height=True):
|
143 |
with gr.Column(scale=9):
|
144 |
with gr.Row():
|
@@ -165,9 +162,9 @@ class App:
|
|
165 |
with gr.Row():
|
166 |
btn_generate = gr.Button("GENERATE", variant="primary")
|
167 |
with gr.Row():
|
168 |
-
vid_output = gr.Video(label="Output
|
169 |
with gr.Column():
|
170 |
-
output_file = gr.File(label="Downloadable
|
171 |
btn_open_folder = gr.Button("📁\nOpen Output folder", scale=1)
|
172 |
|
173 |
file_vid_input.change(fn=self.on_video_model_change,
|
|
|
10 |
from modules.paths import (OUTPUT_DIR, OUTPUT_PSD_DIR, SAM2_CONFIGS_DIR, TEMP_DIR, OUTPUT_FILTER_DIR)
|
11 |
from modules.utils import open_folder
|
12 |
from modules.constants import (AUTOMATIC_MODE, BOX_PROMPT_MODE, PIXELIZE_FILTER, COLOR_FILTER, DEFAULT_COLOR,
|
13 |
+
DEFAULT_PIXEL_SIZE, SOUND_FILE_EXT, IMAGE_FILE_EXT, VIDEO_FILE_EXT)
|
14 |
from modules.video_utils import extract_frames, extract_sound, get_frames_from_dir, clean_temp_dir
|
15 |
|
16 |
|
|
|
28 |
self.default_pixel_size = DEFAULT_PIXEL_SIZE
|
29 |
default_param_config_path = os.path.join(SAM2_CONFIGS_DIR, "default_hparams.yaml")
|
30 |
with open(default_param_config_path, 'r') as file:
|
31 |
+
self.default_hparams = yaml.safe_load(file)
|
32 |
|
33 |
def mask_parameters(self,
|
34 |
hparams: Optional[Dict] = None):
|
35 |
if hparams is None:
|
36 |
+
hparams = self.default_hparams["mask_hparams"]
|
37 |
mask_components = [
|
38 |
gr.Number(label="points_per_side ", value=hparams["points_per_side"], interactive=True),
|
39 |
gr.Number(label="points_per_batch ", value=hparams["points_per_batch"], interactive=True),
|
|
|
135 |
|
136 |
with gr.TabItem("Pixelize Filter"):
|
137 |
with gr.Column():
|
138 |
+
file_vid_input = gr.File(label="Input", file_types=IMAGE_FILE_EXT + VIDEO_FILE_EXT)
|
|
|
|
|
|
|
139 |
with gr.Row(equal_height=True):
|
140 |
with gr.Column(scale=9):
|
141 |
with gr.Row():
|
|
|
162 |
with gr.Row():
|
163 |
btn_generate = gr.Button("GENERATE", variant="primary")
|
164 |
with gr.Row():
|
165 |
+
vid_output = gr.Video(label="Output")
|
166 |
with gr.Column():
|
167 |
+
output_file = gr.File(label="Downloadable Output File", scale=9)
|
168 |
btn_open_folder = gr.Button("📁\nOpen Output folder", scale=1)
|
169 |
|
170 |
file_vid_input.change(fn=self.on_video_model_change,
|