Spaces:
Sleeping
Sleeping
Commit
·
307f432
1
Parent(s):
dfba72c
Minor change
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import numpy as np
|
|
| 3 |
import gradio as gr
|
| 4 |
from PIL import Image
|
| 5 |
from models.common import DetectMultiBackend
|
|
|
|
| 6 |
from utils.plots import Annotator, colors
|
| 7 |
from utils.torch_utils import select_device, smart_inference_mode
|
| 8 |
from utils.general import check_img_size, Profile, non_max_suppression, scale_boxes
|
|
@@ -45,8 +46,9 @@ def inference(input_img, conf_thres, iou_thres):
|
|
| 45 |
seen, windows, dt = 0, [], (Profile(), Profile(), Profile())
|
| 46 |
|
| 47 |
with dt[0]:
|
| 48 |
-
im =
|
| 49 |
im = im.transpose((2, 0, 1))[::-1]
|
|
|
|
| 50 |
im = im.half() if model.fp16 else im.float() # uint8 to fp16/32
|
| 51 |
im /= 255 # 0 - 255 to 0.0 - 1.0
|
| 52 |
if len(im.shape) == 3:
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
from PIL import Image
|
| 5 |
from models.common import DetectMultiBackend
|
| 6 |
+
from utils.augmentations import letterbox
|
| 7 |
from utils.plots import Annotator, colors
|
| 8 |
from utils.torch_utils import select_device, smart_inference_mode
|
| 9 |
from utils.general import check_img_size, Profile, non_max_suppression, scale_boxes
|
|
|
|
| 46 |
seen, windows, dt = 0, [], (Profile(), Profile(), Profile())
|
| 47 |
|
| 48 |
with dt[0]:
|
| 49 |
+
im = letterbox(input_img, imgsz, stride=32, auto=True)[0] # padded resize
|
| 50 |
im = im.transpose((2, 0, 1))[::-1]
|
| 51 |
+
im = torch.from_numpy(input_img).to(model.device)
|
| 52 |
im = im.half() if model.fp16 else im.float() # uint8 to fp16/32
|
| 53 |
im /= 255 # 0 - 255 to 0.0 - 1.0
|
| 54 |
if len(im.shape) == 3:
|