Add default for caption extension tools
This commit is contained in:
parent
f265197ba9
commit
fcad6bfd98
@ -16,6 +16,10 @@ def caption_images(
|
|||||||
if images_dir_input == '':
|
if images_dir_input == '':
|
||||||
msgbox('Image folder is missing...')
|
msgbox('Image folder is missing...')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if caption_file_ext == '':
|
||||||
|
msgbox('Please provide an extension for the caption files.')
|
||||||
|
return
|
||||||
|
|
||||||
if not caption_text_input == '':
|
if not caption_text_input == '':
|
||||||
print(
|
print(
|
||||||
@ -83,7 +87,8 @@ def gradio_basic_caption_gui_tab():
|
|||||||
)
|
)
|
||||||
caption_file_ext = gr.Textbox(
|
caption_file_ext = gr.Textbox(
|
||||||
label='Caption file extension',
|
label='Caption file extension',
|
||||||
placeholder='(Optional) Default: .caption',
|
placeholder='Extention for caption file. eg: .caption, .txt',
|
||||||
|
value='.txt',
|
||||||
interactive=True,
|
interactive=True,
|
||||||
)
|
)
|
||||||
overwrite_input = gr.Checkbox(
|
overwrite_input = gr.Checkbox(
|
||||||
|
@ -26,6 +26,10 @@ def caption_images(
|
|||||||
if train_data_dir == '':
|
if train_data_dir == '':
|
||||||
msgbox('Image folder is missing...')
|
msgbox('Image folder is missing...')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if caption_file_ext == '':
|
||||||
|
msgbox('Please provide an extension for the caption files.')
|
||||||
|
return
|
||||||
|
|
||||||
print(f'Captioning files in {train_data_dir}...')
|
print(f'Captioning files in {train_data_dir}...')
|
||||||
run_cmd = f'.\\venv\\Scripts\\python.exe "finetune/make_captions.py"'
|
run_cmd = f'.\\venv\\Scripts\\python.exe "finetune/make_captions.py"'
|
||||||
@ -82,7 +86,8 @@ def gradio_blip_caption_gui_tab():
|
|||||||
with gr.Row():
|
with gr.Row():
|
||||||
caption_file_ext = gr.Textbox(
|
caption_file_ext = gr.Textbox(
|
||||||
label='Caption file extension',
|
label='Caption file extension',
|
||||||
placeholder='(Optional) Default: .caption',
|
placeholder='Extention for caption file. eg: .caption, .txt',
|
||||||
|
value='.txt',
|
||||||
interactive=True,
|
interactive=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ def find_replace(folder='', caption_file_ext='.caption', find='', replace=''):
|
|||||||
|
|
||||||
files = [f for f in os.listdir(folder) if f.endswith(caption_file_ext)]
|
files = [f for f in os.listdir(folder) if f.endswith(caption_file_ext)]
|
||||||
for file in files:
|
for file in files:
|
||||||
with open(os.path.join(folder, file), 'r') as f:
|
with open(os.path.join(folder, file), 'r', errors="ignore") as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
f.close
|
f.close
|
||||||
content = content.replace(find, replace)
|
content = content.replace(find, replace)
|
||||||
|
@ -14,6 +14,10 @@ def caption_images(train_data_dir, caption_extension, batch_size, thresh):
|
|||||||
if train_data_dir == '':
|
if train_data_dir == '':
|
||||||
msgbox('Image folder is missing...')
|
msgbox('Image folder is missing...')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if caption_extension == '':
|
||||||
|
msgbox('Please provide an extension for the caption files.')
|
||||||
|
return
|
||||||
|
|
||||||
print(f'Captioning files in {train_data_dir}...')
|
print(f'Captioning files in {train_data_dir}...')
|
||||||
run_cmd = f'accelerate launch "./finetune/tag_images_by_wd14_tagger.py"'
|
run_cmd = f'accelerate launch "./finetune/tag_images_by_wd14_tagger.py"'
|
||||||
@ -56,7 +60,8 @@ def gradio_wd14_caption_gui_tab():
|
|||||||
|
|
||||||
caption_extension = gr.Textbox(
|
caption_extension = gr.Textbox(
|
||||||
label='Caption file extension',
|
label='Caption file extension',
|
||||||
placeholder='(Optional) Default: .caption',
|
placeholder='Extention for caption file. eg: .caption, .txt',
|
||||||
|
value='.txt',
|
||||||
interactive=True,
|
interactive=True,
|
||||||
)
|
)
|
||||||
thresh = gr.Number(value=0.35, label='Threshold')
|
thresh = gr.Number(value=0.35, label='Threshold')
|
||||||
|
@ -267,6 +267,10 @@ def train_model(
|
|||||||
if output_dir == '':
|
if output_dir == '':
|
||||||
msgbox('Output folder path is missing')
|
msgbox('Output folder path is missing')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if stop_text_encoder_training_pct > 0:
|
||||||
|
msgbox('Output "stop text encoder training" is not yet supported. Ignoring')
|
||||||
|
stop_text_encoder_training_pct = 0
|
||||||
|
|
||||||
# If string is empty set string to 0.
|
# If string is empty set string to 0.
|
||||||
if text_encoder_lr == '':
|
if text_encoder_lr == '':
|
||||||
|
Loading…
Reference in New Issue
Block a user