Update README.md
Browse files
README.md
CHANGED
@@ -64,11 +64,12 @@ image = Image.open("image_path.jpg").convert("RGB")
|
|
64 |
|
65 |
# Preprocess and predict
|
66 |
def IQA_preprocess():
|
|
|
67 |
transform = transforms.Compose([
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
std=(0.26862954, 0.26130258, 0.27577711))
|
73 |
])
|
74 |
return transform
|
@@ -78,4 +79,13 @@ image = IQA_preprocess()(image).unsqueeze(0).to(device)
|
|
78 |
with torch.no_grad():
|
79 |
iqa_score = model(image).item()
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
print(f"Predicted quality Score: {iqa_score:.4f}")
|
|
|
64 |
|
65 |
# Preprocess and predict
|
66 |
def IQA_preprocess():
|
67 |
+
random.seed(3407)
|
68 |
transform = transforms.Compose([
|
69 |
+
transforms.Resize((512,384)),
|
70 |
+
transforms.RandomCrop(size=(224,224)),
|
71 |
+
transforms.ToTensor(),
|
72 |
+
transforms.Normalize(mean=(0.48145466, 0.4578275, 0.40821073),
|
73 |
std=(0.26862954, 0.26130258, 0.27577711))
|
74 |
])
|
75 |
return transform
|
|
|
79 |
with torch.no_grad():
|
80 |
iqa_score = model(image).item()
|
81 |
|
82 |
+
# maps the predicted score from the model's range [min_pred, max_pred]
|
83 |
+
# to the actual range [min_score, max_score] using min-max scaling.
|
84 |
+
|
85 |
+
min_pred =
|
86 |
+
max_pred =
|
87 |
+
max_score =
|
88 |
+
min_score =
|
89 |
+
|
90 |
+
normalized_score = ((iqa_score - min_pred) / (max_pred - min_pred)) * (max_score - min_score) + min_score
|
91 |
print(f"Predicted quality Score: {iqa_score:.4f}")
|