mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-06 13:02:15 -07:00
forcing all tqdm's to ascii in order to work properly on Chinese windows
This commit is contained in:
parent
1e7a0836f7
commit
72646becd1
5 changed files with 24 additions and 25 deletions
|
@ -259,7 +259,7 @@ def main (input_dir, output_dir, model_dir, model_name, aligned_dir=None, **in_o
|
||||||
alignments = {}
|
alignments = {}
|
||||||
|
|
||||||
aligned_path_image_paths = Path_utils.get_image_paths(aligned_path)
|
aligned_path_image_paths = Path_utils.get_image_paths(aligned_path)
|
||||||
for filename in tqdm(aligned_path_image_paths, desc= "Collecting alignments" ):
|
for filename in tqdm(aligned_path_image_paths, desc="Collecting alignments", ascii=True ):
|
||||||
dflpng = DFLPNG.load( str(filename), print_on_no_embedded_data=True )
|
dflpng = DFLPNG.load( str(filename), print_on_no_embedded_data=True )
|
||||||
if dflpng is None:
|
if dflpng is None:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -3,7 +3,6 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
from tqdm import tqdm
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
|
|
|
@ -131,14 +131,14 @@ def sort_by_blur(input_path):
|
||||||
|
|
||||||
def sort_by_brightness(input_path):
|
def sort_by_brightness(input_path):
|
||||||
print ("Sorting by brightness...")
|
print ("Sorting by brightness...")
|
||||||
img_list = [ [x, np.mean ( cv2.cvtColor(cv2.imread(x), cv2.COLOR_BGR2HSV)[...,2].flatten() )] for x in tqdm( Path_utils.get_image_paths(input_path), desc="Loading") ]
|
img_list = [ [x, np.mean ( cv2.cvtColor(cv2.imread(x), cv2.COLOR_BGR2HSV)[...,2].flatten() )] for x in tqdm( Path_utils.get_image_paths(input_path), desc="Loading", ascii=True) ]
|
||||||
print ("Sorting...")
|
print ("Sorting...")
|
||||||
img_list = sorted(img_list, key=operator.itemgetter(1), reverse=True)
|
img_list = sorted(img_list, key=operator.itemgetter(1), reverse=True)
|
||||||
return img_list
|
return img_list
|
||||||
|
|
||||||
def sort_by_hue(input_path):
|
def sort_by_hue(input_path):
|
||||||
print ("Sorting by hue...")
|
print ("Sorting by hue...")
|
||||||
img_list = [ [x, np.mean ( cv2.cvtColor(cv2.imread(x), cv2.COLOR_BGR2HSV)[...,0].flatten() )] for x in tqdm( Path_utils.get_image_paths(input_path), desc="Loading") ]
|
img_list = [ [x, np.mean ( cv2.cvtColor(cv2.imread(x), cv2.COLOR_BGR2HSV)[...,0].flatten() )] for x in tqdm( Path_utils.get_image_paths(input_path), desc="Loading", ascii=True) ]
|
||||||
print ("Sorting...")
|
print ("Sorting...")
|
||||||
img_list = sorted(img_list, key=operator.itemgetter(1), reverse=True)
|
img_list = sorted(img_list, key=operator.itemgetter(1), reverse=True)
|
||||||
return img_list
|
return img_list
|
||||||
|
@ -148,7 +148,7 @@ def sort_by_face(input_path):
|
||||||
print ("Sorting by face similarity...")
|
print ("Sorting by face similarity...")
|
||||||
|
|
||||||
img_list = []
|
img_list = []
|
||||||
for filepath in tqdm( Path_utils.get_image_paths(input_path), desc="Loading"):
|
for filepath in tqdm( Path_utils.get_image_paths(input_path), desc="Loading", ascii=True):
|
||||||
filepath = Path(filepath)
|
filepath = Path(filepath)
|
||||||
|
|
||||||
if filepath.suffix != '.png':
|
if filepath.suffix != '.png':
|
||||||
|
@ -163,7 +163,7 @@ def sort_by_face(input_path):
|
||||||
|
|
||||||
|
|
||||||
img_list_len = len(img_list)
|
img_list_len = len(img_list)
|
||||||
for i in tqdm ( range(0, img_list_len-1), desc="Sorting"):
|
for i in tqdm ( range(0, img_list_len-1), desc="Sorting", ascii=True):
|
||||||
min_score = float("inf")
|
min_score = float("inf")
|
||||||
j_min_score = i+1
|
j_min_score = i+1
|
||||||
for j in range(i+1,len(img_list)):
|
for j in range(i+1,len(img_list)):
|
||||||
|
@ -184,7 +184,7 @@ def sort_by_face_dissim(input_path):
|
||||||
print ("Sorting by face dissimilarity...")
|
print ("Sorting by face dissimilarity...")
|
||||||
|
|
||||||
img_list = []
|
img_list = []
|
||||||
for filepath in tqdm( Path_utils.get_image_paths(input_path), desc="Loading"):
|
for filepath in tqdm( Path_utils.get_image_paths(input_path), desc="Loading", ascii=True):
|
||||||
filepath = Path(filepath)
|
filepath = Path(filepath)
|
||||||
|
|
||||||
if filepath.suffix != '.png':
|
if filepath.suffix != '.png':
|
||||||
|
@ -198,7 +198,7 @@ def sort_by_face_dissim(input_path):
|
||||||
img_list.append( [str(filepath), dflpng.get_landmarks(), 0 ] )
|
img_list.append( [str(filepath), dflpng.get_landmarks(), 0 ] )
|
||||||
|
|
||||||
img_list_len = len(img_list)
|
img_list_len = len(img_list)
|
||||||
for i in tqdm( range(0, img_list_len-1), desc="Sorting"):
|
for i in tqdm( range(0, img_list_len-1), desc="Sorting", ascii=True):
|
||||||
score_total = 0
|
score_total = 0
|
||||||
for j in range(i+1,len(img_list)):
|
for j in range(i+1,len(img_list)):
|
||||||
if i == j:
|
if i == j:
|
||||||
|
@ -217,7 +217,7 @@ def sort_by_face_dissim(input_path):
|
||||||
def sort_by_face_yaw(input_path):
|
def sort_by_face_yaw(input_path):
|
||||||
print ("Sorting by face yaw...")
|
print ("Sorting by face yaw...")
|
||||||
img_list = []
|
img_list = []
|
||||||
for filepath in tqdm( Path_utils.get_image_paths(input_path), desc="Loading"):
|
for filepath in tqdm( Path_utils.get_image_paths(input_path), desc="Loading", ascii=True):
|
||||||
filepath = Path(filepath)
|
filepath = Path(filepath)
|
||||||
|
|
||||||
if filepath.suffix != '.png':
|
if filepath.suffix != '.png':
|
||||||
|
@ -436,7 +436,7 @@ def sort_by_hist_dissim(input_path):
|
||||||
print ("Sorting by histogram dissimilarity...")
|
print ("Sorting by histogram dissimilarity...")
|
||||||
|
|
||||||
img_list = []
|
img_list = []
|
||||||
for filename_path in tqdm( Path_utils.get_image_paths(input_path), desc="Loading"):
|
for filename_path in tqdm( Path_utils.get_image_paths(input_path), desc="Loading", ascii=True):
|
||||||
image = cv2.imread(filename_path)
|
image = cv2.imread(filename_path)
|
||||||
|
|
||||||
dflpng = DFLPNG.load( str(filename_path) )
|
dflpng = DFLPNG.load( str(filename_path) )
|
||||||
|
@ -563,7 +563,7 @@ def sort_final(input_path):
|
||||||
grads_space = np.linspace (-255,255,grads)
|
grads_space = np.linspace (-255,255,grads)
|
||||||
|
|
||||||
yaws_sample_list = [None]*grads
|
yaws_sample_list = [None]*grads
|
||||||
for g in tqdm ( range(grads), desc="Sort by yaw" ):
|
for g in tqdm ( range(grads), desc="Sort by yaw", ascii=True ):
|
||||||
yaw = grads_space[g]
|
yaw = grads_space[g]
|
||||||
next_yaw = grads_space[g+1] if g < grads-1 else yaw
|
next_yaw = grads_space[g+1] if g < grads-1 else yaw
|
||||||
|
|
||||||
|
@ -578,7 +578,7 @@ def sort_final(input_path):
|
||||||
yaws_sample_list[g] = yaw_samples
|
yaws_sample_list[g] = yaw_samples
|
||||||
|
|
||||||
total_lack = 0
|
total_lack = 0
|
||||||
for g in tqdm ( range (grads), desc="" ):
|
for g in tqdm ( range (grads), desc="", ascii=True ):
|
||||||
img_list = yaws_sample_list[g]
|
img_list = yaws_sample_list[g]
|
||||||
img_list_len = len(img_list) if img_list is not None else 0
|
img_list_len = len(img_list) if img_list is not None else 0
|
||||||
|
|
||||||
|
@ -588,7 +588,7 @@ def sort_final(input_path):
|
||||||
imgs_per_grad += total_lack // grads
|
imgs_per_grad += total_lack // grads
|
||||||
sharpned_imgs_per_grad = imgs_per_grad*10
|
sharpned_imgs_per_grad = imgs_per_grad*10
|
||||||
|
|
||||||
for g in tqdm ( range (grads), desc="Sort by blur" ):
|
for g in tqdm ( range (grads), desc="Sort by blur", ascii=True ):
|
||||||
img_list = yaws_sample_list[g]
|
img_list = yaws_sample_list[g]
|
||||||
if img_list is None:
|
if img_list is None:
|
||||||
continue
|
continue
|
||||||
|
@ -605,7 +605,7 @@ def sort_final(input_path):
|
||||||
|
|
||||||
yaws_sample_list[g] = img_list
|
yaws_sample_list[g] = img_list
|
||||||
|
|
||||||
for g in tqdm ( range (grads), desc="Sort by hist" ):
|
for g in tqdm ( range (grads), desc="Sort by hist", ascii=True ):
|
||||||
img_list = yaws_sample_list[g]
|
img_list = yaws_sample_list[g]
|
||||||
if img_list is None:
|
if img_list is None:
|
||||||
continue
|
continue
|
||||||
|
@ -620,7 +620,7 @@ def sort_final(input_path):
|
||||||
|
|
||||||
yaws_sample_list[g] = sorted(img_list, key=operator.itemgetter(3), reverse=True)
|
yaws_sample_list[g] = sorted(img_list, key=operator.itemgetter(3), reverse=True)
|
||||||
|
|
||||||
for g in tqdm ( range (grads), desc="Fetching best" ):
|
for g in tqdm ( range (grads), desc="Fetching best", ascii=True ):
|
||||||
img_list = yaws_sample_list[g]
|
img_list = yaws_sample_list[g]
|
||||||
if img_list is None:
|
if img_list is None:
|
||||||
continue
|
continue
|
||||||
|
@ -634,7 +634,7 @@ def sort_by_black(input_path):
|
||||||
print ("Sorting by amount of black pixels...")
|
print ("Sorting by amount of black pixels...")
|
||||||
|
|
||||||
img_list = []
|
img_list = []
|
||||||
for x in tqdm( Path_utils.get_image_paths(input_path), desc="Loading"):
|
for x in tqdm( Path_utils.get_image_paths(input_path), desc="Loading", ascii=True):
|
||||||
img = cv2.imread(x)
|
img = cv2.imread(x)
|
||||||
img_list.append ([x, img[(img == 0)].size ])
|
img_list.append ([x, img[(img == 0)].size ])
|
||||||
|
|
||||||
|
@ -654,7 +654,7 @@ def final_process(input_path, img_list, trash_img_list):
|
||||||
for filename in Path_utils.get_image_paths(trash_path):
|
for filename in Path_utils.get_image_paths(trash_path):
|
||||||
Path(filename).unlink()
|
Path(filename).unlink()
|
||||||
|
|
||||||
for i in tqdm( range(len(trash_img_list)), desc="Moving trash" , leave=False):
|
for i in tqdm( range(len(trash_img_list)), desc="Moving trash" , leave=False, ascii=True):
|
||||||
src = Path (trash_img_list[i][0])
|
src = Path (trash_img_list[i][0])
|
||||||
dst = trash_path / src.name
|
dst = trash_path / src.name
|
||||||
try:
|
try:
|
||||||
|
@ -664,7 +664,7 @@ def final_process(input_path, img_list, trash_img_list):
|
||||||
|
|
||||||
print ("")
|
print ("")
|
||||||
|
|
||||||
for i in tqdm( range(len(img_list)), desc="Renaming" , leave=False):
|
for i in tqdm( range(len(img_list)), desc="Renaming" , leave=False, ascii=True):
|
||||||
src = Path (img_list[i][0])
|
src = Path (img_list[i][0])
|
||||||
dst = input_path / ('%.5d_%s' % (i, src.name ))
|
dst = input_path / ('%.5d_%s' % (i, src.name ))
|
||||||
try:
|
try:
|
||||||
|
@ -672,7 +672,7 @@ def final_process(input_path, img_list, trash_img_list):
|
||||||
except:
|
except:
|
||||||
print ('fail to rename %s' % (src.name) )
|
print ('fail to rename %s' % (src.name) )
|
||||||
|
|
||||||
for i in tqdm( range(len(img_list)) , desc="Renaming" ):
|
for i in tqdm( range(len(img_list)) , desc="Renaming", ascii=True ):
|
||||||
src = Path (img_list[i][0])
|
src = Path (img_list[i][0])
|
||||||
|
|
||||||
src = input_path / ('%.5d_%s' % (i, src.name))
|
src = input_path / ('%.5d_%s' % (i, src.name))
|
||||||
|
@ -686,7 +686,7 @@ def sort_by_origname(input_path):
|
||||||
print ("Sort by original filename...")
|
print ("Sort by original filename...")
|
||||||
|
|
||||||
img_list = []
|
img_list = []
|
||||||
for filepath in tqdm( Path_utils.get_image_paths(input_path), desc="Loading"):
|
for filepath in tqdm( Path_utils.get_image_paths(input_path), desc="Loading", ascii=True):
|
||||||
filepath = Path(filepath)
|
filepath = Path(filepath)
|
||||||
|
|
||||||
if filepath.suffix != '.png':
|
if filepath.suffix != '.png':
|
||||||
|
|
|
@ -27,7 +27,7 @@ class SampleLoader:
|
||||||
|
|
||||||
if sample_type == SampleType.IMAGE:
|
if sample_type == SampleType.IMAGE:
|
||||||
if datas[sample_type] is None:
|
if datas[sample_type] is None:
|
||||||
datas[sample_type] = [ Sample(filename=filename) for filename in tqdm( Path_utils.get_image_paths(samples_path), desc="Loading" ) ]
|
datas[sample_type] = [ Sample(filename=filename) for filename in tqdm( Path_utils.get_image_paths(samples_path), desc="Loading", ascii=True ) ]
|
||||||
|
|
||||||
elif sample_type == SampleType.FACE:
|
elif sample_type == SampleType.FACE:
|
||||||
if datas[sample_type] is None:
|
if datas[sample_type] is None:
|
||||||
|
@ -53,7 +53,7 @@ class SampleLoader:
|
||||||
def upgradeToFaceSamples ( samples ):
|
def upgradeToFaceSamples ( samples ):
|
||||||
sample_list = []
|
sample_list = []
|
||||||
|
|
||||||
for s in tqdm( samples, desc="Loading" ):
|
for s in tqdm( samples, desc="Loading", ascii=True ):
|
||||||
|
|
||||||
s_filename_path = Path(s.filename)
|
s_filename_path = Path(s.filename)
|
||||||
if s_filename_path.suffix != '.png':
|
if s_filename_path.suffix != '.png':
|
||||||
|
@ -78,7 +78,7 @@ class SampleLoader:
|
||||||
yaw_samples_len = len(yaw_samples)
|
yaw_samples_len = len(yaw_samples)
|
||||||
|
|
||||||
sample_list = []
|
sample_list = []
|
||||||
for i in tqdm( range(yaw_samples_len), desc="Sorting" ):
|
for i in tqdm( range(yaw_samples_len), desc="Sorting", ascii=True ):
|
||||||
if yaw_samples[i] is not None:
|
if yaw_samples[i] is not None:
|
||||||
for s in yaw_samples[i]:
|
for s in yaw_samples[i]:
|
||||||
s_t = []
|
s_t = []
|
||||||
|
@ -114,7 +114,7 @@ class SampleLoader:
|
||||||
|
|
||||||
yaws_sample_list = [None]*gradations
|
yaws_sample_list = [None]*gradations
|
||||||
|
|
||||||
for i in tqdm( range(0, gradations), desc="Sorting" ):
|
for i in tqdm( range(0, gradations), desc="Sorting", ascii=True ):
|
||||||
yaw = lowest_yaw + i*diff_rot_per_grad
|
yaw = lowest_yaw + i*diff_rot_per_grad
|
||||||
next_yaw = lowest_yaw + (i+1)*diff_rot_per_grad
|
next_yaw = lowest_yaw + (i+1)*diff_rot_per_grad
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ class SubprocessorBase(object):
|
||||||
print ( self.get_no_process_started_message() )
|
print ( self.get_no_process_started_message() )
|
||||||
return None
|
return None
|
||||||
|
|
||||||
self.progress_bar = tqdm( total=self.onHostGetProgressBarLen(), desc=self.onHostGetProgressBarDesc() )
|
self.progress_bar = tqdm( total=self.onHostGetProgressBarLen(), desc=self.onHostGetProgressBarDesc(), ascii=True )
|
||||||
self.onHostClientsInitialized()
|
self.onHostClientsInitialized()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue