Spaces:
Runtime error
Runtime error
syurein
commited on
Commit
·
cfbf2cc
1
Parent(s):
d9afec2
easyocrの問題により、いったん消去
Browse files- app.py +3 -11
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -224,7 +224,6 @@ def create_mask(image, x1, y1, x2, y2):
|
|
| 224 |
cv2.rectangle(mask, (int(x1), int(y1)), (int(x2), int(y2)), 255, -1)
|
| 225 |
return mask
|
| 226 |
|
| 227 |
-
import easyocr
|
| 228 |
|
| 229 |
|
| 230 |
|
|
@@ -332,8 +331,7 @@ def special_process_image_yolo(risk_level, image_path, point1, point2, threshold
|
|
| 332 |
print("モデルが正常にロードされ、デバイスに移動しました。")
|
| 333 |
|
| 334 |
# OCRモデルの初期化
|
| 335 |
-
|
| 336 |
-
|
| 337 |
# タイムスタンプを作成
|
| 338 |
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
|
| 339 |
|
|
@@ -356,13 +354,7 @@ def special_process_image_yolo(risk_level, image_path, point1, point2, threshold
|
|
| 356 |
image = cv2.imread(image_path)
|
| 357 |
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 358 |
|
| 359 |
-
|
| 360 |
-
mask_ocr = np.zeros(image.shape[:2], dtype=np.uint8)
|
| 361 |
-
ocr_results = reader.readtext(image_rgb)
|
| 362 |
-
for (bbox, text, ocr_conf) in ocr_results:
|
| 363 |
-
x1, y1 = int(bbox[0][0]), int(bbox[0][1])
|
| 364 |
-
x2, y2 = int(bbox[2][0]), int(bbox[2][1])
|
| 365 |
-
mask_ocr[y1:y2, x1:x2] = 255 # テキスト領域をマスク
|
| 366 |
|
| 367 |
# YOLO推論実行
|
| 368 |
results = model(image_rgb)
|
|
@@ -381,7 +373,7 @@ def special_process_image_yolo(risk_level, image_path, point1, point2, threshold
|
|
| 381 |
mask_yolo = create_mask(image, x1, y1, x2, y2)
|
| 382 |
|
| 383 |
# OCRマスクとYOLOマスクの結合
|
| 384 |
-
final_mask =
|
| 385 |
|
| 386 |
# 絶対座標に変換した点の範囲を黒に設定
|
| 387 |
p1_x, p1_y = int(point1[0] * image.shape[1]), int(point1[1] * image.shape[0])
|
|
|
|
| 224 |
cv2.rectangle(mask, (int(x1), int(y1)), (int(x2), int(y2)), 255, -1)
|
| 225 |
return mask
|
| 226 |
|
|
|
|
| 227 |
|
| 228 |
|
| 229 |
|
|
|
|
| 331 |
print("モデルが正常にロードされ、デバイスに移動しました。")
|
| 332 |
|
| 333 |
# OCRモデルの初期化
|
| 334 |
+
|
|
|
|
| 335 |
# タイムスタンプを作成
|
| 336 |
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
|
| 337 |
|
|
|
|
| 354 |
image = cv2.imread(image_path)
|
| 355 |
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 356 |
|
| 357 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
|
| 359 |
# YOLO推論実行
|
| 360 |
results = model(image_rgb)
|
|
|
|
| 373 |
mask_yolo = create_mask(image, x1, y1, x2, y2)
|
| 374 |
|
| 375 |
# OCRマスクとYOLOマスクの結合
|
| 376 |
+
final_mask = mask_yolo
|
| 377 |
|
| 378 |
# 絶対座標に変換した点の範囲を黒に設定
|
| 379 |
p1_x, p1_y = int(point1[0] * image.shape[1]), int(point1[1] * image.shape[0])
|
requirements.txt
CHANGED
|
@@ -70,7 +70,7 @@ ultralytics-thop==2.0.10
|
|
| 70 |
urllib3==2.2.3
|
| 71 |
uvicorn==0.32.0
|
| 72 |
zipp==3.20.2
|
| 73 |
-
|
| 74 |
supervision # 重複を解消
|
| 75 |
onnxruntime
|
| 76 |
google-genai
|
|
|
|
| 70 |
urllib3==2.2.3
|
| 71 |
uvicorn==0.32.0
|
| 72 |
zipp==3.20.2
|
| 73 |
+
|
| 74 |
supervision # 重複を解消
|
| 75 |
onnxruntime
|
| 76 |
google-genai
|