JosephTK commited on
Commit
63cd666
1 Parent(s): 44fce2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -19,16 +19,17 @@ colors = ["red",
19
  "slategray",
20
  ]
21
 
 
 
 
22
  def detect(image):
23
- # Change width to 640 pixels
24
- #h, w, c = image.shape
25
- #scale = 640 / w
 
 
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