shaquilledanil commited on
Commit
51829a6
·
verified ·
1 Parent(s): 768368a

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +59 -0
  2. best.pt +3 -0
  3. requirements.txt +151 -0
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import hf_hub_download
3
+ from ultralytics import YOLO
4
+ from PIL import Image
5
+
6
+ # Скачиваем веса из вашего репо на Hugging Face
7
+ REPO_ID = "shaquilledanil/yolo11-skinai"
8
+ FILENAME = "best.pt"
9
+ WEIGHT_PATH = hf_hub_download(repo_id=REPO_ID, filename=FILENAME)
10
+
11
+ # Загружаем YOLO-модель
12
+ model = YOLO(WEIGHT_PATH)
13
+
14
+ def yolo_inference(image: Image.Image):
15
+ """
16
+ Принимает PIL.Image, прогоняет через YOLO-модель,
17
+ возвращает кортеж (annotated_image, detections_info).
18
+ """
19
+ results = model.predict(source=image)
20
+
21
+ # Подготовим изображение с нарисованными bboxes
22
+ # Ultralytics в results[0].plot() вернёт PIL.Image с рамками
23
+ annotated_image = results[0].plot() if len(results) else image
24
+
25
+ # Соберём текстовую информацию о детекциях
26
+ detections = []
27
+ if len(results):
28
+ boxes = results[0].boxes
29
+ for box in boxes:
30
+ cls_id = int(box.cls[0].item())
31
+ conf = float(box.conf[0].item())
32
+ xyxy = box.xyxy[0].tolist()
33
+ class_name = results[0].names[cls_id]
34
+ detections.append({
35
+ "class_id": cls_id,
36
+ "class_name": class_name,
37
+ "confidence": round(conf, 3),
38
+ "bbox": [round(x, 1) for x in xyxy]
39
+ })
40
+
41
+ return annotated_image, detections
42
+
43
+ # Создаём Gradio-интерфейс:
44
+ # - inputs: одна картинка
45
+ # - outputs: (1) картинка с боксами, (2) JSON (список детекций)
46
+ demo = gr.Interface(
47
+ fn=yolo_inference,
48
+ inputs=gr.Image(type="pil"),
49
+ outputs=[
50
+ gr.Image(type="pil", label="Detected Objects"),
51
+ "json"
52
+ ],
53
+ title="YOLO SkinAI Demo",
54
+ description="Загрузите изображение, чтобы увидеть результат детекции"
55
+ )
56
+
57
+ # Запуск (при локальном тесте):
58
+ if __name__ == "__main__":
59
+ demo.launch()
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9fe1180af4d10f963eb6f41fa1f5df8eff4e2a5c9be1d03277fdc968b8716aec
3
+ size 3212411
requirements.txt ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ aiohttp==3.9.5
3
+ aiohttp-socks==0.8.4
4
+ aiosignal==1.3.1
5
+ annotated-types==0.7.0
6
+ anyio==4.8.0
7
+ asttokens==3.0.0
8
+ async-timeout==4.0.3
9
+ attrs==24.2.0
10
+ blinker==1.8.2
11
+ build==1.2.2.post1
12
+ CacheControl==0.14.0
13
+ certifi==2024.8.30
14
+ charset-normalizer==3.4.0
15
+ cleo==2.1.0
16
+ click==8.1.7
17
+ colorama==0.4.6
18
+ comm==0.2.2
19
+ contourpy==1.3.1
20
+ crashtest==0.4.1
21
+ cycler==0.12.1
22
+ Cython==3.0.11
23
+ debugpy==1.8.11
24
+ decorator==5.1.1
25
+ distlib==0.3.9
26
+ dtw-python==1.5.3
27
+ dulwich==0.21.7
28
+ executing==2.1.0
29
+ fake-useragent==1.5.1
30
+ Faker==27.0.0
31
+ fastapi==0.115.6
32
+ fastjsonschema==2.20.0
33
+ ffmpy==0.5.0
34
+ filelock==3.16.1
35
+ Flask==3.0.3
36
+ fonttools==4.55.3
37
+ frozenlist==1.4.1
38
+ fsspec==2024.10.0
39
+ gradio==5.10.0
40
+ gradio_client==1.5.3
41
+ h11==0.14.0
42
+ httpcore==1.0.7
43
+ httpx==0.28.1
44
+ huggingface-hub==0.27.1
45
+ idna==3.8
46
+ installer==0.7.0
47
+ ipykernel==6.29.5
48
+ ipython==8.30.0
49
+ itsdangerous==2.2.0
50
+ jaraco.classes==3.4.0
51
+ jedi==0.19.2
52
+ Jinja2==3.1.4
53
+ jupyter_client==8.6.3
54
+ jupyter_core==5.7.2
55
+ keyring==24.3.1
56
+ kiwisolver==1.4.7
57
+ llvmlite==0.43.0
58
+ loguru==0.7.2
59
+ markdown-it-py==3.0.0
60
+ MarkupSafe==2.1.5
61
+ matplotlib==3.10.0
62
+ matplotlib-inline==0.1.7
63
+ mdurl==0.1.2
64
+ more-itertools==10.5.0
65
+ mpmath==1.3.0
66
+ msgpack==1.1.0
67
+ multidict==6.0.5
68
+ nest-asyncio==1.6.0
69
+ networkx==3.4.2
70
+ numba==0.60.0
71
+ numpy==2.0.2
72
+ openai-whisper==20240930
73
+ opencv-python==4.10.0.84
74
+ orjson==3.10.13
75
+ packaging==24.1
76
+ pandas==2.2.2
77
+ parso==0.8.4
78
+ pexpect==4.9.0
79
+ Pillow==9.5.0
80
+ pkginfo==1.11.2
81
+ platformdirs==4.3.6
82
+ poetry==1.8.4
83
+ poetry-core==1.9.1
84
+ poetry-plugin-export==1.8.0
85
+ prompt_toolkit==3.0.48
86
+ psutil==6.1.0
87
+ ptyprocess==0.7.0
88
+ pure_eval==0.2.3
89
+ py-cpuinfo==9.0.0
90
+ pyaes==1.6.1
91
+ pydantic==2.10.4
92
+ pydantic_core==2.27.2
93
+ pydub==0.25.1
94
+ Pygments==2.18.0
95
+ pyparsing==3.2.0
96
+ pyproject_hooks==1.2.0
97
+ Pyrogram==2.0.106
98
+ PySocks==1.7.1
99
+ python-dateutil==2.9.0.post0
100
+ python-multipart==0.0.20
101
+ python-socks==2.5.1
102
+ pytz==2024.1
103
+ pywin32==308
104
+ pywin32-ctypes==0.2.3
105
+ PyYAML==6.0.2
106
+ pyzmq==26.2.0
107
+ RapidFuzz==3.10.0
108
+ regex==2024.9.11
109
+ requests==2.32.3
110
+ requests-toolbelt==1.0.0
111
+ rich==13.9.4
112
+ ruff==0.8.6
113
+ safehttpx==0.1.6
114
+ safetensors==0.4.5
115
+ scipy==1.14.1
116
+ seaborn==0.13.2
117
+ semantic-version==2.10.0
118
+ sentry-sdk==2.19.2
119
+ setuptools==75.3.0
120
+ shellingham==1.5.4
121
+ six==1.16.0
122
+ sniffio==1.3.1
123
+ stack-data==0.6.3
124
+ starlette==0.41.3
125
+ sympy==1.13.1
126
+ telegram==0.0.1
127
+ TgCrypto==1.2.5
128
+ thop==0.1.1.post2209072238
129
+ tiktoken==0.8.0
130
+ tokenizers==0.20.3
131
+ tomlkit==0.13.2
132
+ torch==2.5.1
133
+ torchvision==0.20.1
134
+ tornado==6.4.2
135
+ tqdm==4.66.6
136
+ traitlets==5.14.3
137
+ transformers==4.46.2
138
+ trove-classifiers==2024.10.16
139
+ typer==0.15.1
140
+ typing_extensions==4.12.2
141
+ tzdata==2024.1
142
+ ultralytics==8.3.57
143
+ ultralytics-thop==2.0.13
144
+ urllib3==2.2.3
145
+ uvicorn==0.22.0
146
+ virtualenv==20.27.0
147
+ wcwidth==0.2.13
148
+ websockets==14.1
149
+ Werkzeug==3.1.1
150
+ win32-setctime==1.1.0
151
+ yarl==1.10.0