This commit is contained in:
dwelle 2024-06-24 23:43:00 +02:00
parent eac523c83f
commit 37f5c04805

View File

@ -10,7 +10,7 @@ export const actionRemoveBackground = register({
label: "stats.fullTitle", label: "stats.fullTitle",
trackEvent: false, trackEvent: false,
viewMode: false, viewMode: false,
async perform(elements, appState, _, app) { async perform(elements, appState, type, app) {
const selectedElements = app.scene.getSelectedElements(appState); const selectedElements = app.scene.getSelectedElements(appState);
if ( if (
@ -63,11 +63,11 @@ export const actionRemoveBackground = register({
for (const [, { file, elements }] of filesToProcess) { for (const [, { file, elements }] of filesToProcess) {
const res = await backgroundRemoval.removeBackground(file.dataURL, { const res = await backgroundRemoval.removeBackground(file.dataURL, {
// debug: true, debug: true,
progress: (...args) => { progress: (...args) => {
console.log("progress", args); console.log("progress", args);
}, },
device: "gpu", device: type === "auto" ? undefined : type,
proxyToWorker: true, proxyToWorker: true,
}); });
@ -101,13 +101,29 @@ export const actionRemoveBackground = register({
}, },
PanelComponent: ({ updateData }) => { PanelComponent: ({ updateData }) => {
return ( return (
<button <>
onClick={() => { <button
updateData(); onClick={() => {
}} updateData("auto");
> }}
Remove background >
</button> Remove background (auto)
</button>
<button
onClick={() => {
updateData("gpu");
}}
>
Remove background (gpu)
</button>
<button
onClick={() => {
updateData("cpu");
}}
>
Remove background (cpu)
</button>
</>
); );
}, },
}); });