nagasurendra commited on
Commit
28bbe05
·
verified ·
1 Parent(s): b783290

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -1,17 +1,19 @@
 
1
  import os
2
  import gradio as gr
3
  import cv2
4
  import numpy as np
5
  from ultralytics import YOLO
6
  import tempfile
 
7
 
8
  # Set Ultralytics config path
9
  os.environ['YOLO_CONFIG_DIR'] = '/tmp/Ultralytics'
10
 
11
- # Custom function to load model with weights_only=False
12
  def load_model_with_trusted_weights(model_path):
13
- import torch
14
- with torch.serialization.safe_globals():
15
  return YOLO(model_path)
16
 
17
  # Load both YOLO models
 
1
+
2
  import os
3
  import gradio as gr
4
  import cv2
5
  import numpy as np
6
  from ultralytics import YOLO
7
  import tempfile
8
+ import torch
9
 
10
  # Set Ultralytics config path
11
  os.environ['YOLO_CONFIG_DIR'] = '/tmp/Ultralytics'
12
 
13
+ # Custom function to load model with trusted weights
14
  def load_model_with_trusted_weights(model_path):
15
+ import ultralytics.nn.tasks
16
+ with torch.serialization.safe_globals([ultralytics.nn.tasks.DetectionModel]):
17
  return YOLO(model_path)
18
 
19
  # Load both YOLO models