aboutsummaryrefslogtreecommitdiff
path: root/modules/progress.py
diff options
context:
space:
mode:
authorNeil Mahseth <neilmahaseth@gmail.com>2023-07-06 22:02:47 +0530
committerGitHub <noreply@github.com>2023-07-06 22:02:47 +0530
commitc258dd34a888b7c6c9e4c9bbef76732d9d7db6e7 (patch)
tree80b4c8e9e4f3c7a62ae592a14621848b79a7c9a3 /modules/progress.py
parent394ffa7b0a7fff3ec484bcd084e673a8b301ccc8 (diff)
Fix UnicodeEncodeError when writing to file CLIP Interrogator Batch Mode
The code snippet print(interrogation_function(img), file=open(os.path.join(ii_output_dir, f"{left}.txt"), 'a')) raises a UnicodeEncodeError with the message "'charmap' codec can't encode character '\u016b' in position 129". This error occurs because the default encoding used by the open() function cannot handle certain Unicode characters. To fix this issue, the encoding parameter needs to be explicitly specified when opening the file. By using an appropriate encoding, such as 'utf-8', we can ensure that Unicode characters are properly encoded and written to the file. The updated code should be modified as follows: python Copy code print(interrogation_function(img), file=open(os.path.join(ii_output_dir, f"{left}.txt"), 'a', encoding='utf-8')) By making this change, the code will no longer raise the UnicodeEncodeError and will correctly handle Unicode characters during the file write operation.
Diffstat (limited to 'modules/progress.py')
0 files changed, 0 insertions, 0 deletions