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.
This commit is contained in:
+5
-4
@@ -1,3 +1,4 @@
|
|||||||
|
# Import libraries
|
||||||
from PIL import Image, UnidentifiedImageError
|
from PIL import Image, UnidentifiedImageError
|
||||||
from transformers import ViTImageProcessor, ViTForImageClassification
|
from transformers import ViTImageProcessor, ViTForImageClassification
|
||||||
|
|
||||||
@@ -9,11 +10,11 @@ model = ViTForImageClassification.from_pretrained(
|
|||||||
ignore_mismatched_sizes=True
|
ignore_mismatched_sizes=True
|
||||||
)
|
)
|
||||||
|
|
||||||
# Load your image
|
# Load image
|
||||||
try:
|
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
|
# Convert the image to RGB if it's not already
|
||||||
if image.mode != 'RGB':
|
if (image.mode != 'RGB'):
|
||||||
image = image.convert('RGB')
|
image = image.convert('RGB')
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print("Error: Image file not found.")
|
print("Error: Image file not found.")
|
||||||
@@ -25,7 +26,7 @@ except Exception as e:
|
|||||||
print(f"An error occurred: {e}")
|
print(f"An error occurred: {e}")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
# Prepare the image for the model
|
# Preparing the image for the model
|
||||||
inputs = image_processor(images=image, return_tensors="pt")
|
inputs = image_processor(images=image, return_tensors="pt")
|
||||||
|
|
||||||
# Make the prediction
|
# Make the prediction
|
||||||
|
|||||||
Reference in New Issue
Block a user