narugo1992 commited on
Commit
495db77
1 Parent(s): 40de271

dev(narugo): update the GUI

Browse files
Files changed (1) hide show
  1. app.py +27 -18
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import re
2
  from functools import lru_cache
3
  from typing import List, Mapping, Tuple
@@ -85,21 +86,29 @@ def image_to_deepdanbooru_tags(image: Image.Image, threshold: float,
85
 
86
 
87
  if __name__ == '__main__':
88
- interface = gr.Interface(
89
- image_to_deepdanbooru_tags,
90
- inputs=[
91
- gr.Image(type='pil', label='Original Image'),
92
- gr.Slider(0.0, 1.0, 0.5, label='Tagging Confidence Threshold'),
93
- gr.Checkbox(value=False, label='Use Space Instead Of _'),
94
- gr.Checkbox(value=True, label='Use Text Escape'),
95
- gr.Checkbox(value=False, label='Keep Confidences'),
96
- gr.Checkbox(value=True, label='Descend By Confidence'),
97
- ],
98
- outputs=[
99
- gr.TextArea(label='Exported Text'),
100
- gr.Label(label='Tags'),
101
- ],
102
- interpretation="default"
103
-
104
- )
105
- interface.launch()
 
 
 
 
 
 
 
 
 
1
+ import os
2
  import re
3
  from functools import lru_cache
4
  from typing import List, Mapping, Tuple
 
86
 
87
 
88
  if __name__ == '__main__':
89
+ with gr.Blocks() as demo:
90
+ with gr.Row():
91
+ with gr.Column():
92
+ gr_input_image = gr.Image(type='pil', label='Original Image')
93
+ gr_threshold = gr.Slider(0.0, 1.0, 0.5, label='Tagging Confidence Threshold')
94
+ with gr.Row():
95
+ gr_space = gr.Checkbox(value=False, label='Use Space Instead Of _')
96
+ gr_escape = gr.Checkbox(value=True, label='Use Text Escape')
97
+ gr_confidence = gr.Checkbox(value=False, label='Keep Confidences')
98
+ gr_order = gr.Checkbox(value=True, label='Descend By Confidence')
99
+
100
+ gr_btn_submit = gr.Button(value='Tagging', variant='primary')
101
+
102
+ with gr.Column():
103
+ with gr.Tabs():
104
+ with gr.Tab("Tags"):
105
+ gr_tags = gr.Label(label='Tags')
106
+ with gr.Tab("Exported Text"):
107
+ gr_output_text = gr.TextArea(label='Exported Text')
108
+
109
+ gr_btn_submit.click(
110
+ image_to_deepdanbooru_tags,
111
+ inputs=[gr_input_image, gr_threshold, gr_space, gr_escape, gr_confidence, gr_order],
112
+ outputs=[gr_output_text, gr_tags],
113
+ )
114
+ demo.queue(os.cpu_count()).launch()