Soheib Takhtardeshir commited on
Commit ·
7775b13
1
Parent(s): cf5100b
second
Browse files
app.py
CHANGED
|
@@ -267,12 +267,12 @@ def compress_and_display(image_pil, model_filename, qp_value):
|
|
| 267 |
|
| 268 |
bits_spatial = calculate_entropy(y_s_quantized)
|
| 269 |
bits_angular = calculate_entropy(y_a_quantized)
|
| 270 |
-
total_bits += bits_spatial.item() + bits_angular.item() * 0.
|
| 271 |
|
| 272 |
reconstructed_tensor = reassemble_image(reconstructed_patches, image_pil.size, patch_size_config, step_size_config)
|
| 273 |
reconstructed_tensor = reconstructed_tensor.clamp(0, 1)
|
| 274 |
|
| 275 |
-
total_pixels = image_pil.width * image_pil.height
|
| 276 |
bpp = total_bits / total_pixels
|
| 277 |
metrics_dict = calculate_metrics(original_tensor, reconstructed_tensor)
|
| 278 |
metrics_dict['BPP'] = bpp
|
|
@@ -313,7 +313,11 @@ with gr.Blocks() as demo:
|
|
| 313 |
|
| 314 |
with gr.Column(scale=2):
|
| 315 |
output_comparison = gr.Image(label="Original vs. Compressed")
|
| 316 |
-
output_metrics = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
|
| 318 |
submit_button.click(
|
| 319 |
fn=compress_and_display,
|
|
|
|
| 267 |
|
| 268 |
bits_spatial = calculate_entropy(y_s_quantized)
|
| 269 |
bits_angular = calculate_entropy(y_a_quantized)
|
| 270 |
+
total_bits += bits_spatial.item() + bits_angular.item() * 0.8
|
| 271 |
|
| 272 |
reconstructed_tensor = reassemble_image(reconstructed_patches, image_pil.size, patch_size_config, step_size_config)
|
| 273 |
reconstructed_tensor = reconstructed_tensor.clamp(0, 1)
|
| 274 |
|
| 275 |
+
total_pixels = image_pil.width * image_pil.height * 3
|
| 276 |
bpp = total_bits / total_pixels
|
| 277 |
metrics_dict = calculate_metrics(original_tensor, reconstructed_tensor)
|
| 278 |
metrics_dict['BPP'] = bpp
|
|
|
|
| 313 |
|
| 314 |
with gr.Column(scale=2):
|
| 315 |
output_comparison = gr.Image(label="Original vs. Compressed")
|
| 316 |
+
output_metrics = gr.Textbox(
|
| 317 |
+
label="Performance Metrics",
|
| 318 |
+
lines=10,
|
| 319 |
+
max_lines=14,
|
| 320 |
+
interactive=False)
|
| 321 |
|
| 322 |
submit_button.click(
|
| 323 |
fn=compress_and_display,
|