Spaces:
Runtime error
Runtime error
checking. resizing background image
Browse files
app.py
CHANGED
|
@@ -68,8 +68,8 @@ def draw_keypoints_on_image(image,
|
|
| 68 |
# Predict detections with MegaDetector v5a model
|
| 69 |
def predict_md(im, size=640):
|
| 70 |
# resize image
|
| 71 |
-
|
| 72 |
-
|
| 73 |
|
| 74 |
## detect objects
|
| 75 |
results = MD_model(im) # inference # vars(results).keys()= dict_keys(['imgs', 'pred', 'names', 'files', 'times', 'xyxy', 'xywh', 'xyxyn', 'xywhn', 'n', 't', 's'])
|
|
@@ -208,6 +208,8 @@ def predict_pipeline(img_input,
|
|
| 208 |
|
| 209 |
# Produce final image
|
| 210 |
img_background = img_input # img_input? Image.fromarray(md_results.imgs[0])
|
|
|
|
|
|
|
| 211 |
for ic, (np_crop, kpts_crop) in enumerate(zip(list_crops,
|
| 212 |
list_kpts_per_crop)):
|
| 213 |
|
|
|
|
| 68 |
# Predict detections with MegaDetector v5a model
|
| 69 |
def predict_md(im, size=640):
|
| 70 |
# resize image
|
| 71 |
+
g = (size / max(im.size)) # gain
|
| 72 |
+
im = im.resize((int(x * g) for x in im.size), Image.ANTIALIAS) # resize
|
| 73 |
|
| 74 |
## detect objects
|
| 75 |
results = MD_model(im) # inference # vars(results).keys()= dict_keys(['imgs', 'pred', 'names', 'files', 'times', 'xyxy', 'xywh', 'xyxyn', 'xywhn', 'n', 't', 's'])
|
|
|
|
| 208 |
|
| 209 |
# Produce final image
|
| 210 |
img_background = img_input # img_input? Image.fromarray(md_results.imgs[0])
|
| 211 |
+
g = (size / max(img_background.size)) # gain
|
| 212 |
+
img_background = img_background.resize((int(x * g) for x in img_background.size), Image.ANTIALIAS) # resize
|
| 213 |
for ic, (np_crop, kpts_crop) in enumerate(zip(list_crops,
|
| 214 |
list_kpts_per_crop)):
|
| 215 |
|