Spaces:
Build error
Build error
Update product_update_validator.py
Browse files
product_update_validator.py
CHANGED
|
@@ -2,14 +2,14 @@ from description_validator import Description_Validator
|
|
| 2 |
from image_validator import Image_Validator
|
| 3 |
|
| 4 |
class Update_Validator:
|
| 5 |
-
def __init__(self, text_model=None, image_model=None, threshold=0.
|
| 6 |
self.description_validator = Description_Validator(model_name=text_model)
|
| 7 |
self.image_validator = Image_Validator(model_name=image_model)
|
| 8 |
self.threshold = threshold
|
| 9 |
|
| 10 |
def validate(self, text1, image1, text2, image2, threshold=None, return_score=False):
|
| 11 |
description_similarity = self.description_validator.similarity_score(text1, text2)
|
| 12 |
-
image_similarity = self.image_validator.similarity_score(
|
| 13 |
similarity_score = 0.75 * description_similarity + 0.25 * image_similarity
|
| 14 |
|
| 15 |
if threshold is None: threshold=self.threshold
|
|
|
|
| 2 |
from image_validator import Image_Validator
|
| 3 |
|
| 4 |
class Update_Validator:
|
| 5 |
+
def __init__(self, text_model=None, image_model=None, threshold=0.75):
|
| 6 |
self.description_validator = Description_Validator(model_name=text_model)
|
| 7 |
self.image_validator = Image_Validator(model_name=image_model)
|
| 8 |
self.threshold = threshold
|
| 9 |
|
| 10 |
def validate(self, text1, image1, text2, image2, threshold=None, return_score=False):
|
| 11 |
description_similarity = self.description_validator.similarity_score(text1, text2)
|
| 12 |
+
image_similarity = self.image_validator.similarity_score(image1, image2)
|
| 13 |
similarity_score = 0.75 * description_similarity + 0.25 * image_similarity
|
| 14 |
|
| 15 |
if threshold is None: threshold=self.threshold
|