Spaces:
Runtime error
Runtime error
cmosquerat
commited on
Commit
•
b13e8d8
1
Parent(s):
ec80702
Upload folder using huggingface_hub
Browse files- .gitignore +8 -0
- README.md +20 -7
- __pycache__/app.cpython-38.pyc +0 -0
- app.py +80 -0
- best.pt +3 -0
- bus.jpg +0 -0
- launch.py +34 -0
- nohup.out +0 -0
- requirements.txt +2 -0
- runs/.gitignore +0 -0
- webui.bat +6 -0
- webui.sh +5 -0
- yolov8l.pt +3 -0
- yolov8n-cls.pt +3 -0
- yolov8n-pose.pt +3 -0
- yolov8n-seg.pt +3 -0
.gitignore
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
yolov8l.pt
|
2 |
+
yolov8n-cls.pt
|
3 |
+
yolov8n-pose.pt
|
4 |
+
yolov8n-seg.pt
|
5 |
+
|
6 |
+
_pychache_
|
7 |
+
|
8 |
+
.venv/
|
README.md
CHANGED
@@ -1,12 +1,25 @@
|
|
1 |
---
|
2 |
-
title: YOLOv8
|
3 |
-
|
4 |
-
colorFrom: gray
|
5 |
-
colorTo: blue
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.35.2
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
|
|
1 |
---
|
2 |
+
title: YOLOv8-WebUI
|
3 |
+
app_file: app.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
sdk_version: 3.35.2
|
|
|
|
|
6 |
---
|
7 |
+
<h1 align="center">YOLOv8-WebUI</h1>
|
8 |
+
<div align="center">
|
9 |
+
|
10 |
+
Web browser UI for [YOLOv8](https://github.com/ultralytics/ultralytics)
|
11 |
+
|
12 |
+
</div>
|
13 |
+
|
14 |
+
|
15 |
+
# Launch
|
16 |
+
|
17 |
+
## Windows
|
18 |
+
1.Clone this repository.
|
19 |
+
|
20 |
+
2.Run `webui.bat`
|
21 |
+
|
22 |
+
## Linux or Mac
|
23 |
+
1.Clone this repository.
|
24 |
|
25 |
+
2.Run `webui.sh`
|
__pycache__/app.cpython-38.pyc
ADDED
Binary file (1.54 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from ultralytics import YOLO
|
3 |
+
|
4 |
+
#各モデルをロード
|
5 |
+
detect_model = YOLO("best.pt")
|
6 |
+
seg_model = YOLO('yolov8n-seg.pt')
|
7 |
+
cls_model = YOLO('yolov8n-cls.pt')
|
8 |
+
pose_model = YOLO("yolov8n-pose.pt")
|
9 |
+
|
10 |
+
#オプションリストをオブジェクトに整形
|
11 |
+
def return_options(checkbox):
|
12 |
+
option = {}
|
13 |
+
|
14 |
+
#整形
|
15 |
+
for check in checkbox:
|
16 |
+
option[check] = True
|
17 |
+
|
18 |
+
return option
|
19 |
+
|
20 |
+
#結果を描画する
|
21 |
+
def plot(res):
|
22 |
+
plot = res[0].plot()
|
23 |
+
return plot
|
24 |
+
|
25 |
+
def inference(type,input,conf):
|
26 |
+
if(type == "Detección"):
|
27 |
+
model = detect_model
|
28 |
+
elif(type == "seg"):
|
29 |
+
model = seg_model
|
30 |
+
elif(type == "cls"):
|
31 |
+
model = cls_model
|
32 |
+
elif(type == "Pose"):
|
33 |
+
model = pose_model
|
34 |
+
|
35 |
+
cpu=True
|
36 |
+
if(cpu):
|
37 |
+
device = "cpu"
|
38 |
+
|
39 |
+
|
40 |
+
line_width = None
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
#物体検出を実行
|
45 |
+
res = model(input,conf=conf,iou=0.7,device="cpu",max_det=300,line_width=line_width)
|
46 |
+
|
47 |
+
#結果を描画
|
48 |
+
plotted = plot(res)
|
49 |
+
return plotted
|
50 |
+
|
51 |
+
with gr.Blocks() as app:
|
52 |
+
#ヘッダー
|
53 |
+
gr.Markdown("# Detección de comportamiento sospechoso")
|
54 |
+
|
55 |
+
#タブ
|
56 |
+
with gr.Tabs():
|
57 |
+
#inferenceタブ
|
58 |
+
with gr.TabItem("Inferencia"):
|
59 |
+
with gr.Row():
|
60 |
+
input = gr.Image()
|
61 |
+
output = gr.Image()
|
62 |
+
|
63 |
+
type = gr.Radio(["Detección", "Pose"], value="Detección", label="Tasks")
|
64 |
+
|
65 |
+
#オプション
|
66 |
+
conf = gr.Slider(minimum=0, maximum=1, value=0.25, step=0.01, interactive=True,label="conf")
|
67 |
+
#iou = gr.Slider(minimum=0, maximum=1, value=0.7, step=0.01, interactive=True,label="iou")
|
68 |
+
#checkbox = gr.CheckboxGroup(["half","show","save","save_txt","save_conf","save_crop","hide_labels","hide_conf","vid_stride","visualize","augment","agnostic_nms","retina_masks","boxes"], label="Options",value=["boxes"])
|
69 |
+
|
70 |
+
#device = gr.Number(value=0, label="device", interactive=True, precision=0)
|
71 |
+
#cpu = gr.Checkbox(label="cpu", interactive=True)
|
72 |
+
#max_det = gr.Number(value=300, label="max_det", interactive=True, precision=0)
|
73 |
+
#line_width = gr.Number(value=0, label="line_width", interactive=True, precision=0)
|
74 |
+
|
75 |
+
inference_button = gr.Button("Realizar Inferencia")
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
#inputから画像を取得してdetect関数を実行
|
80 |
+
inference_button.click(inference, inputs=[type,input,conf], outputs=output)
|
best.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:afe842072018b6485ef8e0bc1df7a2d9f95e61e17825a79f90c7cc73b4155503
|
3 |
+
size 22538616
|
bus.jpg
ADDED
launch.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import importlib.util
|
2 |
+
import pip
|
3 |
+
import app
|
4 |
+
import sys
|
5 |
+
|
6 |
+
#パッケージがインストールされているかの確認
|
7 |
+
def is_installed(package):
|
8 |
+
try:
|
9 |
+
spec = importlib.util.find_spec(package)
|
10 |
+
except ModuleNotFoundError:
|
11 |
+
return False
|
12 |
+
|
13 |
+
return spec is not None
|
14 |
+
|
15 |
+
def start():
|
16 |
+
print(f"Python {sys.version}")
|
17 |
+
|
18 |
+
print("###################################################################")
|
19 |
+
|
20 |
+
#パッケージがインストールされていなければパッケージをインストールする
|
21 |
+
if not (is_installed("gradio")):
|
22 |
+
|
23 |
+
print("Installing gradio")
|
24 |
+
pip.main(['install','gradio'])
|
25 |
+
|
26 |
+
if not (is_installed("ultralytics")):
|
27 |
+
|
28 |
+
print("Installing ultralytics")
|
29 |
+
pip.main(['install','ultralytics'])
|
30 |
+
|
31 |
+
#appを起動
|
32 |
+
app.app.launch(share=True)
|
33 |
+
|
34 |
+
start()
|
nohup.out
ADDED
File without changes
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
ultralytics
|
runs/.gitignore
ADDED
File without changes
|
webui.bat
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@echo off
|
2 |
+
cd /d %~dp0
|
3 |
+
|
4 |
+
echo Launching app...
|
5 |
+
|
6 |
+
python launch.py
|
webui.sh
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!bin/bash
|
2 |
+
|
3 |
+
echo Launching app...
|
4 |
+
|
5 |
+
python launch.py
|
yolov8l.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:18218ea4798da042d9862e6029ca9531adbd40ace19b6c9a75e2e28f1adf30cc
|
3 |
+
size 87769683
|
yolov8n-cls.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f5079cd980628313a2e62cd09d358e5c8debf0d8f75b6e8be7973d94e3a5da9f
|
3 |
+
size 5533216
|
yolov8n-pose.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e3c2db6df38dbc31836154f7b7b70af317fecb43f4ab00f2127590825e0f1ad8
|
3 |
+
size 6807462
|
yolov8n-seg.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d39e867b2c3a5dbc1aa764411544b475cb14727bf6af1ec46c238f8bb1351ab9
|
3 |
+
size 7054355
|