-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (29 loc) · 1.12 KB
/
app.py
File metadata and controls
38 lines (29 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import gradio as gr
from PIL import Image
from src.main import IMAGE_REF_PATH, epc_scorer
REFERENCE_IMAGE = Image.open(IMAGE_REF_PATH)
def epc_scorer_wrapper(test_img):
resp = epc_scorer.callback(None, test_img)
if resp:
return f"""
<p>
<span style="color: {"forestgreen" if resp[1] == "match" else "tomato"}; font-size: 50px;">{resp[1]}</span> <i>with
<span style="color: cyan; font-size: 25px;">{resp[2]}</span> confidence!</i>
</p>
"""
else:
return ""
with gr.Blocks() as demo:
gr.Markdown("# EPC? Or Not?")
with gr.Row():
gr.Image(value=REFERENCE_IMAGE, label="Reference Image", interactive=False)
user_input = gr.Image(
label="Upload Sample Image", sources=["upload"], type="pil"
)
text_output = gr.Markdown(label="Result")
gr.Markdown(
"### *Please wait a while after uploading your first image as the models might get loaded in the background*"
)
user_input.change(epc_scorer_wrapper, inputs=user_input, outputs=text_output)
if __name__ == "__main__":
demo.launch()