check for duplicates in extract folder
Hello all,
I have been having trouble with cloud servers shutting down unexpectedly so I edited the original extract.py to not overwrite if the image has already been processed in a previous run.
Note that I am currently assuming an idx of 0 (i.e. single face was found in photo, usually denoting successful face extraction - all extracted images with nonzero index have been failures from what I ve seen, please enlighten me further!)
This can be handy since somebody may update his image db but should not wait for complete re-extraction! Note that this is on an earlier version I pulled from this repo so not directly applicable, but I am sure this can be implemented extremely quickly.
Just thought I'd share this idea: you can have a -no flag in the extract command to prevent overwriting.
Thoughts? Thanks to all contributors for the good work!
import os
def process(self):
extractor_name = "Align" # TODO Pass as argument
extractor = PluginLoader.get_extractor(extractor_name)()
try:
for filename in self.read_directory():
output_file = self.output_dir / Path(filename).stem
output_file_to_check = os.path.abspath(str(output_file) +
'0' +
Path(filename).suffix)
if os.path.isfile(output_file_to_check):
print('File {} already exists, will not overwrite'.format(output_file_to_check))
else:
image = cv2.imread(filename)
for idx, face in self.get_faces(image):
resized_image = extractor.extract(image, face, 256)
cv2.imwrite(str(output_file) + str(idx) + Path(filename).suffix, resized_image)
except Exception as e:
print('Failed to extract from image: {}. Reason: {}'.format(filename, e))
Just a heads up, https://cloud.google.com/free/ gives you 300 dollars of free credit. I built a quad core linux system to run facewap on and added a 3584 cuda core Tesla P100. Trained models on it like a charm and only ran out of the free 300 after about a week, plenty of time to train models on a P100. I pay for it now because its honestly a great price for that many Cuda cores and the storage and cpu are basically free - you can get a model down to 0.02 in about 15 hours on a free instance. and it pretty much never goes down. Always been up for me.
Hi, thanks for the suggestion! I am actually running on a google colab notebook which provides free access to a Tesla K80. Problem is you need a good internet connection to stay connected otherwise the notebook stops :/
I would be very interested in instruction on how to setup a vm on gcp!
Can you mount your cloud drive or how does it work with the image db?
I tried once to build a docker image but was taking too long (mind you on google-colab I still need about 20 min to setup all dependencies etc.) plus I lack experience with such setups.
Good thing is I've learned a ton trying to build all packages and optmise stuff to get my setup to work properly in a highly restricted ipython environment; will share once I fix a few issues.
I'm not sure what you mean by cloud drive but depending on the platform (windows/linux) you can transfer files dierectly. On google cloud instead of something like google drive, you have whats called a bucket. its essentially the same thing, you can upload and download files to your instance and your actual computer, its hard to describe but way handier than google drive. If I wanted to put images on my instance I'd upload them to my bucket and then download them to my cloud instance. Then set up your fakeapp on windows or faceswap on linux and you aree good to go. on Windows if you close the instance or lose internet it keeps running, on linux just install "screen", make a new session and you can get the same effect. I'm in love with it because I got so many renders out of it for free, and I really would reccommend it as youd get a big speed impromement with the p100 which you can add for free while your 300 dollars lasts.
@flipflopbboi after i saw your post, i tried google colab, took me a while to get familiar with the system but once i ran training on it, it immediatly start showing oom errors. looks like gpu memory is capped for colab sessions?
name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235 pciBusID: 0000:00:04.0 totalMemory: 11.17GiB freeMemory: 503.62MiB
@3xtr3m3d This used to happen to me too, but if you restart your session (Runtime -> Restart Runtime..) and rerun your K80 memory is cleansed and you are allocated full 12 GB.
@flipflopbboi Thanks, yes got 12GB after several attempts. but now im not seeing loss values in the command output. also it looks like running because i see the message "saved model weights" appear in the output but it takes really really long time even with lowmem and batch size 32. is there any tricks to run in colab?
to see updates of losses, remove the end=\r in the ModelAE.py as per #116
@flipflopbboi Thanks. that solved the issue. but seems it takes about 13 seconds for 1 iteration :(
ahh now its going fast
@flipflopbboi
print("\r[{0}] [#{1:05d}] loss_A: {2:.5f}, loss_B: {3:.5f}".format(time.strftime("%H:%M:%S"), iter, loss_A, loss_B),end='')
This solves the output issue. can see loss values without printing a line for every iteration
@iperov can we close this if your sort tool does it already?
Ah no it's more a duplicate on filename...
Do we need this? Isn't it done already?
related to #214 AFAIK. If not please reopen...