muskangoyal06 commited on
Commit
95b31dc
·
verified ·
1 Parent(s): 4e9dcdb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -3,9 +3,10 @@ import torch
3
  from ultralytics.nn.tasks import DetectionModel
4
  from torch.nn.modules.container import Sequential
5
  from ultralytics.nn.modules import Conv
 
6
 
7
- # Whitelist safe globals (only do this if you trust the source of the model)
8
- torch.serialization.add_safe_globals([DetectionModel, Sequential, Conv])
9
 
10
  from ultralyticsplus import YOLO, render_result
11
  from PIL import Image
@@ -13,7 +14,7 @@ from PIL import Image
13
  # Load the YOLOv8s Leaf Detection and Classification model from Hugging Face
14
  model = YOLO('foduucom/plant-leaf-detection-and-classification')
15
 
16
- # Set recommended model parameters
17
  model.overrides['conf'] = 0.25 # NMS confidence threshold
18
  model.overrides['iou'] = 0.45 # NMS IoU threshold
19
  model.overrides['agnostic_nms'] = False # NMS class-agnostic setting
 
3
  from ultralytics.nn.tasks import DetectionModel
4
  from torch.nn.modules.container import Sequential
5
  from ultralytics.nn.modules import Conv
6
+ from torch.nn.modules.conv import Conv2d # Import Conv2d
7
 
8
+ # Whitelist the globals to bypass the pickle errors (only do this if you trust the source!)
9
+ torch.serialization.add_safe_globals([DetectionModel, Sequential, Conv, Conv2d])
10
 
11
  from ultralyticsplus import YOLO, render_result
12
  from PIL import Image
 
14
  # Load the YOLOv8s Leaf Detection and Classification model from Hugging Face
15
  model = YOLO('foduucom/plant-leaf-detection-and-classification')
16
 
17
+ # Set recommended model parameters as per the model card
18
  model.overrides['conf'] = 0.25 # NMS confidence threshold
19
  model.overrides['iou'] = 0.45 # NMS IoU threshold
20
  model.overrides['agnostic_nms'] = False # NMS class-agnostic setting