Adicionando a variavel de token
Browse files
app.py
CHANGED
@@ -6,21 +6,25 @@ import pickle
|
|
6 |
from PIL import Image
|
7 |
import zipfile
|
8 |
import os
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Repositório no Hugging Face
|
11 |
repo_id = "davebraga/wrdbTI6"
|
12 |
|
13 |
-
# Baixar o modelo compactado
|
14 |
-
model_zip_path = hf_hub_download(repo_id, "saved_model.zip")
|
15 |
|
16 |
# Descompactar o modelo se ainda não existir
|
17 |
if not os.path.exists("saved_model"):
|
18 |
with zipfile.ZipFile(model_zip_path, 'r') as zip_ref:
|
19 |
zip_ref.extractall("saved_model")
|
20 |
|
21 |
-
# Baixar os encoders
|
22 |
-
category_encoder_path = hf_hub_download(repo_id, "category_encoder.pkl")
|
23 |
-
color_encoder_path = hf_hub_download(repo_id, "color_encoder.pkl")
|
24 |
|
25 |
# Carregar modelo e encoders
|
26 |
model = load_model("saved_model")
|
|
|
6 |
from PIL import Image
|
7 |
import zipfile
|
8 |
import os
|
9 |
+
import os as _os
|
10 |
+
|
11 |
+
# Pega o token do Hugging Face da variável de ambiente
|
12 |
+
hf_token = _os.getenv("HUGGINGFACE_HUB_TOKEN")
|
13 |
|
14 |
# Repositório no Hugging Face
|
15 |
repo_id = "davebraga/wrdbTI6"
|
16 |
|
17 |
+
# Baixar o modelo compactado com autenticação
|
18 |
+
model_zip_path = hf_hub_download(repo_id, "saved_model.zip", token=hf_token)
|
19 |
|
20 |
# Descompactar o modelo se ainda não existir
|
21 |
if not os.path.exists("saved_model"):
|
22 |
with zipfile.ZipFile(model_zip_path, 'r') as zip_ref:
|
23 |
zip_ref.extractall("saved_model")
|
24 |
|
25 |
+
# Baixar os encoders com autenticação
|
26 |
+
category_encoder_path = hf_hub_download(repo_id, "category_encoder.pkl", token=hf_token)
|
27 |
+
color_encoder_path = hf_hub_download(repo_id, "color_encoder.pkl", token=hf_token)
|
28 |
|
29 |
# Carregar modelo e encoders
|
30 |
model = load_model("saved_model")
|