Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -121,9 +121,12 @@ def main():
|
|
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 |
)
|
@@ -140,26 +143,17 @@ def main():
|
|
140 |
label="Select Model",
|
141 |
)
|
142 |
|
143 |
-
#
|
144 |
-
if isinstance(args.score_slider_step, bool)
|
145 |
-
|
146 |
-
if isinstance(args.
|
147 |
-
args.score_general_threshold = 0.25 # Default value if it's a boolean
|
148 |
|
149 |
general_thresh = gr.Slider(
|
150 |
-
0, 1, step=
|
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=
|
161 |
-
value=float(args.score_character_threshold or 1.0),
|
162 |
-
label="Character Tags Threshold"
|
163 |
)
|
164 |
|
165 |
filter_tags = gr.Textbox(
|
@@ -172,6 +166,7 @@ def main():
|
|
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]
|
177 |
results = predictor.predict(images, model_repo, general_thresh, character_thresh)
|
|
|
121 |
gr.Markdown(f"<h1 style='text-align: center;'>{TITLE}</h1>")
|
122 |
gr.Markdown(DESCRIPTION)
|
123 |
|
124 |
+
with gr.Blocks(title=TITLE) as demo:
|
125 |
+
gr.Markdown(f"<h1 style='text-align: center;'>{TITLE}</h1>")
|
126 |
+
gr.Markdown(DESCRIPTION)
|
127 |
+
|
128 |
with gr.Row():
|
129 |
with gr.Column():
|
|
|
130 |
submit = gr.Button(
|
131 |
value="Process Images", variant="primary"
|
132 |
)
|
|
|
143 |
label="Select Model",
|
144 |
)
|
145 |
|
146 |
+
# Fallbacks for possibly invalid args
|
147 |
+
step = 0.1 if isinstance(args.score_slider_step, bool) else float(args.score_slider_step)
|
148 |
+
general_val = 0.25 if isinstance(args.score_general_threshold, bool) else float(args.score_general_threshold)
|
149 |
+
char_val = 1.0 if isinstance(args.score_character_threshold, bool) else float(args.score_character_threshold)
|
|
|
150 |
|
151 |
general_thresh = gr.Slider(
|
152 |
+
0, 1, step=step, value=general_val, label="General Tags Threshold"
|
|
|
|
|
153 |
)
|
154 |
|
|
|
|
|
|
|
|
|
155 |
character_thresh = gr.Slider(
|
156 |
+
0, 1, step=step, value=char_val, label="Character Tags Threshold"
|
|
|
|
|
157 |
)
|
158 |
|
159 |
filter_tags = gr.Textbox(
|
|
|
166 |
with gr.Column():
|
167 |
output = gr.Textbox(label="Output", lines=10)
|
168 |
|
169 |
+
|
170 |
def process_images(files, model_repo, general_thresh, character_thresh, filter_tags):
|
171 |
images = [Image.open(file.name) for file in files]
|
172 |
results = predictor.predict(images, model_repo, general_thresh, character_thresh)
|