ura23 commited on
Commit
21f4426
·
verified ·
1 Parent(s): 725266c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -33
app.py CHANGED
@@ -118,43 +118,59 @@ def main():
118
  "2025"]
119
 
120
  with gr.Blocks(title=TITLE) as demo:
121
- gr.Markdown(f"<h1 style='text-align: center;'>{TITLE}</h1>")
122
- gr.Markdown(DESCRIPTION)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
- with gr.Row():
125
- with gr.Column():
 
126
 
127
- submit = gr.Button(
128
- value="Process Images", variant="primary"
 
 
129
  )
130
-
131
- image_files = gr.File(
132
- file_types=["image"], label="Upload Images", file_count="multiple",
 
 
 
133
  )
134
-
135
- # Wrap the model selection and sliders in an Accordion
136
- with gr.Accordion("Advanced Settings", open=False): # Collapsible by default
137
- model_repo = gr.Dropdown(
138
- model_repos,
139
- value=VIT_MODEL_DSV3_REPO,
140
- label="Select Model",
141
- )
142
- general_thresh = gr.Slider(
143
- 0, 1, step=args.score_slider_step, value=args.score_general_threshold, label="General Tags Threshold"
144
- )
145
- character_thresh = gr.Slider(
146
- 0, 1, step=args.score_slider_step, value=args.score_character_threshold, label="Character Tags Threshold"
147
- )
148
- filter_tags = gr.Textbox(
149
- value=", ".join(predefined_tags),
150
- label="Filter Tags (comma-separated)",
151
- placeholder="Add tags to filter out (e.g., winter, red, from above)",
152
- lines=9
153
- )
154
-
155
-
156
- with gr.Column():
157
- output = gr.Textbox(label="Output", lines=10)
158
 
159
  def process_images(files, model_repo, general_thresh, character_thresh, filter_tags):
160
  images = [Image.open(file.name) for file in files]
 
118
  "2025"]
119
 
120
  with gr.Blocks(title=TITLE) as demo:
121
+ gr.Markdown(f"<h1 style='text-align: center;'>{TITLE}</h1>")
122
+ gr.Markdown(DESCRIPTION)
123
+
124
+ with gr.Row():
125
+ with gr.Column():
126
+
127
+ submit = gr.Button(
128
+ value="Process Images", variant="primary"
129
+ )
130
+
131
+ image_files = gr.File(
132
+ file_types=["image"], label="Upload Images", file_count="multiple",
133
+ )
134
+
135
+ # Wrap the model selection and sliders in an Accordion
136
+ with gr.Accordion("Advanced Settings", open=False): # Collapsible by default
137
+ model_repo = gr.Dropdown(
138
+ model_repos,
139
+ value=VIT_MODEL_DSV3_REPO,
140
+ label="Select Model",
141
+ )
142
+
143
+ # Ensure args.score_slider_step and args.score_general_threshold are valid floats
144
+ if isinstance(args.score_slider_step, bool):
145
+ args.score_slider_step = 0.1 # Default value if it's a boolean
146
+ if isinstance(args.score_general_threshold, bool):
147
+ args.score_general_threshold = 0.25 # Default value if it's a boolean
148
+
149
+ general_thresh = gr.Slider(
150
+ 0, 1, step=float(args.score_slider_step or 0.1),
151
+ value=float(args.score_general_threshold or 0.25),
152
+ label="General Tags Threshold"
153
+ )
154
 
155
+ # Ensure args.score_character_threshold is a valid float
156
+ if isinstance(args.score_character_threshold, bool):
157
+ args.score_character_threshold = 1.0 # Default value if it's a boolean
158
 
159
+ character_thresh = gr.Slider(
160
+ 0, 1, step=float(args.score_slider_step or 0.1),
161
+ value=float(args.score_character_threshold or 1.0),
162
+ label="Character Tags Threshold"
163
  )
164
+
165
+ filter_tags = gr.Textbox(
166
+ value=", ".join(predefined_tags),
167
+ label="Filter Tags (comma-separated)",
168
+ placeholder="Add tags to filter out (e.g., winter, red, from above)",
169
+ lines=9
170
  )
171
+
172
+ with gr.Column():
173
+ output = gr.Textbox(label="Output", lines=10)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
  def process_images(files, model_repo, general_thresh, character_thresh, filter_tags):
176
  images = [Image.open(file.name) for file in files]