Compare commits

...

6 Commits

Author SHA1 Message Date
Uma Maheshwar Reddy Thipparthi a211dee24e
Merge 0cc4a2216f into 72049f3e91 2025-05-19 16:52:25 +08:00
Chou Chamnan 72049f3e91
Add khmer translation (#1291)
* Add khmer language

* Fix khmer language

---------

Co-authored-by: Chamnan dev
2025-05-18 23:03:53 +05:30
inwchamp1337 6cb5de01f8
Added a Thai translation (#1284)
* Added a Thai translation

* Update th.json
2025-05-18 23:03:19 +05:30
KRSHH 0bcf340217
Merge pull request #1281 from Giovannapls/add/pt-br-translate
[Added] pt br translate
2025-05-18 23:01:00 +05:30
Giovanna 994a63c546 [Added] pt br translate 2025-05-14 19:24:13 -03:00
maheshreddyy345 0cc4a2216f Fix CUDA configuration issue #1140 - add better error handling and fallback 2025-04-30 06:15:13 -07:00
6 changed files with 287 additions and 34 deletions

45
locales/km.json 100644
View File

@ -0,0 +1,45 @@
{
"Source x Target Mapper": "ប្រភប x បន្ថែម Mapper",
"select a source image": "ជ្រើសរើសប្រភពរូបភាព",
"Preview": "បង្ហាញ",
"select a target image or video": "ជ្រើសរើសគោលដៅរូបភាពឬវីដេអូ",
"save image output file": "រក្សាទុកលទ្ធផលឯកសាររូបភាព",
"save video output file": "រក្សាទុកលទ្ធផលឯកសារវីដេអូ",
"select a target image": "ជ្រើសរើសគោលដៅរូបភាព",
"source": "ប្រភព",
"Select a target": "ជ្រើសរើសគោលដៅ",
"Select a face": "ជ្រើសរើសមុខ",
"Keep audio": "រម្លងសម្លេង",
"Face Enhancer": "ឧបករណ៍ពង្រឹងមុខ",
"Many faces": "ទម្រង់មុខច្រើន",
"Show FPS": "បង្ហាញ FPS",
"Keep fps": "រម្លង fps",
"Keep frames": "រម្លងទម្រង់",
"Fix Blueish Cam": "ជួសជុល Cam Blueish",
"Mouth Mask": "របាំងមាត់",
"Show Mouth Mask Box": "បង្ហាញប្រអប់របាំងមាត់",
"Start": "ចាប់ផ្ដើម",
"Live": "ផ្សាយផ្ទាល់",
"Destroy": "លុប",
"Map faces": "ផែនទីមុខ",
"Processing...": "កំពុងដំណើរការ...",
"Processing succeed!": "ការដំណើរការទទួលបានជោគជ័យ!",
"Processing ignored!": "ការដំណើរការមិនទទួលបានជោគជ័យ!",
"Failed to start camera": "បរាជ័យដើម្បីចាប់ផ្ដើមបើកកាមេរ៉ា",
"Please complete pop-up or close it.": "សូមបញ្ចប់ផ្ទាំងផុស ឬបិទវា.",
"Getting unique faces": "ការចាប់ផ្ដើមទម្រង់មុខប្លែក",
"Please select a source image first": "សូមជ្រើសរើសប្រភពរូបភាពដំបូង",
"No faces found in target": "រកអត់ឃើញមុខនៅក្នុងគោលដៅ",
"Add": "បន្ថែម",
"Clear": "សម្អាត",
"Submit": "បញ្ចូន",
"Select source image": "ជ្រើសរើសប្រភពរូបភាព",
"Select target image": "ជ្រើសរើសគោលដៅរូបភាព",
"Please provide mapping!": "សូមផ្ដល់នៅផែនទី",
"At least 1 source with target is required!": "ត្រូវការប្រភពយ៉ាងហោចណាស់ ១ ដែលមានគោលដៅ!",
"Face could not be detected in last upload!": "មុខមិនអាចភ្ជាប់នៅក្នុងការបង្ហេាះចុងក្រោយ!",
"Select Camera:": "ជ្រើសរើសកាមេរ៉ា",
"All mappings cleared!": "ផែនទីទាំងអស់ត្រូវបានសម្អាត!",
"Mappings successfully submitted!": "ផែនទីត្រូវបានបញ្ជូនជោគជ័យ!",
"Source x Target Mapper is already open.": "ប្រភព x Target Mapper បានបើករួចហើយ។"
}

46
locales/pt-br.json 100644
View File

@ -0,0 +1,46 @@
{
"Source x Target Mapper": "Mapeador de Origem x Destino",
"select an source image": "Escolha uma imagem de origem",
"Preview": "Prévia",
"select an target image or video": "Escolha uma imagem ou vídeo de destino",
"save image output file": "Salvar imagem final",
"save video output file": "Salvar vídeo final",
"select an target image": "Escolha uma imagem de destino",
"source": "Origem",
"Select a target": "Escolha o destino",
"Select a face": "Escolha um rosto",
"Keep audio": "Manter o áudio original",
"Face Enhancer": "Melhorar rosto",
"Many faces": "Vários rostos",
"Show FPS": "Mostrar FPS",
"Keep fps": "Manter FPS",
"Keep frames": "Manter frames",
"Fix Blueish Cam": "Corrigir tom azulado da câmera",
"Mouth Mask": "Máscara da boca",
"Show Mouth Mask Box": "Mostrar área da máscara da boca",
"Start": "Começar",
"Live": "Ao vivo",
"Destroy": "Destruir",
"Map faces": "Mapear rostos",
"Processing...": "Processando...",
"Processing succeed!": "Tudo certo!",
"Processing ignored!": "Processamento ignorado!",
"Failed to start camera": "Não foi possível iniciar a câmera",
"Please complete pop-up or close it.": "Finalize ou feche o pop-up",
"Getting unique faces": "Buscando rostos diferentes",
"Please select a source image first": "Selecione primeiro uma imagem de origem",
"No faces found in target": "Nenhum rosto encontrado na imagem de destino",
"Add": "Adicionar",
"Clear": "Limpar",
"Submit": "Enviar",
"Select source image": "Escolha a imagem de origem",
"Select target image": "Escolha a imagem de destino",
"Please provide mapping!": "Você precisa realizar o mapeamento!",
"Atleast 1 source with target is required!": "É necessária pelo menos uma origem com um destino!",
"At least 1 source with target is required!": "É necessária pelo menos uma origem com um destino!",
"Face could not be detected in last upload!": "Não conseguimos detectar o rosto na última imagem!",
"Select Camera:": "Escolher câmera:",
"All mappings cleared!": "Todos os mapeamentos foram removidos!",
"Mappings successfully submitted!": "Mapeamentos enviados com sucesso!",
"Source x Target Mapper is already open.": "O Mapeador de Origem x Destino já está aberto."
}

45
locales/th.json 100644
View File

@ -0,0 +1,45 @@
{
"Source x Target Mapper": "ตัวจับคู่ต้นทาง x ปลายทาง",
"select a source image": "เลือกรูปภาพต้นฉบับ",
"Preview": "ตัวอย่าง",
"select a target image or video": "เลือกรูปภาพหรือวิดีโอเป้าหมาย",
"save image output file": "บันทึกไฟล์รูปภาพ",
"save video output file": "บันทึกไฟล์วิดีโอ",
"select a target image": "เลือกรูปภาพเป้าหมาย",
"source": "ต้นฉบับ",
"Select a target": "เลือกเป้าหมาย",
"Select a face": "เลือกใบหน้า",
"Keep audio": "เก็บเสียง",
"Face Enhancer": "ปรับปรุงใบหน้า",
"Many faces": "หลายใบหน้า",
"Show FPS": "แสดง FPS",
"Keep fps": "คงค่า FPS",
"Keep frames": "คงค่าเฟรม",
"Fix Blueish Cam": "แก้ไขภาพอมฟ้าจากกล้อง",
"Mouth Mask": "มาสก์ปาก",
"Show Mouth Mask Box": "แสดงกรอบมาสก์ปาก",
"Start": "เริ่ม",
"Live": "สด",
"Destroy": "หยุด",
"Map faces": "จับคู่ใบหน้า",
"Processing...": "กำลังประมวลผล...",
"Processing succeed!": "ประมวลผลสำเร็จแล้ว!",
"Processing ignored!": "การประมวลผลถูกละเว้น",
"Failed to start camera": "ไม่สามารถเริ่มกล้องได้",
"Please complete pop-up or close it.": "โปรดดำเนินการในป๊อปอัปให้เสร็จสิ้น หรือปิด",
"Getting unique faces": "กำลังค้นหาใบหน้าที่ไม่ซ้ำกัน",
"Please select a source image first": "โปรดเลือกภาพต้นฉบับก่อน",
"No faces found in target": "ไม่พบใบหน้าในภาพเป้าหมาย",
"Add": "เพิ่ม",
"Clear": "ล้าง",
"Submit": "ส่ง",
"Select source image": "เลือกภาพต้นฉบับ",
"Select target image": "เลือกภาพเป้าหมาย",
"Please provide mapping!": "โปรดระบุการจับคู่!",
"At least 1 source with target is required!": "ต้องมีการจับคู่ต้นฉบับกับเป้าหมายอย่างน้อย 1 คู่!",
"Face could not be detected in last upload!": "ไม่สามารถตรวจพบใบหน้าในไฟล์อัปโหลดล่าสุด!",
"Select Camera:": "เลือกกล้อง:",
"All mappings cleared!": "ล้างการจับคู่ทั้งหมดแล้ว!",
"Mappings successfully submitted!": "ส่งการจับคู่สำเร็จแล้ว!",
"Source x Target Mapper is already open.": "ตัวจับคู่ต้นทาง x ปลายทาง เปิดอยู่แล้ว"
}

View File

@ -114,8 +114,46 @@ def encode_execution_providers(execution_providers: List[str]) -> List[str]:
def decode_execution_providers(execution_providers: List[str]) -> List[str]:
return [provider for provider, encoded_execution_provider in zip(onnxruntime.get_available_providers(), encode_execution_providers(onnxruntime.get_available_providers()))
if any(execution_provider in encoded_execution_provider for execution_provider in execution_providers)]
try:
available_providers = onnxruntime.get_available_providers()
encoded_available_providers = encode_execution_providers(available_providers)
selected_providers = []
unavailable_providers = []
for execution_provider in execution_providers:
provider_found = False
for provider, encoded_provider in zip(available_providers, encoded_available_providers):
if execution_provider in encoded_provider:
selected_providers.append(provider)
provider_found = True
break
if not provider_found:
unavailable_providers.append(execution_provider)
if 'cuda' in [p.lower() for p in unavailable_providers]:
# CUDA was requested but not available
cuda_path = os.environ.get('CUDA_PATH')
if cuda_path:
update_status(f"Warning: CUDA_PATH is set ({cuda_path}) but CUDA wasn't able to be loaded. Check your CUDA installation.", "DLC.CORE")
if os.path.exists(cuda_path):
# CUDA path exists but couldn't be loaded - likely missing DLLs or incorrect configuration
update_status("CUDA path exists but CUDA libraries couldn't be loaded. Check if the CUDA runtime is properly installed.", "DLC.CORE")
else:
update_status("CUDA_PATH is set but the directory doesn't exist. Check your environment variables.", "DLC.CORE")
else:
update_status("CUDA was requested but no CUDA_PATH is set in environment variables.", "DLC.CORE")
# If no providers were selected, fall back to CPU
if not selected_providers:
update_status("Falling back to CPU execution provider.", "DLC.CORE")
selected_providers = ['CPUExecutionProvider']
return selected_providers
except Exception as e:
update_status(f"Error determining execution providers: {str(e)}. Falling back to CPU.", "DLC.CORE")
return ['CPUExecutionProvider']
def suggest_max_memory() -> int:
@ -160,6 +198,56 @@ def release_resources() -> None:
torch.cuda.empty_cache()
def check_cuda_configuration() -> None:
"""
Check CUDA configuration and provide diagnostic information.
This helps users identify issues with their CUDA setup.
"""
if 'cuda' in [p.lower() for p in encode_execution_providers(modules.globals.execution_providers)]:
update_status("CUDA execution provider requested, checking configuration...", "DLC.CUDA")
# Check for CUDA environment variables
cuda_path = os.environ.get('CUDA_PATH')
if cuda_path:
update_status(f"CUDA_PATH is set to: {cuda_path}", "DLC.CUDA")
# Check if the directory exists
if os.path.exists(cuda_path):
update_status("CUDA_PATH directory exists", "DLC.CUDA")
# Check for critical CUDA DLLs on Windows
if platform.system().lower() == 'windows':
cuda_dll_path = os.path.join(cuda_path, 'bin', 'cudart64_*.dll')
import glob
cuda_dlls = glob.glob(cuda_dll_path)
if cuda_dlls:
update_status(f"CUDA Runtime DLLs found: {', '.join(os.path.basename(dll) for dll in cuda_dlls)}", "DLC.CUDA")
else:
update_status("Warning: No CUDA Runtime DLLs found in CUDA_PATH/bin", "DLC.CUDA")
update_status("This may cause CUDA initialization failures", "DLC.CUDA")
else:
update_status("Warning: CUDA_PATH is set but directory doesn't exist", "DLC.CUDA")
else:
update_status("Warning: CUDA_PATH environment variable is not set", "DLC.CUDA")
# Check if CUDA is in PATH
path_env = os.environ.get('PATH', '')
if cuda_path and cuda_path + '\\bin' in path_env:
update_status("CUDA bin directory is in PATH", "DLC.CUDA")
else:
update_status("Warning: CUDA bin directory not found in PATH", "DLC.CUDA")
update_status("This may prevent CUDA libraries from being found", "DLC.CUDA")
# Try CUDA provider availability directly from onnxruntime
available_providers = onnxruntime.get_available_providers()
if 'CUDAExecutionProvider' in available_providers:
update_status("CUDA provider is available in ONNX Runtime", "DLC.CUDA")
else:
update_status("Warning: CUDA provider is not available in ONNX Runtime", "DLC.CUDA")
update_status("Available providers: " + ', '.join(available_providers), "DLC.CUDA")
def pre_check() -> bool:
if sys.version_info < (3, 9):
update_status('Python version is not supported - please upgrade to 3.9 or higher.')
@ -167,6 +255,10 @@ def pre_check() -> bool:
if not shutil.which('ffmpeg'):
update_status('ffmpeg is not installed.')
return False
# Check CUDA configuration if requested
check_cuda_configuration()
return True

View File

@ -19,8 +19,26 @@ def get_face_analyser() -> Any:
global FACE_ANALYSER
if FACE_ANALYSER is None:
FACE_ANALYSER = insightface.app.FaceAnalysis(name='buffalo_l', providers=modules.globals.execution_providers)
FACE_ANALYSER.prepare(ctx_id=0, det_size=(640, 640))
try:
FACE_ANALYSER = insightface.app.FaceAnalysis(name='buffalo_l', providers=modules.globals.execution_providers)
FACE_ANALYSER.prepare(ctx_id=0, det_size=(640, 640))
except Exception as e:
error_msg = str(e)
print(f"[DLC.FACE-ANALYSER] Error initializing face analyser with providers {modules.globals.execution_providers}: {error_msg}")
# If error is CUDA-related, try with CPU provider as fallback
if "cuda" in error_msg.lower() or "gpu" in error_msg.lower():
print("[DLC.FACE-ANALYSER] CUDA error detected. Falling back to CPU provider.")
modules.globals.execution_providers = ['CPUExecutionProvider']
try:
FACE_ANALYSER = insightface.app.FaceAnalysis(name='buffalo_l', providers=modules.globals.execution_providers)
FACE_ANALYSER.prepare(ctx_id=0, det_size=(640, 640))
print("[DLC.FACE-ANALYSER] Successfully initialized with CPU provider as fallback.")
except Exception as fallback_error:
print(f"[DLC.FACE-ANALYSER] Failed to initialize even with fallback provider: {str(fallback_error)}")
raise
else:
raise
return FACE_ANALYSER

View File

@ -61,9 +61,29 @@ def get_face_swapper() -> Any:
with THREAD_LOCK:
if FACE_SWAPPER is None:
model_path = os.path.join(models_dir, "inswapper_128_fp16.onnx")
FACE_SWAPPER = insightface.model_zoo.get_model(
model_path, providers=modules.globals.execution_providers
)
try:
FACE_SWAPPER = insightface.model_zoo.get_model(
model_path, providers=modules.globals.execution_providers
)
update_status(f"Successfully loaded model with providers: {modules.globals.execution_providers}", NAME)
except Exception as e:
error_msg = str(e)
update_status(f"Error loading model with selected providers: {error_msg}", NAME)
# If the error is related to CUDA, provide more helpful information
if "cuda" in error_msg.lower() or "gpu" in error_msg.lower():
update_status("CUDA error detected. Trying to load with CPU provider instead.", NAME)
modules.globals.execution_providers = ['CPUExecutionProvider']
try:
FACE_SWAPPER = insightface.model_zoo.get_model(
model_path, providers=modules.globals.execution_providers
)
update_status("Successfully loaded model with CPU provider as fallback.", NAME)
except Exception as fallback_error:
update_status(f"Failed to load model even with fallback provider: {str(fallback_error)}", NAME)
raise
else:
raise
return FACE_SWAPPER
@ -430,37 +450,24 @@ def draw_mouth_mask_visualization(
feathered_mask = cv2.GaussianBlur(
mask_region.astype(float), (kernel_size, kernel_size), 0
)
feathered_mask = (feathered_mask / feathered_mask.max() * 255).astype(np.uint8)
# Remove the feathered mask color overlay
# color_feathered_mask = cv2.applyColorMap(feathered_mask, cv2.COLORMAP_VIRIDIS)
feathered_mask = feathered_mask / feathered_mask.max()
# Ensure shapes match before blending feathered mask
# if vis_region.shape == color_feathered_mask.shape:
# blended_feathered = cv2.addWeighted(vis_region, 0.7, color_feathered_mask, 0.3, 0)
# vis_frame[min_y:max_y, min_x:max_x] = blended_feathered
face_mask_roi = face_mask[min_y:max_y, min_x:max_x]
combined_mask = feathered_mask * (face_mask_roi / 255.0)
# Add labels
cv2.putText(
vis_frame,
"Lower Mouth Mask",
(min_x, min_y - 10),
cv2.FONT_HERSHEY_SIMPLEX,
0.5,
(255, 255, 255),
1,
)
cv2.putText(
vis_frame,
"Feathered Mask",
(min_x, max_y + 20),
cv2.FONT_HERSHEY_SIMPLEX,
0.5,
(255, 255, 255),
1,
combined_mask = combined_mask[:, :, np.newaxis]
blended = (
color_corrected_mouth * combined_mask + vis_region * (1 - combined_mask)
).astype(np.uint8)
# Apply face mask to blended result
face_mask_3channel = (
np.repeat(face_mask_roi[:, :, np.newaxis], 3, axis=2) / 255.0
)
final_blend = blended * face_mask_3channel + vis_region * (1 - face_mask_3channel)
return vis_frame
return frame
vis_frame[min_y:max_y, min_x:max_x] = final_blend.astype(np.uint8)
return vis_frame
def apply_mouth_area(