Update app.py
Browse files
app.py
CHANGED
|
@@ -28,11 +28,15 @@ gpu_flag = torch.cuda.is_available()
|
|
| 28 |
ocr_reader = easyocr.Reader(["en"], gpu=gpu_flag)
|
| 29 |
|
| 30 |
# (Optional) Object detection using YOLOv5
|
| 31 |
-
use_yolo =
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# CPU cores for parallelism
|
| 38 |
cpu_cores = os.cpu_count() or 4
|
|
|
|
| 28 |
ocr_reader = easyocr.Reader(["en"], gpu=gpu_flag)
|
| 29 |
|
| 30 |
# (Optional) Object detection using YOLOv5
|
| 31 |
+
use_yolo = False
|
| 32 |
+
try:
|
| 33 |
+
yolo_model = torch.hub.load("ultralytics/yolov5", "yolov5s", pretrained=True)
|
| 34 |
+
if gpu_flag:
|
| 35 |
+
yolo_model.to("cuda")
|
| 36 |
+
except Exception as e:
|
| 37 |
+
print(f"Warning: YOLOv5 load failed ({e}); object detection disabled.")
|
| 38 |
+
use_yolo = False
|
| 39 |
+
yolo_model = None
|
| 40 |
|
| 41 |
# CPU cores for parallelism
|
| 42 |
cpu_cores = os.cpu_count() or 4
|