From c254f356bf11b6ad836606563f066cb4420217c5 Mon Sep 17 00:00:00 2001 From: Kshitij Date: Sat, 22 Feb 2025 22:41:43 +0530 Subject: [PATCH] test2, i.e. vishnu is the chosen model. Shall be using that going forward. Perfectly working right now. Will be attempting to locally reference it now. --- models/test2.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/models/test2.py b/models/test2.py index 53f04d1..d36e521 100644 --- a/models/test2.py +++ b/models/test2.py @@ -1,3 +1,4 @@ +# Import libraries from PIL import Image, UnidentifiedImageError from transformers import ViTImageProcessor, ViTForImageClassification @@ -9,11 +10,11 @@ model = ViTForImageClassification.from_pretrained( ignore_mismatched_sizes=True ) -# Load your image +# Load image try: - image = Image.open('/home/overnion/Status200/potato.png') # Replace with the actual path to your image + image = Image.open('/home/overnion/Status200/tomato.png') # Convert the image to RGB if it's not already - if image.mode != 'RGB': + if (image.mode != 'RGB'): image = image.convert('RGB') except FileNotFoundError: print("Error: Image file not found.") @@ -25,7 +26,7 @@ except Exception as e: print(f"An error occurred: {e}") exit() -# Prepare the image for the model +# Preparing the image for the model inputs = image_processor(images=image, return_tensors="pt") # Make the prediction