theArijitDas commited on
Commit
d29ec33
1 Parent(s): faf09ce

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from product_update_validator import Update_Validator
2
+ import gradio as gr
3
+
4
+ update_validator = Update_Validator(text_model="DistilRoBERTa-v1", image_model="CLIP-ViT Base", threshold=0.75)
5
+
6
+ def gradio_interface(text1, image1, text2, image2, threshold=0.75):
7
+ out = update_validator.validate(text1=text1, image1=image1, text2=text2, image2=image2, threshold=threshold, return_score=True)
8
+ return out['score'], label['label']
9
+
10
+ inputs = [
11
+ gr.inputs.Textbox(lines=5, label="Description 1"),
12
+ gr.inputs.Image(label="Image 1"),
13
+ gr.inputs.Textbox(lines=5, label="Description 2"),
14
+ gr.inputs.Image(label="Image 2"),
15
+ gr.inputs.Slider(minimum=0, maximum=1, default=0.75, step=0.01, label="Similarity Threshold")
16
+ ]
17
+
18
+ outputs = [
19
+ gr.outputs.Textbox(label="Similarity Score"),
20
+ gr.outputs.Textbox(label="Update Label")
21
+ ]
22
+
23
+ iface = gr.Interface(fn=gradio_interface, inputs=inputs, outputs=outputs, title="Product Update Validator")
24
+ iface.launch()