Downloads · 30 days
0
hadezbladez/tirecheck
tirecheck is a machine learning model from hadezbladez. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as cc-by-nc-sa-4.0.
1. this is raw pytorch model 2. what you need to import? i use these and i thought it will work but maybe...
Downloads · 30 days
0
Access
Public
Updated Jun 20, 2024
Repo size
26.7 MB
Likes
0
Public
Click a slice to open those files.
.pt26.7 MB · 100%
From the Hugging Face model README
import os
from skimage import io
from PIL import Image
import pandas as pd
import torch
from torch.utils.data import Dataset
import torch.nn as nn
import torch.optim as optim
import torchvision.transforms as transforms
import torchvision
from torch.utils.data import DataLoader
from transformers import TrainingArguments, Trainer
from transformers import DefaultDataCollator
class OneContentDataset(Dataset):
def __init__(self, imagefilepath, transform):
self.imagefilepath = imagefilepath
self.transform = transform
def __len__(self): return 1
def __getitem__(self, index):
image = io.imread(self.imagefilepath)
y_label = 0
if self.transform : image = self.transform(image)
return (image, y_label)
def predictModelData (imagefilepath, model):
dataset = OneContentDataset(imagefilepath, transform=transform_formodel)
predict_loader = DataLoader(dataset=dataset, batch_size=batch_size, shuffle=False)
for x, y in predict_loader :
scores = model(x)
_, predictions = scores.max(1)
print(f"x shape:{x.shape} | prediction = {predictions[0]}")
labelpoint = predictions[0].tolist()
return labeldata[labelpoint]
break
modeltest = torch.load('./tirecheck.pt')
modeltest.eval()
predictModelData('./yourtire.jpg',modeltest)