Plana-Archive commited on
Commit
db266ce
·
verified ·
1 Parent(s): 97cafbb

Upload ccip/app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. ccip/app.py +41 -0
ccip/app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ import gradio as gr
4
+
5
+ from ccip import _VALID_MODEL_NAMES, _DEFAULT_MODEL_NAMES, ccip_difference, ccip_default_threshold
6
+
7
+
8
+ def _compare(imagex, imagey, model_name):
9
+ threshold = ccip_default_threshold(model_name)
10
+ diff = ccip_difference(imagex, imagey)
11
+
12
+ return diff, 'Same' if diff <= threshold else 'Not Same'
13
+
14
+
15
+ if __name__ == '__main__':
16
+ with gr.Blocks() as demo:
17
+ with gr.Row():
18
+ with gr.Column():
19
+ with gr.Row():
20
+ with gr.Column():
21
+ gr_input_x = gr.Image(type='pil', label='Image X')
22
+ with gr.Column():
23
+ gr_input_y = gr.Image(type='pil', label='Image Y')
24
+ with gr.Row():
25
+ gr_model_name = gr.Dropdown(_VALID_MODEL_NAMES, value=_DEFAULT_MODEL_NAMES, label='Model')
26
+
27
+ gr_button = gr.Button(value='Compare', variant='primary')
28
+
29
+ with gr.Column():
30
+ with gr.Row():
31
+ gr_diff = gr.Number(value=0.0, label='Difference')
32
+ with gr.Row():
33
+ gr_prediction = gr.Text(value='', label='Prediction')
34
+
35
+ gr_button.click(
36
+ _compare,
37
+ inputs=[gr_input_x, gr_input_y, gr_model_name],
38
+ outputs=[gr_diff, gr_prediction],
39
+ )
40
+
41
+ demo.queue(os.cpu_count()).launch()