Spaces:
Sleeping
Sleeping
Merge branch 'master' into huggingface
Browse files- .github/FUNDING.yml +1 -1
- .github/workflows/publish-docker.yml +37 -0
- app.py +41 -41
- modules/html_constants.py +1 -1
.github/FUNDING.yml
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
4 |
patreon: # Replace with a single Patreon username
|
5 |
open_collective: # Replace with a single Open Collective username
|
6 |
-
ko_fi:
|
7 |
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
8 |
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
9 |
liberapay: # Replace with a single Liberapay username
|
|
|
3 |
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
4 |
patreon: # Replace with a single Patreon username
|
5 |
open_collective: # Replace with a single Open Collective username
|
6 |
+
ko_fi: # Replace with a single Open Kofi username
|
7 |
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
8 |
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
9 |
liberapay: # Replace with a single Liberapay username
|
.github/workflows/publish-docker.yml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Publish to Docker Hub
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- master
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
build-and-push:
|
10 |
+
runs-on: ubuntu-latest
|
11 |
+
|
12 |
+
steps:
|
13 |
+
- name: Log in to Docker Hub
|
14 |
+
uses: docker/login-action@v2
|
15 |
+
with:
|
16 |
+
username: ${{ secrets.DOCKER_USERNAME }}
|
17 |
+
password: ${{ secrets.DOCKER_PASSWORD }}
|
18 |
+
|
19 |
+
- name: Checkout repository
|
20 |
+
uses: actions/checkout@v3
|
21 |
+
|
22 |
+
- name: Set up Docker Buildx
|
23 |
+
uses: docker/setup-buildx-action@v3
|
24 |
+
|
25 |
+
- name: Set up QEMU
|
26 |
+
uses: docker/setup-qemu-action@v3
|
27 |
+
|
28 |
+
- name: Build and push Docker image
|
29 |
+
uses: docker/build-push-action@v5
|
30 |
+
with:
|
31 |
+
context: .
|
32 |
+
file: ./Dockerfile
|
33 |
+
push: true
|
34 |
+
tags: ${{ secrets.DOCKER_USERNAME }}/sam2-playground:latest
|
35 |
+
|
36 |
+
- name: Log out of Docker Hub
|
37 |
+
run: docker logout
|
app.py
CHANGED
@@ -108,48 +108,9 @@ class App:
|
|
108 |
md_header = gr.Markdown(HEADER, elem_id="md_header")
|
109 |
|
110 |
with gr.Tabs():
|
111 |
-
with gr.TabItem("
|
112 |
-
with gr.Row():
|
113 |
-
with gr.Column(scale=5):
|
114 |
-
img_input = gr.Image(label="Input image here", visible=self.default_mode == AUTOMATIC_MODE)
|
115 |
-
img_input_prompter = ImagePrompter(label="Prompt image with Box & Point", type='pil',
|
116 |
-
visible=self.default_mode == BOX_PROMPT_MODE)
|
117 |
-
|
118 |
-
with gr.Column(scale=5):
|
119 |
-
dd_input_modes = gr.Dropdown(label="Image Input Mode", value=self.default_mode,
|
120 |
-
choices=self.image_modes)
|
121 |
-
dd_models = gr.Dropdown(label="Model", value=DEFAULT_MODEL_TYPE,
|
122 |
-
choices=self.sam_inf.available_models)
|
123 |
-
|
124 |
-
with gr.Accordion("Mask Parameters", open=False, visible=self.default_mode == AUTOMATIC_MODE) as acc_mask_hparams:
|
125 |
-
mask_hparams_component = self.mask_generation_parameters(_mask_hparams)
|
126 |
-
|
127 |
-
cb_multimask_output = gr.Checkbox(label="multimask_output", value=_mask_hparams["multimask_output"])
|
128 |
-
|
129 |
-
with gr.Row():
|
130 |
-
btn_generate = gr.Button("GENERATE", variant="primary")
|
131 |
-
with gr.Row():
|
132 |
-
gallery_output = gr.Gallery(label="Output images will be shown here")
|
133 |
-
with gr.Column():
|
134 |
-
output_file = gr.File(label="Generated psd file", scale=9)
|
135 |
-
btn_open_folder = gr.Button("📁\nOpen PSD folder", scale=1)
|
136 |
-
|
137 |
-
sources = [img_input, img_input_prompter, dd_input_modes]
|
138 |
-
model_params = [dd_models]
|
139 |
-
mask_hparams = mask_hparams_component + [cb_multimask_output]
|
140 |
-
input_params = sources + model_params + mask_hparams
|
141 |
-
|
142 |
-
btn_generate.click(fn=self.sam_inf.divide_layer,
|
143 |
-
inputs=input_params, outputs=[gallery_output, output_file])
|
144 |
-
btn_open_folder.click(fn=lambda: open_folder(os.path.join(self.args.output_dir, "psd")),
|
145 |
-
inputs=None, outputs=None)
|
146 |
-
dd_input_modes.change(fn=self.on_mode_change,
|
147 |
-
inputs=[dd_input_modes],
|
148 |
-
outputs=[img_input, img_input_prompter, acc_mask_hparams])
|
149 |
-
|
150 |
-
with gr.TabItem("Pixelize Filter"):
|
151 |
with gr.Column():
|
152 |
-
file_vid_input = gr.File(label="Input Video", file_types=IMAGE_FILE_EXT + VIDEO_FILE_EXT)
|
153 |
with gr.Row(equal_height=True):
|
154 |
with gr.Column(scale=9):
|
155 |
with gr.Row():
|
@@ -207,6 +168,45 @@ class App:
|
|
207 |
inputs=None,
|
208 |
outputs=None)
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
self.demo.queue().launch(
|
211 |
inbrowser=self.args.inbrowser,
|
212 |
share=self.args.share,
|
|
|
108 |
md_header = gr.Markdown(HEADER, elem_id="md_header")
|
109 |
|
110 |
with gr.Tabs():
|
111 |
+
with gr.TabItem("Filter to Video"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
with gr.Column():
|
113 |
+
file_vid_input = gr.File(label="Upload Input Video", file_types=IMAGE_FILE_EXT + VIDEO_FILE_EXT)
|
114 |
with gr.Row(equal_height=True):
|
115 |
with gr.Column(scale=9):
|
116 |
with gr.Row():
|
|
|
168 |
inputs=None,
|
169 |
outputs=None)
|
170 |
|
171 |
+
with gr.TabItem("Layer Divider"):
|
172 |
+
with gr.Row():
|
173 |
+
with gr.Column(scale=5):
|
174 |
+
img_input = gr.Image(label="Input image here", visible=self.default_mode == AUTOMATIC_MODE)
|
175 |
+
img_input_prompter = ImagePrompter(label="Prompt image with Box & Point", type='pil',
|
176 |
+
visible=self.default_mode == BOX_PROMPT_MODE)
|
177 |
+
|
178 |
+
with gr.Column(scale=5):
|
179 |
+
dd_input_modes = gr.Dropdown(label="Image Input Mode", value=self.default_mode,
|
180 |
+
choices=self.image_modes)
|
181 |
+
dd_models = gr.Dropdown(label="Model", value=DEFAULT_MODEL_TYPE,
|
182 |
+
choices=self.sam_inf.available_models)
|
183 |
+
|
184 |
+
with gr.Accordion("Mask Parameters", open=False, visible=self.default_mode == AUTOMATIC_MODE) as acc_mask_hparams:
|
185 |
+
mask_hparams_component = self.mask_generation_parameters(_mask_hparams)
|
186 |
+
|
187 |
+
cb_multimask_output = gr.Checkbox(label="multimask_output", value=_mask_hparams["multimask_output"])
|
188 |
+
|
189 |
+
with gr.Row():
|
190 |
+
btn_generate = gr.Button("GENERATE", variant="primary")
|
191 |
+
with gr.Row():
|
192 |
+
gallery_output = gr.Gallery(label="Output images will be shown here")
|
193 |
+
with gr.Column():
|
194 |
+
output_file = gr.File(label="Generated psd file", scale=9)
|
195 |
+
btn_open_folder = gr.Button("📁\nOpen PSD folder", scale=1)
|
196 |
+
|
197 |
+
sources = [img_input, img_input_prompter, dd_input_modes]
|
198 |
+
model_params = [dd_models]
|
199 |
+
mask_hparams = mask_hparams_component + [cb_multimask_output]
|
200 |
+
input_params = sources + model_params + mask_hparams
|
201 |
+
|
202 |
+
btn_generate.click(fn=self.sam_inf.divide_layer,
|
203 |
+
inputs=input_params, outputs=[gallery_output, output_file])
|
204 |
+
btn_open_folder.click(fn=lambda: open_folder(os.path.join(self.args.output_dir, "psd")),
|
205 |
+
inputs=None, outputs=None)
|
206 |
+
dd_input_modes.change(fn=self.on_mode_change,
|
207 |
+
inputs=[dd_input_modes],
|
208 |
+
outputs=[img_input, img_input_prompter, acc_mask_hparams])
|
209 |
+
|
210 |
self.demo.queue().launch(
|
211 |
inbrowser=self.args.inbrowser,
|
212 |
share=self.args.share,
|
modules/html_constants.py
CHANGED
@@ -22,4 +22,4 @@ CSS = """
|
|
22 |
#md_header a:hover {
|
23 |
text-decoration: underline;
|
24 |
}
|
25 |
-
"""
|
|
|
22 |
#md_header a:hover {
|
23 |
text-decoration: underline;
|
24 |
}
|
25 |
+
"""
|