Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -9,15 +9,19 @@ model = AutoModel.from_pretrained('jinaai/jina-clip-v1', trust_remote_code=True) | |
| 9 | 
             
            def compute_similarity(input1_type, input1_text, input1_image, input2_type, input2_text, input2_image):
         | 
| 10 | 
             
                """Computes similarity for Text-Text, Image-Image, or Text-Image comparisons."""
         | 
| 11 |  | 
|  | |
|  | |
|  | |
|  | |
| 12 | 
             
                # Handle empty inputs properly
         | 
| 13 | 
             
                if input1_type == "Text" and not input1_text.strip():
         | 
| 14 | 
             
                    return "Error: Input 1 (Text) is empty!"
         | 
| 15 | 
            -
                if input1_type == "Image" and  | 
| 16 | 
             
                    return "Error: Please upload a valid image for Input 1!"
         | 
| 17 |  | 
| 18 | 
             
                if input2_type == "Text" and not input2_text.strip():
         | 
| 19 | 
             
                    return "Error: Input 2 (Text) is empty!"
         | 
| 20 | 
            -
                if input2_type == "Image" and  | 
| 21 | 
             
                    return "Error: Please upload a valid image for Input 2!"
         | 
| 22 |  | 
| 23 | 
             
                try:
         | 
|  | |
| 9 | 
             
            def compute_similarity(input1_type, input1_text, input1_image, input2_type, input2_text, input2_image):
         | 
| 10 | 
             
                """Computes similarity for Text-Text, Image-Image, or Text-Image comparisons."""
         | 
| 11 |  | 
| 12 | 
            +
                # Ensure images are valid (Gradio may pass `False` instead of `None`)
         | 
| 13 | 
            +
                input1_image = None if isinstance(input1_image, bool) else input1_image
         | 
| 14 | 
            +
                input2_image = None if isinstance(input2_image, bool) else input2_image
         | 
| 15 | 
            +
             | 
| 16 | 
             
                # Handle empty inputs properly
         | 
| 17 | 
             
                if input1_type == "Text" and not input1_text.strip():
         | 
| 18 | 
             
                    return "Error: Input 1 (Text) is empty!"
         | 
| 19 | 
            +
                if input1_type == "Image" and input1_image is None:
         | 
| 20 | 
             
                    return "Error: Please upload a valid image for Input 1!"
         | 
| 21 |  | 
| 22 | 
             
                if input2_type == "Text" and not input2_text.strip():
         | 
| 23 | 
             
                    return "Error: Input 2 (Text) is empty!"
         | 
| 24 | 
            +
                if input2_type == "Image" and input2_image is None:
         | 
| 25 | 
             
                    return "Error: Please upload a valid image for Input 2!"
         | 
| 26 |  | 
| 27 | 
             
                try:
         |