|
import os |
|
|
|
import gradio as gr |
|
from PIL import Image |
|
from imgutils.metrics import lpips_difference |
|
|
|
|
|
def _fn_diff(imagex: Image.Image, imagey: Image.Image): |
|
diff = lpips_difference(imagex, imagey) |
|
return diff |
|
|
|
|
|
if __name__ == '__main__': |
|
with gr.Blocks() as demo: |
|
with gr.Row(): |
|
with gr.Column(): |
|
with gr.Row(): |
|
gr_input_x = gr.Image(label='Image X', image_mode='RGB', type='pil') |
|
gr_input_y = gr.Image(label='Image Y', image_mode='RGB', type='pil') |
|
with gr.Row(): |
|
gr_submit = gr.Button(value='Get Diff', variant='primary') |
|
|
|
with gr.Column(): |
|
with gr.Row(): |
|
gr_diff = gr.Textbox(label='Difference') |
|
|
|
gr_submit.click( |
|
_fn_diff, |
|
inputs=[gr_input_x, gr_input_y], |
|
outputs=[gr_diff], |
|
) |
|
|
|
demo.queue(os.cpu_count()).launch() |
|
|