|
from product_update_validator import Update_Validator |
|
import gradio as gr |
|
|
|
update_validator = Update_Validator(text_model="DistilRoBERTa-v1", image_model="CLIP-ViT Base", threshold=0.75) |
|
|
|
def gradio_interface(text1, image1, text2, image2, threshold=0.75): |
|
out = update_validator.validate( |
|
text1=text1, |
|
image1=image1, |
|
text2=text2, |
|
image2=image2, |
|
threshold=threshold, |
|
return_score=True |
|
) |
|
return out['score'], "Valid" if out['label'] else "Invalid" |
|
|
|
inputs = [ |
|
gr.Textbox(lines=5, label="Description 1"), |
|
gr.Image(type="pil", label="Image 1"), |
|
gr.Textbox(lines=5, label="Description 2"), |
|
gr.Image(type="pil", label="Image 2"), |
|
gr.Slider(minimum=0, maximum=1, value=0.75, step=0.01, label="Similarity Threshold") |
|
] |
|
|
|
outputs = [ |
|
gr.Number(label="Similarity Score"), |
|
gr.Textbox(label="Update Label") |
|
] |
|
|
|
iface = gr.Interface( |
|
fn=gradio_interface, |
|
inputs=inputs, |
|
outputs=outputs, |
|
title="Product Update Validator" |
|
) |
|
|
|
iface.launch() |
|
|