Spaces:
Build error
Build error
Update app.py
Browse files4 unmodified lines567898910111213141516171718191819202122232425269 unmodified lines36373839353637404142434445464748494 unmodified linesimport seaborn as snsimport cv2import torchfrom transformers import AutoTokenizer, AutoModelForImageClassificationfrom huggingface_hub import hf_hub_downloadfrom huggingface_hub import hf_hub_download, loginfrom PIL import Imageimport pickle
# Cargar datasetdataset_repo = "VicGerardoPR/Traffic_sign_dataset"dataset_file = "train.p"
try:dataset_path = hf_hub_download(repo_id=dataset_repo, filename=dataset_file)with open(dataset_path, 'rb') as file: train_data = pickle.load(file) dataset_path = hf_hub_download(repo_id=dataset_repo, filename=dataset_file, repo_type="dataset") with open(dataset_path, 'rb') as file: train_data = pickle.load(file)except Exception as e: st.error(f"Error al cargar el dataset: {e}") st.stop()
train_images, train_labels = train_data['features'], train_data['labels']
9 unmodified linesmodel_repo = "VicGerardoPR/Traffic_sign_model"model_file = "traffic_sign_classifier.h5"
try:model_path = hf_hub_download(repo_id=model_repo, filename=model_file)model = torch.load(model_path, map_location=torch.device('cpu'))model.eval() model_path = hf_hub_download(repo_id=model_repo, filename=model_file, repo_type="model") model = torch.load(model_path, map_location=torch.device('cpu')) model.eval()except Exception as e: st.error(f"Error al cargar el modelo: {e}") st.stop()
# Diccionario de clases de señales de tráficoclasses = {app.py+17-8