Download diffusers_empr.py from Apedlop/prueba: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/spaces/Apedlop/prueba/resolve/main/diffusers_empr.py
- Command line
-
hf download hf://spaces/Apedlop/prueba/diffusers_empr.py
-
curl -L -o diffusers_empr.py https://huggingface.co/spaces/Apedlop/prueba/resolve/main/diffusers_empr.py
1.8 kB
| import torch | |
| import gradio as gr | |
| from PIL import Image | |
| from diffusers import DiffusionPipeline | |
| from transformers import pipeline | |
| # Diffuser | |
| # diffuser = DiffusionPipeline.from_pretrained( | |
| # "bb1070/catvton-acne-4000-full", | |
| # torch_dtype=torch.float16 | |
| # ).to("cuda") | |
| # Clasificador de acné (GRADE REAL) | |
| classifier = pipeline( | |
| "image-classification", | |
| model="imfarzanansari/skintelligent-acne", | |
| device=0 | |
| ) | |
| GRADE_MAP = { | |
| "Clear Skin": 0, | |
| "Mild Acne": 1, | |
| "Moderate Acne": 2, | |
| "Severe Acne": 3 | |
| } | |
| # def analyze_skin(image, use_diffuser): | |
| # if image is None: | |
| # return None, "No image", "-", "-" | |
| # prompt = "face with acne, dermatology photo, neutral lighting" | |
| # image = diffuser(prompt, image=image).images[0] | |
| # # Clasificación | |
| # result = classifier(image) | |
| # top = result[0] | |
| # label = top["label"] | |
| # confidence = round(top["score"], 3) | |
| # grade = GRADE_MAP.get(label, "N/A") | |
| # return image, label, grade, confidence | |
| with gr.Blocks(title="Skin Acne AI") as demo: | |
| gr.Markdown("## Análisis de Acné con IA") | |
| gr.Markdown( | |
| "Sube una imagen de la piel. " | |
| "El sistema devuelve un **GRADE dermatológico no clínico**." | |
| ) | |
| with gr.Row(): | |
| with gr.Column(): | |
| input_image = gr.Image(type="pil", label="Imagen de la piel") | |
| btn = gr.Button("Analizar") | |
| with gr.Column(): | |
| output_image = gr.Image(label="Imagen procesada") | |
| label_out = gr.Textbox(label="Diagnóstico IA") | |
| grade_out = gr.Textbox(label="Grade (0–3)") | |
| conf_out = gr.Textbox(label="Confianza") | |
| btn.click( | |
| # analyze_skin, | |
| inputs=[input_image], | |
| outputs=[output_image, label_out, grade_out, conf_out] | |
| ) | |
| demo.launch() | |