Spaces:
Build error
Build error
Commit
·
53b5a12
1
Parent(s):
bf7e805
Update app.py
Browse files
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)
|
| 45 |
-
|
| 46 |
-
"""
|
| 47 |
-
# Start the timer
|
| 48 |
start_time = timer()
|
| 49 |
|
| 50 |
# Transform the target image and add a batch dimension
|
| 51 |
-
|
|
|
|
| 52 |
img1 = effnetb2_transforms(img1).unsqueeze(0)
|
| 53 |
pix = normalize_2d(np.array(img))
|
| 54 |
|
| 55 |
-
pix1=model.predict(str(
|
| 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
|