Spaces:
Build error
Build error
Commit
·
6fc1fce
1
Parent(s):
6ada5e3
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,10 @@ import gradio as gr
|
|
| 3 |
import os
|
| 4 |
import torch
|
| 5 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
from model import create_effnetb2_model
|
| 8 |
from timeit import default_timer as timer
|
|
@@ -45,6 +49,9 @@ def predict(img) -> Tuple[Dict, float]:
|
|
| 45 |
# Transform the target image and add a batch dimension
|
| 46 |
img1 = effnetb2_transforms(img).unsqueeze(0)
|
| 47 |
pix = normalize_2d(np.array(img))
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# Put model into evaluation mode and turn on inference mode
|
| 50 |
effnetb2.eval()
|
|
@@ -59,7 +66,7 @@ def predict(img) -> Tuple[Dict, float]:
|
|
| 59 |
pred_time = round(timer() - start_time, 5)
|
| 60 |
|
| 61 |
# Return the prediction dictionary and prediction time
|
| 62 |
-
return pred_labels_and_probs, pred_time,
|
| 63 |
|
| 64 |
### 4. Gradio app ###
|
| 65 |
|
|
|
|
| 3 |
import os
|
| 4 |
import torch
|
| 5 |
import numpy as np
|
| 6 |
+
from roboflow import Roboflow
|
| 7 |
+
rf = Roboflow(api_key="gjZE3lykkitagkxHplyJ")
|
| 8 |
+
project = rf.workspace().project("rideit")
|
| 9 |
+
model = project.version(1).model
|
| 10 |
|
| 11 |
from model import create_effnetb2_model
|
| 12 |
from timeit import default_timer as timer
|
|
|
|
| 49 |
# Transform the target image and add a batch dimension
|
| 50 |
img1 = effnetb2_transforms(img).unsqueeze(0)
|
| 51 |
pix = normalize_2d(np.array(img))
|
| 52 |
+
|
| 53 |
+
pix1=model.predict(img, confidence=40, overlap=30)
|
| 54 |
+
|
| 55 |
|
| 56 |
# Put model into evaluation mode and turn on inference mode
|
| 57 |
effnetb2.eval()
|
|
|
|
| 66 |
pred_time = round(timer() - start_time, 5)
|
| 67 |
|
| 68 |
# Return the prediction dictionary and prediction time
|
| 69 |
+
return pred_labels_and_probs, pred_time,pix1
|
| 70 |
|
| 71 |
### 4. Gradio app ###
|
| 72 |
|