| import gradio as gr |
| from transformers import AutoFeatureExtractor, AutoModelForImageClassification |
| from PIL import Image |
|
|
| |
| extractor = AutoFeatureExtractor.from_pretrained("dima806/skin_types_image_detection") |
| model = AutoModelForImageClassification.from_pretrained("dima806/skin_types_image_detection") |
|
|
| def detectar_piel(image): |
| inputs = extractor(images=image, return_tensors="pt") |
| outputs = model(**inputs) |
| logits = outputs.logits |
| predicted_class_idx = logits.argmax(-1).item() |
| |
| class_label = model.config.id2label[predicted_class_idx] |
| return class_label |
|
|
| iface = gr.Interface( |
| fn=detectar_piel, |
| inputs=gr.Image(type="pil"), |
| outputs=gr.Textbox(), |
| title="Detección tipo de piel", |
| description="Sube una imagen (rostro/zona de piel) y el modelo intentará clasificar el tipo de piel" |
| ) |
|
|
| iface.launch() |
|
|