Spaces:
Sleeping
Sleeping
Binssin commited on
Commit ·
ea2b490
1
Parent(s): 59f0897
Add application files
Browse files
README.md
CHANGED
|
@@ -1,13 +1,26 @@
|
|
| 1 |
---
|
| 2 |
title: TileDetect
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
-
short_description: A app with yolov9 for detecting the tiles which have fallen
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: TileDetect
|
| 3 |
+
emoji: 🏗️
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: yellow
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.19.2
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# 磁磚檢測系統
|
| 13 |
+
|
| 14 |
+
這是一個使用 YOLO 模型進行磁磚檢測的系統。上傳圖片後,系統會自動檢測圖片中的磁磚並標記出來。
|
| 15 |
+
|
| 16 |
+
## 使用方法
|
| 17 |
+
|
| 18 |
+
1. 上傳圖片
|
| 19 |
+
2. 點擊「開始檢測」按鈕
|
| 20 |
+
3. 查看檢測結果
|
| 21 |
+
|
| 22 |
+
## 技術細節
|
| 23 |
+
|
| 24 |
+
- 使用 Ultralytics YOLO 模型進行檢測
|
| 25 |
+
- 基於 Gradio 的網頁介面
|
| 26 |
+
- 支援各種圖片格式
|
app.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import numpy as np
|
| 4 |
+
from ultralytics import YOLO
|
| 5 |
+
|
| 6 |
+
# 載入模型
|
| 7 |
+
model = YOLO('last.pt') # 使用您的模型
|
| 8 |
+
|
| 9 |
+
def process_image(input_image):
|
| 10 |
+
# 將輸入圖片轉換為 numpy array
|
| 11 |
+
if isinstance(input_image, np.ndarray):
|
| 12 |
+
image = input_image
|
| 13 |
+
else:
|
| 14 |
+
image = np.array(input_image)
|
| 15 |
+
|
| 16 |
+
# 使用模型進行預測
|
| 17 |
+
results = model.predict(image)
|
| 18 |
+
|
| 19 |
+
# 獲取預測結果
|
| 20 |
+
result = results[0]
|
| 21 |
+
|
| 22 |
+
# 直接獲取繪製好的結果圖片
|
| 23 |
+
result_image = result.plot()
|
| 24 |
+
result_pil = Image.fromarray(result_image)
|
| 25 |
+
|
| 26 |
+
return result_pil
|
| 27 |
+
|
| 28 |
+
# 創建 Gradio 介面
|
| 29 |
+
with gr.Blocks() as demo:
|
| 30 |
+
gr.Markdown("# 磁磚檢測系統")
|
| 31 |
+
|
| 32 |
+
with gr.Row():
|
| 33 |
+
input_image = gr.Image(label="上傳圖片")
|
| 34 |
+
output_image = gr.Image(label="檢測結果")
|
| 35 |
+
|
| 36 |
+
submit_btn = gr.Button("開始檢測")
|
| 37 |
+
|
| 38 |
+
# 設置事件處理
|
| 39 |
+
submit_btn.click(
|
| 40 |
+
fn=process_image,
|
| 41 |
+
inputs=input_image,
|
| 42 |
+
outputs=output_image
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
if __name__ == "__main__":
|
| 46 |
+
demo.launch()
|
last.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e3a8a7d54dea71b846953fcba355f04b4208e692a3e1b7b582db98c62477c621
|
| 3 |
+
size 5455059
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ultralytics
|
| 2 |
+
pillow
|
| 3 |
+
numpy
|