remotewith commited on
Commit
53b5a12
·
1 Parent(s): bf7e805

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -5,6 +5,7 @@ import torch
5
  import numpy as np
6
  from roboflow import Roboflow
7
  import cv2
 
8
  rf = Roboflow(api_key="gjZE3lykkitagkxHplyJ")
9
  project = rf.workspace().project("rideit")
10
  model = project.version(1).model
@@ -41,18 +42,17 @@ def normalize_2d(matrix):
41
  return matrix
42
 
43
  # Create predict function
44
- def predict(img) -> Tuple[Dict, float]:
45
- """Transforms and performs a prediction on img and returns prediction and time taken.
46
- """
47
- # Start the timer
48
  start_time = timer()
49
 
50
  # Transform the target image and add a batch dimension
51
- img1=PIL.Image.open(img)
 
52
  img1 = effnetb2_transforms(img1).unsqueeze(0)
53
  pix = normalize_2d(np.array(img))
54
 
55
- pix1=model.predict(str(img), confidence=40, overlap=30)
56
 
57
 
58
  # Put model into evaluation mode and turn on inference mode
 
5
  import numpy as np
6
  from roboflow import Roboflow
7
  import cv2
8
+
9
  rf = Roboflow(api_key="gjZE3lykkitagkxHplyJ")
10
  project = rf.workspace().project("rideit")
11
  model = project.version(1).model
 
42
  return matrix
43
 
44
  # Create predict function
45
+ def predict(img):
46
+
 
 
47
  start_time = timer()
48
 
49
  # Transform the target image and add a batch dimension
50
+ image = cv2.imread(img)
51
+ img1 = PIL.Image.open(img)
52
  img1 = effnetb2_transforms(img1).unsqueeze(0)
53
  pix = normalize_2d(np.array(img))
54
 
55
+ pix1=model.predict(str(image), confidence=40, overlap=30).[0].cpu().numpy()
56
 
57
 
58
  # Put model into evaluation mode and turn on inference mode