Spaces:
Runtime error
Runtime error
import gradio as gr | |
import joblib | |
import cv2 | |
import numpy as np | |
def previsao(image): | |
# Carregando o modelo | |
modelo = joblib.load('CNN.pkl') | |
# tratando pixels da imagem | |
imagem = cv2.resize(image, (150,150)) | |
img_rgb = cv2.cvtColor(imagem, cv2.COLOR_BGR2RGB) | |
img_rgb = img_rgb.astype('float32') | |
img_rgb /= 255.0 | |
img_rgb = img_rgb.reshape(1, 150, 150, 3) | |
# Prevendo labels com a CNN | |
labels = ['cloudy', 'rain', 'shine', 'sunrise'] | |
prev = modelo.predict(img_rgb) | |
return (labels[np.argmax(prev)]) | |
demo = gr.Interface(fn=previsao, | |
inputs=gr.Image(), | |
outputs="label") | |
demo.launch() | |