Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -12,12 +12,20 @@ DESCRIPTION = "Demo for the WaifuDiffusion tagger models"
|
|
12 |
|
13 |
HF_TOKEN = os.environ.get("HF_TOKEN", "")
|
14 |
|
15 |
-
# Model Repositories
|
16 |
VIT_MODEL_DSV3_REPO = "SmilingWolf/wd-vit-tagger-v3"
|
17 |
-
|
18 |
MODEL_FILENAME = "model.onnx"
|
19 |
LABEL_FILENAME = "selected_tags.csv"
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
def parse_args():
|
22 |
parser = argparse.ArgumentParser()
|
23 |
parser.add_argument("--score-slider-step", type=float, default=0.05)
|
@@ -154,30 +162,14 @@ with gr.Blocks(title=TITLE) as demo:
|
|
154 |
gr.Markdown(f"<h1 style='text-align: center;'>{TITLE}</h1>")
|
155 |
gr.Markdown(DESCRIPTION)
|
156 |
|
157 |
-
with gr.
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
with gr.Accordion("Advanced Settings", open=False):
|
162 |
-
model_repo = gr.Dropdown([VIT_MODEL_DSV3_REPO], value=VIT_MODEL_DSV3_REPO, label="Select Model")
|
163 |
-
general_thresh = gr.Slider(0, 1, step=args.score_slider_step, value=args.score_general_threshold, label="General Tags Threshold")
|
164 |
-
character_thresh = gr.Slider(0, 1, step=args.score_slider_step, value=args.score_character_threshold, label="Character Tags Threshold")
|
165 |
-
filter_tags = gr.Textbox(label="Filter Tags (comma-separated)", lines=3)
|
166 |
-
|
167 |
-
submit = gr.Button(value="Process Images", variant="primary")
|
168 |
-
|
169 |
-
with gr.Column():
|
170 |
-
output = gr.Textbox(label="Output", lines=10)
|
171 |
-
|
172 |
-
with gr.Accordion("Tag Replacements", open=False):
|
173 |
-
replacement_rules_text = gr.Textbox(label="Replacement Rules", placeholder="e.g., 1boy -> 1girl", lines=5)
|
174 |
|
175 |
-
|
176 |
-
|
177 |
|
178 |
-
submit.click(process_images,
|
179 |
-
inputs=[image_files, model_repo, general_thresh, character_thresh, filter_tags, replacement_rules_text, fallback_rules_text],
|
180 |
-
outputs=output)
|
181 |
|
182 |
-
demo.queue(max_size=10)
|
183 |
demo.launch()
|
|
|
12 |
|
13 |
HF_TOKEN = os.environ.get("HF_TOKEN", "")
|
14 |
|
|
|
15 |
VIT_MODEL_DSV3_REPO = "SmilingWolf/wd-vit-tagger-v3"
|
|
|
16 |
MODEL_FILENAME = "model.onnx"
|
17 |
LABEL_FILENAME = "selected_tags.csv"
|
18 |
|
19 |
+
PREDEFINED_FILTER_TAGS = [
|
20 |
+
"loli", "oppai_loli", "onee-shota", "incest", "furry", "furry_female", "shota",
|
21 |
+
"male_focus", "signature", "otoko_no_ko", "minigirl", "patreon_username", "babydoll",
|
22 |
+
"monochrome", "happy_birthday", "happy_new_year", "thought_bubble", "greyscale",
|
23 |
+
"speech_bubble", "english_text", "copyright_name", "twitter_username",
|
24 |
+
"patreon username", "patreon logo", "cover", "content_rating", "cover_page",
|
25 |
+
"doujin_cover", "sex", "artist_name", "watermark", "censored", "bar_censor",
|
26 |
+
"blank_censor", "blur_censor", "light_censor", "mosaic_censoring"
|
27 |
+
]
|
28 |
+
|
29 |
def parse_args():
|
30 |
parser = argparse.ArgumentParser()
|
31 |
parser.add_argument("--score-slider-step", type=float, default=0.05)
|
|
|
162 |
gr.Markdown(f"<h1 style='text-align: center;'>{TITLE}</h1>")
|
163 |
gr.Markdown(DESCRIPTION)
|
164 |
|
165 |
+
with gr.Accordion("Settings", open=False):
|
166 |
+
filter_tags = gr.Textbox(value=", ".join(PREDEFINED_FILTER_TAGS), label="Filter Tags (comma-separated)", lines=3)
|
167 |
+
replacement_rules_text = gr.Textbox(label="Replacement Rules", value="1boy -> 1girl", lines=5)
|
168 |
+
fallback_rules_text = gr.Textbox(label="Fallback Rules", value="sad, happy -> smile", lines=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
+
submit = gr.Button(value="Process Images")
|
171 |
+
output = gr.Textbox(label="Output", lines=10)
|
172 |
|
173 |
+
submit.click(process_images, inputs=[[], VIT_MODEL_DSV3_REPO, args.score_general_threshold, args.score_character_threshold, filter_tags, replacement_rules_text, fallback_rules_text], outputs=output)
|
|
|
|
|
174 |
|
|
|
175 |
demo.launch()
|