hippoiam10 commited on
Commit
64d7e8d
·
verified ·
1 Parent(s): 91ee3d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -7,8 +7,13 @@ from PIL import Image, ImageDraw
7
  import numpy as np
8
  from sklearn.metrics import precision_recall_fscore_support
9
 
10
- # 載入 YOLOv8 模型
11
- yolo_model = YOLO("yolov8n.pt", map_location="cpu")
 
 
 
 
 
12
 
13
  # 載入 Faster R-CNN 模型
14
  faster_rcnn_model = torchvision.models.detection.fasterrcnn_resnet50_fpn(weights="COCO_V1")
 
7
  import numpy as np
8
  from sklearn.metrics import precision_recall_fscore_support
9
 
10
+ model_path = "yolov8n.pt"
11
+
12
+ try:
13
+ torch.load(model_path, map_location="cpu")
14
+ yolo_model = YOLO(model_path)
15
+ except Exception as e:
16
+ print(f"模型載入錯誤: {e}")
17
 
18
  # 載入 Faster R-CNN 模型
19
  faster_rcnn_model = torchvision.models.detection.fasterrcnn_resnet50_fpn(weights="COCO_V1")