Spaces:
Runtime error
Runtime error
add remove background
Browse files- js/poseMaker.js +6 -0
- main.py +8 -2
js/poseMaker.js
CHANGED
@@ -807,6 +807,12 @@ function savePose() {
|
|
807 |
}
|
808 |
|
809 |
function importBackground(image) {
|
|
|
|
|
|
|
|
|
|
|
|
|
810 |
let m = new Image();
|
811 |
m.src = image;
|
812 |
m.onload = function() {
|
|
|
807 |
}
|
808 |
|
809 |
function importBackground(image) {
|
810 |
+
if (image == null) {
|
811 |
+
canvasBg = null;
|
812 |
+
Redraw();
|
813 |
+
return;
|
814 |
+
}
|
815 |
+
|
816 |
let m = new Image();
|
817 |
m.src = image;
|
818 |
m.onload = function() {
|
main.py
CHANGED
@@ -57,6 +57,8 @@ with gr.Blocks(css="""button { min-width: 80px; }""") as demo:
|
|
57 |
importBtn = gr.Button(value="Import")
|
58 |
with gr.Column(min_width=80):
|
59 |
bgBtn = gr.Button(value="Background")
|
|
|
|
|
60 |
with gr.Accordion(label="Json", open=False):
|
61 |
with gr.Row():
|
62 |
with gr.Column(min_width=80):
|
@@ -137,8 +139,12 @@ When using Q, X, C, R, pressing and dont release until the operation is complete
|
|
137 |
fn = None,
|
138 |
inputs = [source],
|
139 |
outputs = [],
|
140 |
-
_js="(image) => { importBackground(image); return []; }"
|
141 |
-
|
|
|
|
|
|
|
|
|
142 |
|
143 |
saveBtn.click(
|
144 |
fn = None,
|
|
|
57 |
importBtn = gr.Button(value="Import")
|
58 |
with gr.Column(min_width=80):
|
59 |
bgBtn = gr.Button(value="Background")
|
60 |
+
with gr.Column(min_width=80):
|
61 |
+
removeBgBtn = gr.Button(value="RemoveBG")
|
62 |
with gr.Accordion(label="Json", open=False):
|
63 |
with gr.Row():
|
64 |
with gr.Column(min_width=80):
|
|
|
139 |
fn = None,
|
140 |
inputs = [source],
|
141 |
outputs = [],
|
142 |
+
_js="(image) => { importBackground(image); return []; }")
|
143 |
+
removeBgBtn.click(
|
144 |
+
fn = None,
|
145 |
+
inputs = [],
|
146 |
+
outputs = [],
|
147 |
+
_js="() => { importBackground(null); return []; }")
|
148 |
|
149 |
saveBtn.click(
|
150 |
fn = None,
|