Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -224,10 +224,25 @@ def create_mask(image, x1, y1, x2, y2):
|
|
224 |
|
225 |
|
226 |
def special_process_image_yolo(risk_level, image_path, point1, point2, thresholds=None):
|
|
|
|
|
|
|
|
|
|
|
227 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
228 |
-
print(device)
|
229 |
-
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
model.to(device) # モデルをGPUに移動
|
232 |
|
233 |
|
|
|
224 |
|
225 |
|
226 |
def special_process_image_yolo(risk_level, image_path, point1, point2, thresholds=None):
|
227 |
+
import os
|
228 |
+
import torch
|
229 |
+
from ultralytics import YOLO
|
230 |
+
|
231 |
+
# デバイスの確認
|
232 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
233 |
+
print(f"Using device: {device}")
|
234 |
+
|
235 |
+
# モデルファイルのパス
|
236 |
+
model_path = './1026.pt'
|
237 |
+
|
238 |
+
# モデルファイルの存在確認
|
239 |
+
if not os.path.isfile(model_path):
|
240 |
+
raise FileNotFoundError(f"モデルファイル '{model_path}' が見つかりません。パスを確認してください。")
|
241 |
+
else:
|
242 |
+
# YOLOv8モデルをロードし、指定デバイスに移動
|
243 |
+
model = YOLO(model_path).to(device)
|
244 |
+
print("モデルが正常にロードされ、デバイスに移動しました。")
|
245 |
+
|
246 |
model.to(device) # モデルをGPUに移動
|
247 |
|
248 |
|