Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,16 +19,17 @@ colors = ["red",
|
|
19 |
"slategray",
|
20 |
]
|
21 |
|
|
|
|
|
|
|
22 |
def detect(image):
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
26 |
|
27 |
-
inputs = image_processor(images=image,
|
28 |
-
do_resize=True,
|
29 |
-
size={"shortest_edge": 480,
|
30 |
-
"longest_edge": 640},
|
31 |
-
return_tensors="pt")
|
32 |
outputs = model(**inputs)
|
33 |
|
34 |
# convert outputs to COCO API
|
|
|
19 |
"slategray",
|
20 |
]
|
21 |
|
22 |
+
# Resized image width
|
23 |
+
WIDTH = 640
|
24 |
+
|
25 |
def detect(image):
|
26 |
+
width, height = image.size
|
27 |
+
ratio = float(WIDTH) / float(w)
|
28 |
+
new_h = h * ratio
|
29 |
+
|
30 |
+
image = image.resize((WIDTH, new_h), Image.Resampling.LANCZOS)
|
31 |
|
32 |
+
inputs = image_processor(images=image, return_tensors="pt")
|
|
|
|
|
|
|
|
|
33 |
outputs = model(**inputs)
|
34 |
|
35 |
# convert outputs to COCO API
|