Open erikdemarco opened 3 years ago
for that you can use this repo, https://github.com/xuebinqin/U-2-Net
Bulk in what sense? Read a folder?
On Tue, Nov 30, 2021, 10:43 Faraz Ahmad @.***> wrote:
for that you can use this repo, https://github.com/xuebinqin/U-2-Net
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nadermx/backgroundremover/issues/22#issuecomment-982759018, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYACXBZM4IOC6G6EMGYXBDUOTWI5ANCNFSM5IRWECMA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
yes
For anyone wanting a quick and dirty solution:
#!/bin/python3
import os
path_of_the_directory= './sd'
i = 0
for filename in os.listdir(path_of_the_directory):
input_file = os.path.join(path_of_the_directory,filename)
output_file = os.path.join(path_of_the_directory,f'{i}.png')
if os.path.isfile(input_file):
os.system(f'backgroundremover -i "{input_file}" -o "{output_file}"')
i += 1
Save as bg.py, update the "path_of_directory" variable and run. It will spit out 0.png 1.png etc.
For anyone wanting a quick and dirty solution:
#!/bin/python3 import os path_of_the_directory= './sd' i = 0 for filename in os.listdir(path_of_the_directory): input_file = os.path.join(path_of_the_directory,filename) output_file = os.path.join(path_of_the_directory,f'{i}.png') if os.path.isfile(input_file): os.system(f'backgroundremover -i "{input_file}" -o "{output_file}"') i += 1
Save as bg.py, update the "path_of_directory" variable and run. It will spit out 0.png 1.png etc.
Hi Thanks for sharing, maybe you can help: There is already a bg.py at "backgroundremover" sub-directory of the master root. I tried to add the code you made + I changed the "path_of_the_directory" but it's not working.
Can you please explain where to add the code you shared? or the new created bg.py with the code you shared ONLY but in what sub-directory? Probably I shouldn't overwrite the original bg.py as it contains the main code, right?
Also,
I'm currently using a batch file includes the basic code, do I need to change the command?
backgroundremover -i ./_SOURCE_/image.jpg -o ./_RESULT_/output.png -m "u2net_human_seg"
since the filenames and directory path are overwrite with your new code? (I'm a bit lost oops)
Sorry for the confusion, I'm not a programmer so I don't know how to make it work, I hope you can explain for newbie such as myself.
Thanks ahead! :)
Oh, I didn't realize there was already a bg.py file. I didn't mean for that to be overwritten, but for a new file to be made, it can be named anything but that name will be the file that you run, e.g. if you name it rainbow-unicorns.py
then you'd run ./rainbow-unicorns.py
after giving it execute permission (I'm on linux, I'm not sure how to run it on Windows).
Modified script for you command:
#!/bin/python3
import os
path_of_the_directory= './sd'
i = 0
for filename in os.listdir(path_of_the_directory):
input_file = os.path.join(path_of_the_directory,filename)
output_file = os.path.join(path_of_the_directory,f'{i}.png')
if os.path.isfile(input_file):
os.system(f'backgroundremover -i "{input_file}" -o "{output_file}" -m "u2net_human_seg"')
i += 1
Adding this into the main, but maybe not as dirty
Is there any command to do bulk background removing?