Spaces:
Runtime error
Runtime error
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( | |
"EfficientNetV2B0.h5") | |
y = efficientnetv2b0.predict(img).reshape(-1) | |
y = (np.round(y, 3)*100).tolist() | |
return outputs(y) | |