Adicionando arquivos
Browse files- .gitattributes +1 -0
- app.py +42 -0
- category_encoder.pkl +3 -0
- color_encoder.pkl +3 -0
- requirements.txt +11 -0
- trained_model.keras +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
trained_model.keras filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
from tensorflow.keras.models import load_model
|
4 |
+
from huggingface_hub import hf_hub_download
|
5 |
+
import pickle
|
6 |
+
from PIL import Image
|
7 |
+
|
8 |
+
# Baixar os arquivos
|
9 |
+
repo_id = "davebraga/wrdbTI6"
|
10 |
+
model_path = hf_hub_download(repo_id, "trained_model.keras")
|
11 |
+
category_encoder_path = hf_hub_download(repo_id, "category_encoder.pkl")
|
12 |
+
color_encoder_path = hf_hub_download(repo_id, "color_encoder.pkl")
|
13 |
+
|
14 |
+
# Carregar modelo e encoders
|
15 |
+
model = load_model(model_path)
|
16 |
+
with open(category_encoder_path, "rb") as f:
|
17 |
+
category_encoder = pickle.load(f)
|
18 |
+
with open(color_encoder_path, "rb") as f:
|
19 |
+
color_encoder = pickle.load(f)
|
20 |
+
|
21 |
+
# Previsão
|
22 |
+
def predict(image):
|
23 |
+
image = image.resize((160, 160))
|
24 |
+
image_array = np.array(image) / 255.0
|
25 |
+
image_array = np.expand_dims(image_array, axis=0)
|
26 |
+
|
27 |
+
category_pred, color_pred = model.predict(image_array)
|
28 |
+
category = category_encoder.inverse_transform([np.argmax(category_pred)])[0]
|
29 |
+
color = color_encoder.inverse_transform([np.argmax(color_pred)])[0]
|
30 |
+
|
31 |
+
return f"Categoria: {category}", f"Cor: {color}"
|
32 |
+
|
33 |
+
# Interface
|
34 |
+
iface = gr.Interface(
|
35 |
+
fn=predict,
|
36 |
+
inputs=gr.Image(type="pil"),
|
37 |
+
outputs=["text", "text"],
|
38 |
+
title="Classificador de Categoria e Cor",
|
39 |
+
description="Faça upload de uma imagem de uma peça de roupa para prever a categoria e a cor."
|
40 |
+
)
|
41 |
+
|
42 |
+
iface.launch()
|
category_encoder.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2f99e3adb1f6ef591417646730181cb5170c89248e0eb9094dbbd5958dd292d3
|
3 |
+
size 1280
|
color_encoder.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b4432d811f63ada3387ab0891bc83982524c5b82cd69ea9b512fc3ce1fac3fd7
|
3 |
+
size 639
|
requirements.txt
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
pandas
|
2 |
+
numpy
|
3 |
+
matplotlib
|
4 |
+
seaborn
|
5 |
+
tensorflow==2.14.0
|
6 |
+
opencv-python
|
7 |
+
scikit-learn
|
8 |
+
fastapi
|
9 |
+
uvicorn
|
10 |
+
python-multipart
|
11 |
+
opencv-python
|
trained_model.keras
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:276bdb759587874e7b36d8307ba3d9c7e01d2744e321e6c69f26cace4ff22cc7
|
3 |
+
size 51228499
|