CoolFace
Apppublic

Rifd/Ultimate-Vocal-Remover-WebUI

sourceHugging Facemitupdated 3y agoView on Hugging Face
5likes
error_handling.py107 linesDownload Raw Back to gui_data
1from datetime import datetime2import traceback3 4CUDA_MEMORY_ERROR = "CUDA out of memory"5CUDA_RUNTIME_ERROR = "CUDNN error executing cudnnSetTensorNdDescriptor"6DEMUCS_MODEL_MISSING_ERROR = "is neither a single pre-trained model or a bag of models."7ENSEMBLE_MISSING_MODEL_ERROR = "local variable \'enseExport\' referenced before assignment"8FFMPEG_MISSING_ERROR = """audioread\__init__.py", line 116, in audio_open"""9FILE_MISSING_ERROR = "FileNotFoundError"10MDX_MEMORY_ERROR = "onnxruntime::CudaCall CUDA failure 2: out of memory"11MDX_MODEL_MISSING = "[ONNXRuntimeError] : 3 : NO_SUCHFILE"12MDX_MODEL_SETTINGS_ERROR = "Got invalid dimensions for input"13MDX_RUNTIME_ERROR = "onnxruntime::BFCArena::AllocateRawInternal"14MODULE_ERROR = "ModuleNotFoundError"15WINDOW_SIZE_ERROR = "h1_shape[3] must be greater than h2_shape[3]"16SF_WRITE_ERROR = "sf.write"17SYSTEM_MEMORY_ERROR = "DefaultCPUAllocator: not enough memory"18MISSING_MODEL_ERROR = "'NoneType\' object has no attribute \'model_basename\'"19ARRAY_SIZE_ERROR = "ValueError: \"array is too big; `arr.size * arr.dtype.itemsize` is larger than the maximum possible size.\""20GPU_INCOMPATIBLE_ERROR = "no kernel image is available for execution on the device"21 22CONTACT_DEV = 'If this error persists, please contact the developers with the error details.'23 24ERROR_MAPPER = {25    CUDA_MEMORY_ERROR:26                        ('The application was unable to allocate enough GPU memory to use this model. ' + 27                        'Please close any GPU intensive applications and try again.\n' + 28                        'If the error persists, your GPU might not be supported.') ,29    CUDA_RUNTIME_ERROR:30                        (f'Your PC cannot process this audio file with the chunk size selected. Please lower the chunk size and try again.\n\n{CONTACT_DEV}'),31    DEMUCS_MODEL_MISSING_ERROR:32                        ('The selected Demucs model is missing. ' + 33                        'Please download the model or make sure it is in the correct directory.'),34    ENSEMBLE_MISSING_MODEL_ERROR:35                        ('The application was unable to locate a model you selected for this ensemble.\n\n' + 36                        'Please do the following to use all compatible models:\n\n1. Navigate to the \"Updates\" tab in the Help Guide.\n2. Download and install the model expansion pack.\n3. Then try again.\n\n' + 37                        'If the error persists, please verify all models are present.'),38    FFMPEG_MISSING_ERROR:39                        ('The input file type is not supported or FFmpeg is missing. Please select a file type supported by FFmpeg and try again. ' + 40                        'If FFmpeg is missing or not installed, you will only be able to process \".wav\" files until it is available on this system. ' + 41                        f'See the \"More Info\" tab in the Help Guide.\n\n{CONTACT_DEV}'),42    FILE_MISSING_ERROR:43                        (f'Missing file error raised. Please address the error and try again.\n\n{CONTACT_DEV}'),44    MDX_MEMORY_ERROR:45                        ('The application was unable to allocate enough GPU memory to use this model.\n\n' + 46                        'Please do the following:\n\n1. Close any GPU intensive applications.\n2. Lower the set chunk size.\n3. Then try again.\n\n' + 47                        'If the error persists, your GPU might not be supported.'),48    MDX_MODEL_MISSING:49                        ('The application could not detect this MDX-Net model on your system. ' + 50                        'Please make sure all the models are present in the correct directory.\n\n' + 51                        'If the error persists, please reinstall application or contact the developers.'),52    MDX_RUNTIME_ERROR:53                        ('The application was unable to allocate enough GPU memory to use this model.\n\n' + 54                        'Please do the following:\n\n1. Close any GPU intensive applications.\n2. Lower the set chunk size.\n3. Then try again.\n\n' + 55                        'If the error persists, your GPU might not be supported.'),56    WINDOW_SIZE_ERROR:57                        ('Invalid window size.\n\n' + 58                        'The chosen window size is likely not compatible with this model. Please select a different size and try again.'),59    SF_WRITE_ERROR:60                        ('Could not write audio file.\n\n' + 61                        'This could be due to one of the following:\n\n1. Low storage on target device.\n2. The export directory no longer exists.\n3. A system permissions issue.'),62    SYSTEM_MEMORY_ERROR:63                        ('The application was unable to allocate enough system memory to use this model.\n\n' + 64                        'Please do the following:\n\n1. Restart this application.\n2. Ensure any CPU intensive applications are closed.\n3. Then try again.\n\n' + 65                        'Please Note: Intel Pentium and Intel Celeron processors do not work well with this application.\n\n' +66                        'If the error persists, the system may not have enough RAM, or your CPU might not be supported.'),67    MISSING_MODEL_ERROR:68                        ('Model Missing: The application was unable to locate the chosen model.\n\n' + 69                        'If the error persists, please verify any selected models are present.'),70    GPU_INCOMPATIBLE_ERROR:71                        ('This process is not compatible with your GPU.\n\n' + 72                        'Please uncheck \"GPU Conversion\" and try again'),73    ARRAY_SIZE_ERROR:74                        ('The application was not able to process the given audiofile. Please convert the audiofile to another format and try again.'),75}76 77def error_text(process_method, exception):78                 79    traceback_text = ''.join(traceback.format_tb(exception.__traceback__))80    message = f'{type(exception).__name__}: "{exception}"\nTraceback Error: "\n{traceback_text}"\n'81    error_message = f'\n\nRaw Error Details:\n\n{message}\nError Time Stamp [{datetime.now().strftime("%Y-%m-%d %H:%M:%S")}]\n'82    process = f'Last Error Received:\n\nProcess: {process_method}\n\n'83 84    for error_type, full_text in ERROR_MAPPER.items():85        if error_type in message:86            final_message = full_text87            break88    else:89        final_message = (CONTACT_DEV) 90        91    return f"{process}{final_message}{error_message}"92 93def error_dialouge(exception):94    95    error_name = f'{type(exception).__name__}'96    traceback_text = ''.join(traceback.format_tb(exception.__traceback__))97    message = f'{error_name}: "{exception}"\n{traceback_text}"'98    99    for error_type, full_text in ERROR_MAPPER.items():100        if error_type in message:101            final_message = full_text102            break103    else:104        final_message = (f'{error_name}: {exception}\n\n{CONTACT_DEV}') 105    106    return final_message107