Spaces:
Running
Running
narugo1992
commited on
Commit
·
733ba14
1
Parent(s):
d9e6838
dev(narugo): update GUI
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import re
|
| 2 |
from typing import Mapping, Tuple, Dict
|
| 3 |
|
|
@@ -152,23 +153,32 @@ def image_to_wd14_tags(image: Image.Image, model_name: str, threshold: float,
|
|
| 152 |
|
| 153 |
|
| 154 |
if __name__ == '__main__':
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
import re
|
| 3 |
from typing import Mapping, Tuple, Dict
|
| 4 |
|
|
|
|
| 153 |
|
| 154 |
|
| 155 |
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='Original Image')
|
| 160 |
+
with gr.Row():
|
| 161 |
+
gr_model = gr.Radio(list(WAIFU_MODELS.keys()), value='wd14-vit', label='Waifu Model')
|
| 162 |
+
gr_threshold = gr.Slider(0.0, 1.0, 0.5, label='Tagging Confidence Threshold')
|
| 163 |
+
with gr.Row():
|
| 164 |
+
gr_space = gr.Checkbox(value=False, label='Use Space Instead Of _')
|
| 165 |
+
gr_escape = gr.Checkbox(value=True, label='Use Text Escape')
|
| 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='Tagging', variant='primary')
|
| 170 |
+
|
| 171 |
+
with gr.Column():
|
| 172 |
+
gr_ratings = gr.Label(label='Ratings')
|
| 173 |
+
with gr.Tabs():
|
| 174 |
+
with gr.Tab("Tags"):
|
| 175 |
+
gr_tags = gr.Label(label='Tags')
|
| 176 |
+
with gr.Tab("Exported Text"):
|
| 177 |
+
gr_output_text = gr.TextArea(label='Exported Text')
|
| 178 |
+
|
| 179 |
+
gr_btn_submit.click(
|
| 180 |
+
image_to_wd14_tags,
|
| 181 |
+
inputs=[gr_input_image, gr_model, gr_threshold, gr_space, gr_escape, gr_confidence, gr_order],
|
| 182 |
+
outputs=[gr_ratings, gr_output_text, gr_tags],
|
| 183 |
+
)
|
| 184 |
+
demo.queue(os.cpu_count()).launch()
|