Spaces:
Build error
Build error
Update app.py
Browse files4 unmodified lines567889101137 unmodified lines495051525352535455565857585946 unmodified lines1061071081111121091141151161101111121131144 unmodified linesimport matplotlib.pyplot as pltimport seaborn as snsimport cv2import torchimport tensorflow as tffrom huggingface_hub import hf_hub_downloadfrom PIL import Imageimport pickle37 unmodified lines
try: 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() model = tf.keras.models.load_model(model_path)except Exception as e: st.error(f"Error al cargar el modelo: {e}") st.stop()
# Diccionario de clases de se帽ales de tr谩ficoclasses = { 0: 'Speed limit (20km/h)',46 unmodified lines image = cv2.resize(image, (32, 32)) image = image / 255.0 image = np.expand_dims(image, axis=0) image = np.transpose(image, (0, 3, 1, 2)) # Reordenar dimensiones para PyTorch image = torch.tensor(image).float()
with torch.no_grad(): predictions = model(image) class_idx = predictions.argmax().item() predictions = model.predict(image) class_idx = np.argmax(predictions, axis=1)[0] return classes[class_idx]
# T铆tulo y descripci贸n de la aplicaci贸napp.py+4-9