Refine result tile styling and image output visibility
Browse files- Remove redundant background color classes for result tile headers
- Hide image output by default in Gradio interface
- Maintain existing color scheme and layout structure
app.py
CHANGED
@@ -227,15 +227,15 @@ def predict_image(img, confidence_threshold):
|
|
227 |
def generate_results_html(results):
|
228 |
def get_header_color(label):
|
229 |
if label == 'AI':
|
230 |
-
return 'bg-red-500 text-red-700
|
231 |
elif label == 'REAL':
|
232 |
-
return 'bg-green-500 text-green-700
|
233 |
elif label == 'UNCERTAIN':
|
234 |
return 'bg-yellow-500 text-yellow-700 bg-yellow-100', 'bg-yellow-400', 'bg-yellow-100', 'bg-yellow-700 text-yellow-700', 'bg-yellow-200'
|
235 |
elif label == 'MAINTENANCE':
|
236 |
-
return 'bg-blue-500 text-blue-700
|
237 |
else:
|
238 |
-
return 'bg-gray-300 text-gray-700
|
239 |
|
240 |
|
241 |
html_content = f"""
|
@@ -313,7 +313,7 @@ def generate_results_html(results):
|
|
313 |
</div>
|
314 |
</div>
|
315 |
</div>
|
316 |
-
<div class="
|
317 |
<div class="w-full bg-gray-400 rounded-none h-8">
|
318 |
<div class="inline-flex whitespace-nowrap bg-red-400 h-full rounded-none" style="width: {results[1][3] * 100:.2f}%;">
|
319 |
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
@@ -481,7 +481,7 @@ with gr.Blocks() as iface:
|
|
481 |
confidence_slider = gr.Slider(0.0, 1.0, value=0.5, step=0.01, label="Confidence Threshold")
|
482 |
inputs = [image_input, confidence_slider]
|
483 |
with gr.Column(scale=2):
|
484 |
-
image_output = gr.Image(label="Processed Image")
|
485 |
# Custom HTML component to display results in 5 columns
|
486 |
results_html = gr.HTML(label="Model Predictions")
|
487 |
outputs = [image_output, results_html]
|
|
|
227 |
def generate_results_html(results):
|
228 |
def get_header_color(label):
|
229 |
if label == 'AI':
|
230 |
+
return 'bg-red-500 text-red-700', 'bg-red-400', 'bg-red-100', 'bg-red-700 text-red-700', 'bg-red-200'
|
231 |
elif label == 'REAL':
|
232 |
+
return 'bg-green-500 text-green-700', 'bg-green-400', 'bg-green-100', 'bg-green-700 text-green-700', 'bg-green-200'
|
233 |
elif label == 'UNCERTAIN':
|
234 |
return 'bg-yellow-500 text-yellow-700 bg-yellow-100', 'bg-yellow-400', 'bg-yellow-100', 'bg-yellow-700 text-yellow-700', 'bg-yellow-200'
|
235 |
elif label == 'MAINTENANCE':
|
236 |
+
return 'bg-blue-500 text-blue-700', 'bg-blue-400', 'bg-blue-100', 'bg-blue-700 text-blue-700', 'bg-blue-200'
|
237 |
else:
|
238 |
+
return 'bg-gray-300 text-gray-700', 'bg-gray-400', 'bg-gray-100', 'bg-gray-700 text-gray-700', 'bg-gray-200'
|
239 |
|
240 |
|
241 |
html_content = f"""
|
|
|
313 |
</div>
|
314 |
</div>
|
315 |
</div>
|
316 |
+
<div class="relative -mx-4 bg-gray-800">
|
317 |
<div class="w-full bg-gray-400 rounded-none h-8">
|
318 |
<div class="inline-flex whitespace-nowrap bg-red-400 h-full rounded-none" style="width: {results[1][3] * 100:.2f}%;">
|
319 |
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
|
|
481 |
confidence_slider = gr.Slider(0.0, 1.0, value=0.5, step=0.01, label="Confidence Threshold")
|
482 |
inputs = [image_input, confidence_slider]
|
483 |
with gr.Column(scale=2):
|
484 |
+
image_output = gr.Image(label="Processed Image", visible=False)
|
485 |
# Custom HTML component to display results in 5 columns
|
486 |
results_html = gr.HTML(label="Model Predictions")
|
487 |
outputs = [image_output, results_html]
|