Spaces:
Runtime error
Runtime error
Commit
·
97ae590
1
Parent(s):
f00cf0c
Iniciando space
Browse files- app.py +29 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import joblib
|
3 |
+
import cv2
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
def previsao(image):
|
7 |
+
# Carregando o modelo
|
8 |
+
modelo = joblib.load('CNN.pkl')
|
9 |
+
|
10 |
+
# tratando pixels da imagem
|
11 |
+
imagem = cv2.resize(image, (150,150))
|
12 |
+
img_rgb = cv2.cvtColor(imagem, cv2.COLOR_BGR2RGB)
|
13 |
+
img_rgb = img_rgb.astype('float32')
|
14 |
+
img_rgb /= 255.0
|
15 |
+
img_rgb = img_rgb.reshape(1, 150, 150, 3)
|
16 |
+
|
17 |
+
# Prevendo labels com a CNN
|
18 |
+
labels = ['cloudy', 'rain', 'shine', 'sunrise']
|
19 |
+
|
20 |
+
prev = modelo.predict(img_rgb)
|
21 |
+
|
22 |
+
return (labels[np.argmax(prev)])
|
23 |
+
|
24 |
+
|
25 |
+
demo = gr.Interface(fn=previsao,
|
26 |
+
inputs=gr.Image(),
|
27 |
+
outputs="label")
|
28 |
+
|
29 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
cv2
|
2 |
+
keras
|
3 |
+
tensorflow
|
4 |
+
joblib
|
5 |
+
numpy
|