Upload 13 files
Browse filesFiles changed (5)
- app.py+9-3
- model.py+1-1
- requirements.txt+1-1
- tagger/fl2sd3longcap.py+4-2
- tagger/utils.py+5
20 unmodified lines21222324252613 unmodified lines4041424344454647484950519 unmodified lines61626364656675 unmodified lines1421431441451461471481491503 unmodified lines15415515615715815920 unmodified linesremove_specific_prompt,convert_danbooru_to_e621_prompt,insert_recom_prompt,)from tagger.fl2sd3longcap import predict_tags_fl2_sd3from tagger.v2 import (13 unmodified linescss = """#model_info { text-align: center; display:block; }"""with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", css=css) as demo:with gr.Column():with gr.Accordion("Advanced settings", open=True):with gr.Accordion("Recommended Prompt", open=False):recom_prompt_preset = gr.Radio(label="Set Presets", choices=get_recom_prompt_type(), value="Common")with gr.Row():9 unmodified linesv2_ban_tags = gr.Textbox(label="Ban tags", info="Tags to ban from the output.", placeholder="alternate costumen, ...", value="censored")v2_tag_type = gr.Radio(label="Tag Type", info="danbooru for common, e621 for Pony.", choices=["danbooru", "e621"], value="danbooru", visible=False)v2_model = gr.Dropdown(label="Model", choices=list(V2_ALL_MODELS.keys()), value=list(V2_ALL_MODELS.keys())[0])with gr.Accordion("Model", open=True):model_name = gr.Dropdown(label="Select Model", show_label=False, choices=list(loaded_models.keys()), value=list(loaded_models.keys())[0], allow_custom_value=True)model_info = gr.Markdown(value=get_model_info_md(list(loaded_models.keys())[0]), elem_id="model_info")75 unmodified linesconvert_danbooru_to_e621_prompt, [prompt, v2_tag_type], [prompt], queue=False, show_api=False,)tagger_generate_from_image.click(predict_tags_wd,[tagger_image, prompt, tagger_algorithms, tagger_general_threshold, tagger_character_threshold],[v2_series, v2_character, prompt, gr.Button(visible=False)],show_api=False,).success(predict_tags_fl2_sd3, [tagger_image, prompt, tagger_algorithms], [prompt], show_api=False,3 unmodified linesconvert_danbooru_to_e621_prompt, [prompt, tagger_tag_type], [prompt], queue=False, show_api=False,).success(insert_recom_prompt, [prompt, neg_prompt, tagger_recom_prompt], [prompt, neg_prompt], queue=False, show_api=False,)demo.queue()20 unmodified lines2122232425262713 unmodified lines4142434445464748495051529 unmodified lines6263646566676875 unmodified lines1441451461471481491501511521531543 unmodified lines15815916016116216316416520 unmodified linesremove_specific_prompt,convert_danbooru_to_e621_prompt,insert_recom_prompt,compose_prompt_to_copy,)from tagger.fl2sd3longcap import predict_tags_fl2_sd3from tagger.v2 import (13 unmodified linescss = """#model_info { text-align: center; }"""with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", css=css) as demo:with gr.Column():with gr.Accordion("Advanced settings", open=False):with gr.Accordion("Recommended Prompt", open=False):recom_prompt_preset = gr.Radio(label="Set Presets", choices=get_recom_prompt_type(), value="Common")with gr.Row():9 unmodified linesv2_ban_tags = gr.Textbox(label="Ban tags", info="Tags to ban from the output.", placeholder="alternate costumen, ...", value="censored")v2_tag_type = gr.Radio(label="Tag Type", info="danbooru for common, e621 for Pony.", choices=["danbooru", "e621"], value="danbooru", visible=False)v2_model = gr.Dropdown(label="Model", choices=list(V2_ALL_MODELS.keys()), value=list(V2_ALL_MODELS.keys())[0])v2_copy = gr.Button(value="Copy to clipboard", size="sm", interactive=False)with gr.Accordion("Model", open=True):model_name = gr.Dropdown(label="Select Model", show_label=False, choices=list(loaded_models.keys()), value=list(loaded_models.keys())[0], allow_custom_value=True)model_info = gr.Markdown(value=get_model_info_md(list(loaded_models.keys())[0]), elem_id="model_info")75 unmodified linesconvert_danbooru_to_e621_prompt, [prompt, v2_tag_type], [prompt], queue=False, show_api=False,)tagger_generate_from_image.click(lambda: ("", "", ""), None, [v2_series, v2_character, prompt], queue=False, show_api=False,).success(predict_tags_wd,[tagger_image, prompt, tagger_algorithms, tagger_general_threshold, tagger_character_threshold],[v2_series, v2_character, prompt, v2_copy],show_api=False,).success(predict_tags_fl2_sd3, [tagger_image, prompt, tagger_algorithms], [prompt], show_api=False,3 unmodified linesconvert_danbooru_to_e621_prompt, [prompt, tagger_tag_type], [prompt], queue=False, show_api=False,).success(insert_recom_prompt, [prompt, neg_prompt, tagger_recom_prompt], [prompt, neg_prompt], queue=False, show_api=False,).success(compose_prompt_to_copy, [v2_character, v2_series, prompt], [prompt], queue=False, show_api=False,)demo.queue()
1234567from multit2i import find_model_listmodels = find_model_list("John6666", ["anime"], "", "downloads", 100)# Examples:1234567from multit2i import find_model_listmodels = find_model_list("John6666", ["anime"], "", "downloads", 200)# Examples:
12345huggingface_hubtorchtorchvisionacceleratetransformers12345huggingface_hubtorch==2.2.0torchvisionacceleratetransformers
1 unmodified line2345678910111235 unmodified lines484950515253541 unmodified lineimport spacesimport refrom PIL import Imageimport subprocesssubprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)fl_model = AutoModelForCausalLM.from_pretrained('gokaygokay/Florence-2-SD3-Captioner', trust_remote_code=True).eval()fl_processor = AutoProcessor.from_pretrained('gokaygokay/Florence-2-SD3-Captioner', trust_remote_code=True)35 unmodified linesif image.mode != "RGB":image = image.convert("RGB")inputs = fl_processor(text=prompt, images=image, return_tensors="pt")generated_ids = fl_model.generate(input_ids=inputs["input_ids"],pixel_values=inputs["pixel_values"],1 unmodified line23456789101112131435 unmodified lines505152535455561 unmodified lineimport spacesimport refrom PIL import Imageimport torchimport subprocesssubprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)device = "cuda" if torch.cuda.is_available() else "cpu"fl_model = AutoModelForCausalLM.from_pretrained('gokaygokay/Florence-2-SD3-Captioner', trust_remote_code=True).to(device).eval()fl_processor = AutoProcessor.from_pretrained('gokaygokay/Florence-2-SD3-Captioner', trust_remote_code=True)35 unmodified linesif image.mode != "RGB":image = image.convert("RGB")inputs = fl_processor(text=prompt, images=image, return_tensors="pt").to(device)generated_ids = fl_model.generate(input_ids=inputs["input_ids"],pixel_values=inputs["pixel_values"],
42 unmodified lines43444542 unmodified linesnavigator.clipboard.writeText(inputs);}}"""42 unmodified lines434445464748495042 unmodified linesnavigator.clipboard.writeText(inputs);}}"""def gradio_copy_prompt(prompt: str):gr.Info("Copied!")return prompt
app.py+9-3
model.py+1-1
requirements.txt+1-1
tagger/fl2sd3longcap.py+4-2
tagger/utils.py+5