Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -115,8 +115,8 @@ class WaifuDiffusionInterrogator:
|
|
115 |
|
116 |
|
117 |
WAIFU_MODELS: Mapping[str, WaifuDiffusionInterrogator] = {
|
118 |
-
'
|
119 |
-
'
|
120 |
repo='SmilingWolf/wd-v1-4-convnext-tagger'
|
121 |
),
|
122 |
}
|
@@ -124,7 +124,7 @@ RE_SPECIAL = re.compile(r'([\\()])')
|
|
124 |
|
125 |
|
126 |
def image_to_wd14_tags(image: Image.Image, model_name: str, threshold: float,
|
127 |
-
use_spaces: bool, use_escape: bool, include_ranks
|
128 |
-> Tuple[Mapping[str, float], str, Mapping[str, float]]:
|
129 |
model = WAIFU_MODELS[model_name]
|
130 |
ratings, tags = model.interrogate(image)
|
@@ -156,29 +156,27 @@ if __name__ == '__main__':
|
|
156 |
with gr.Blocks() as demo:
|
157 |
with gr.Row():
|
158 |
with gr.Column():
|
159 |
-
gr_input_image = gr.Image(type='pil', label='
|
160 |
with gr.Row():
|
161 |
-
gr_model = gr.Radio(list(WAIFU_MODELS.keys()), value='
|
162 |
gr_threshold = gr.Slider(0.0, 1.0, 0.5, label='Chen Chen Chen Chen Chen')
|
163 |
with gr.Row():
|
164 |
-
gr_space = gr.Checkbox(value=
|
165 |
-
gr_escape = gr.Checkbox(value=True, label='
|
166 |
-
gr_confidence = gr.Checkbox(value=False, label='Keep Confidences')
|
167 |
-
gr_order = gr.Checkbox(value=True, label='Descend By Confidence')
|
168 |
|
169 |
-
gr_btn_submit = gr.Button(value='
|
170 |
|
171 |
with gr.Column():
|
172 |
-
gr_ratings = gr.Label(label='
|
173 |
with gr.Tabs():
|
174 |
-
with gr.Tab("
|
175 |
-
gr_tags = gr.Label(label='
|
176 |
-
with gr.Tab("
|
177 |
-
gr_output_text = gr.TextArea(label='
|
178 |
|
179 |
gr_btn_submit.click(
|
180 |
image_to_wd14_tags,
|
181 |
-
inputs=[gr_input_image, gr_model, gr_threshold, gr_space, gr_escape
|
182 |
outputs=[gr_ratings, gr_output_text, gr_tags],
|
183 |
)
|
184 |
demo.queue(os.cpu_count()).launch()
|
|
|
115 |
|
116 |
|
117 |
WAIFU_MODELS: Mapping[str, WaifuDiffusionInterrogator] = {
|
118 |
+
'chen-vit': WaifuDiffusionInterrogator(),
|
119 |
+
'chen-convnext': WaifuDiffusionInterrogator(
|
120 |
repo='SmilingWolf/wd-v1-4-convnext-tagger'
|
121 |
),
|
122 |
}
|
|
|
124 |
|
125 |
|
126 |
def image_to_wd14_tags(image: Image.Image, model_name: str, threshold: float,
|
127 |
+
use_spaces: bool, use_escape: bool, include_ranks=False, score_descend=True) \
|
128 |
-> Tuple[Mapping[str, float], str, Mapping[str, float]]:
|
129 |
model = WAIFU_MODELS[model_name]
|
130 |
ratings, tags = model.interrogate(image)
|
|
|
156 |
with gr.Blocks() as demo:
|
157 |
with gr.Row():
|
158 |
with gr.Column():
|
159 |
+
gr_input_image = gr.Image(type='pil', label='Chen Chen')
|
160 |
with gr.Row():
|
161 |
+
gr_model = gr.Radio(list(WAIFU_MODELS.keys()), value='chen-vit', label='Chen')
|
162 |
gr_threshold = gr.Slider(0.0, 1.0, 0.5, label='Chen Chen Chen Chen Chen')
|
163 |
with gr.Row():
|
164 |
+
gr_space = gr.Checkbox(value=True, label='Chen " " Chen Chen "_"')
|
165 |
+
gr_escape = gr.Checkbox(value=True, label='Chen Text Escape')
|
|
|
|
|
166 |
|
167 |
+
gr_btn_submit = gr.Button(value='橙', variant='primary')
|
168 |
|
169 |
with gr.Column():
|
170 |
+
gr_ratings = gr.Label(label='橙 橙')
|
171 |
with gr.Tabs():
|
172 |
+
with gr.Tab("Chens"):
|
173 |
+
gr_tags = gr.Label(label='Chens')
|
174 |
+
with gr.Tab("Chen Text"):
|
175 |
+
gr_output_text = gr.TextArea(label='Chen Text')
|
176 |
|
177 |
gr_btn_submit.click(
|
178 |
image_to_wd14_tags,
|
179 |
+
inputs=[gr_input_image, gr_model, gr_threshold, gr_space, gr_escape],
|
180 |
outputs=[gr_ratings, gr_output_text, gr_tags],
|
181 |
)
|
182 |
demo.queue(os.cpu_count()).launch()
|