Spaces:
Runtime error
Runtime error
Upload models.py
Browse files
models.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tensorflow as tf
|
2 |
+
import numpy as np
|
3 |
+
import cv2
|
4 |
+
|
5 |
+
|
6 |
+
def outputs(y):
|
7 |
+
return {
|
8 |
+
"Achaemenid architecture": y[0],
|
9 |
+
"American craftsman style": y[1],
|
10 |
+
"American Foursquare architecture": y[2],
|
11 |
+
"Ancient Egyptian architecture": y[3],
|
12 |
+
"Art Deco architecture": y[4],
|
13 |
+
"Art Nouveau architecture": y[5],
|
14 |
+
"Baroque architecture": y[6],
|
15 |
+
"Bauhaus architecture": y[7],
|
16 |
+
"Beaux Arts architecture": y[8],
|
17 |
+
"Byzantine architecture": y[9],
|
18 |
+
"Chicago school_architecture": y[10],
|
19 |
+
"Colonial architecture": y[11],
|
20 |
+
"Deconstructivism": y[12],
|
21 |
+
"Edwardian architecture": y[13],
|
22 |
+
"Georgian architecture": y[14],
|
23 |
+
"Gothic architecture": y[15],
|
24 |
+
"Greek Revival architecture": y[16],
|
25 |
+
"International style": y[17],
|
26 |
+
"Novelty architecture": y[18],
|
27 |
+
"Palladian architecture": y[19],
|
28 |
+
"Postmodern architecture": y[20],
|
29 |
+
"Queen Anne architecture": y[21],
|
30 |
+
"Romanesque architecture": y[22],
|
31 |
+
"Russian Revival_architecture": y[23],
|
32 |
+
"Tudor Revival architecture": y[24],
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
def efficientnetv2b0_25_arch_styles_Classifier(image):
|
37 |
+
# file_path = f"./images/{file.filename}"
|
38 |
+
# with open(file_path, "wb") as f:
|
39 |
+
# f.write(file.file.read())
|
40 |
+
resized_image = cv2.resize(image, dsize=(
|
41 |
+
224, 224), interpolation=cv2.INTER_CUBIC)
|
42 |
+
img = tf.expand_dims(resized_image, 0)
|
43 |
+
efficientnetv2b0 = tf.keras.models.load_model(
|
44 |
+
"models\EfficientNetV2B0.h5")
|
45 |
+
|
46 |
+
y = efficientnetv2b0.predict(img).reshape(-1)
|
47 |
+
y = (np.round(y, 3)*100).tolist()
|
48 |
+
|
49 |
+
return outputs(y)
|