Delete app.py
Browse files
app.py
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
import evaluate
|
2 |
-
import gradio as gr
|
3 |
-
from PIL import Image
|
4 |
-
|
5 |
-
module = evaluate.load("Bekhouche/PSNR")
|
6 |
-
|
7 |
-
def compute_psnr(prediction, reference):
|
8 |
-
try:
|
9 |
-
prediction = Image.fromarray(prediction)
|
10 |
-
reference = Image.fromarray(reference)
|
11 |
-
except Exception as e:
|
12 |
-
return f"Error loading images: {e}"
|
13 |
-
|
14 |
-
module.add_batch(predictions=[prediction], references=[reference])
|
15 |
-
result = module.compute()
|
16 |
-
return result
|
17 |
-
|
18 |
-
def custom_launch_gradio_widget(module):
|
19 |
-
metric_info = module._info()
|
20 |
-
|
21 |
-
with gr.Blocks() as demo:
|
22 |
-
gr.Markdown(f"### {metric_info.description}")
|
23 |
-
gr.Markdown(f"**Citation:** {metric_info.citation}")
|
24 |
-
gr.Markdown(f"**Inputs Description:** {metric_info.inputs_description}")
|
25 |
-
|
26 |
-
prediction_input = gr.Image(type="numpy", label="Upload Prediction Image")
|
27 |
-
reference_input = gr.Image(type="numpy", label="Upload Reference Image")
|
28 |
-
|
29 |
-
run_button = gr.Button("Run PSNR")
|
30 |
-
output = gr.Textbox(label="PSNR Score")
|
31 |
-
|
32 |
-
run_button.click(
|
33 |
-
compute_psnr,
|
34 |
-
inputs=[prediction_input, reference_input],
|
35 |
-
outputs=output,
|
36 |
-
)
|
37 |
-
|
38 |
-
demo.launch()
|
39 |
-
|
40 |
-
custom_launch_gradio_widget(module)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|