File size: 833 Bytes
d29ec33
 
 
 
 
 
 
ef01d24
d29ec33
 
ef01d24
 
 
 
 
d29ec33
 
 
3aca399
fe24b73
ef01d24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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")
]