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