Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,23 +2,14 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
from PIL import Image
|
4 |
|
5 |
-
# Załaduj
|
6 |
skin_model = pipeline("image-classification", model="Anwarkh1/Skin_Cancer-Image_Classification")
|
7 |
-
image_check_model = pipeline("image-classification", model="google/vit-base-patch16-224")
|
8 |
|
9 |
def analyze_skin(image):
|
10 |
if image is None:
|
11 |
return "❌ Proszę wgrać zdjęcie", None
|
12 |
|
13 |
-
#
|
14 |
-
labels = image_check_model(image)
|
15 |
-
top_label = labels[0]["label"].lower()
|
16 |
-
is_skin = any(kw in top_label for kw in ["skin", "arm", "hand", "person", "human", "neck", "face"])
|
17 |
-
|
18 |
-
if not is_skin:
|
19 |
-
return "❌ To zdjęcie nie wygląda na fragment ludzkiej skóry. Proces zakończony.", None
|
20 |
-
|
21 |
-
# Analizuj zmianę skórną
|
22 |
result = skin_model(image)
|
23 |
|
24 |
# Formatuj wynik
|
@@ -37,7 +28,7 @@ demo = gr.Interface(
|
|
37 |
gr.Image(label="Przesłane zdjęcie")
|
38 |
],
|
39 |
title="🧴 Klasyfikator zmian skórnych (melanoma etc.)",
|
40 |
-
description="Wgraj zdjęcie zmiany skórnej, a aplikacja
|
41 |
theme="soft",
|
42 |
allow_flagging="never"
|
43 |
)
|
|
|
2 |
from transformers import pipeline
|
3 |
from PIL import Image
|
4 |
|
5 |
+
# Załaduj model klasyfikacji zmian skórnych
|
6 |
skin_model = pipeline("image-classification", model="Anwarkh1/Skin_Cancer-Image_Classification")
|
|
|
7 |
|
8 |
def analyze_skin(image):
|
9 |
if image is None:
|
10 |
return "❌ Proszę wgrać zdjęcie", None
|
11 |
|
12 |
+
# Bezpośrednia analiza zmiany skórnej
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
result = skin_model(image)
|
14 |
|
15 |
# Formatuj wynik
|
|
|
28 |
gr.Image(label="Przesłane zdjęcie")
|
29 |
],
|
30 |
title="🧴 Klasyfikator zmian skórnych (melanoma etc.)",
|
31 |
+
description="Wgraj zdjęcie zmiany skórnej, a aplikacja przeanalizuje rodzaj zmiany. Upewnij się, że zdjęcie przedstawia fragment ludzkiej skóry.",
|
32 |
theme="soft",
|
33 |
allow_flagging="never"
|
34 |
)
|