Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -54,6 +54,18 @@ def normalized(a, axis=-1, order=2):
|
|
54 |
l2[l2 == 0] = 1
|
55 |
return a / np.expand_dims(l2, axis)
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
def predict(image):
|
58 |
model = MLP(768) # CLIP embedding dim is 768 for CLIP ViT L 14
|
59 |
pthpath = "https://huggingface.co/haor/aesthetics/resolve/main/sac%2Blogos%2Bava1-l14-linearMSE.pth"
|
@@ -84,7 +96,7 @@ def predict(image):
|
|
84 |
"sha1": sha1,
|
85 |
"laplacian_variance": laplacian_variance
|
86 |
}
|
87 |
-
return result
|
88 |
|
89 |
title = "CLIP Aesthetic Score"
|
90 |
description = "Upload an image to predict its aesthetic score using the CLIP model and calculate other image metrics."
|
|
|
54 |
l2[l2 == 0] = 1
|
55 |
return a / np.expand_dims(l2, axis)
|
56 |
|
57 |
+
def convert_numpy_types(data):
|
58 |
+
if isinstance(data, dict):
|
59 |
+
return {key: convert_numpy_types(value) for key, value in data.items()}
|
60 |
+
elif isinstance(data, list):
|
61 |
+
return [convert_numpy_types(item) for item in data]
|
62 |
+
elif isinstance(data, np.float64):
|
63 |
+
return float(data)
|
64 |
+
elif isinstance(data, np.int64):
|
65 |
+
return int(data)
|
66 |
+
else:
|
67 |
+
return data
|
68 |
+
|
69 |
def predict(image):
|
70 |
model = MLP(768) # CLIP embedding dim is 768 for CLIP ViT L 14
|
71 |
pthpath = "https://huggingface.co/haor/aesthetics/resolve/main/sac%2Blogos%2Bava1-l14-linearMSE.pth"
|
|
|
96 |
"sha1": sha1,
|
97 |
"laplacian_variance": laplacian_variance
|
98 |
}
|
99 |
+
return convert_numpy_types(result)
|
100 |
|
101 |
title = "CLIP Aesthetic Score"
|
102 |
description = "Upload an image to predict its aesthetic score using the CLIP model and calculate other image metrics."
|