| | from PIL import Image |
| |
|
| | |
| | def resize_imagen(img, size=(224,224)): |
| | return img.resize(size) |
| |
|
| | |
| | def batch_preprocesar(imagenes, size=(224,224)): |
| | return [img.resize(size) for img in imagenes] |
| |
|
| | |
| | def cargar_modelo_ligero(): |
| | from transformers import pipeline |
| | |
| | modelo = pipeline("image-classification", model="google/vit-base-patch16-224") |
| | return modelo |
| |
|
| | |
| | _cache = {} |
| | def cache_resultado(key, funcion, *args, **kwargs): |
| | if key in _cache: |
| | return _cache[key] |
| | resultado = funcion(*args, **kwargs) |
| | _cache[key] = resultado |
| | return resultado |
| |
|