nickmuchi commited on
Commit
f2d241e
1 Parent(s): 1d6ddb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -31,11 +31,15 @@ def fig2img(fig):
31
  buf = io.BytesIO()
32
  fig.savefig(buf)
33
  buf.seek(0)
34
- img = Image.open(buf)
 
 
 
 
35
  return img
36
 
37
 
38
- def visualize_prediction(pil_img, output_dict, threshold=0.5, id2label=None):
39
  keep = output_dict["scores"] > threshold
40
  boxes = output_dict["boxes"][keep].tolist()
41
  scores = output_dict["scores"][keep].tolist()
@@ -44,10 +48,6 @@ def visualize_prediction(pil_img, output_dict, threshold=0.5, id2label=None):
44
  labels = [id2label[x] for x in labels]
45
 
46
  plt.figure(figsize=(18, 13))
47
- basewidth = 750
48
- wpercent = (basewidth/float(pil_img.size[0]))
49
- hsize = int((float(pil_img.size[1])*float(wpercent)))
50
- img = pil_img.resize((basewidth,hsize), Image.ANTIALIAS)
51
  plt.imshow(img)
52
  ax = plt.gca()
53
  colors = COLORS * 100
 
31
  buf = io.BytesIO()
32
  fig.savefig(buf)
33
  buf.seek(0)
34
+ pil_img = Image.open(buf)
35
+ basewidth = 750
36
+ wpercent = (basewidth/float(pil_img.size[0]))
37
+ hsize = int((float(pil_img.size[1])*float(wpercent)))
38
+ img = pil_img.resize((basewidth,hsize), Image.ANTIALIAS)
39
  return img
40
 
41
 
42
+ def visualize_prediction(img, output_dict, threshold=0.5, id2label=None):
43
  keep = output_dict["scores"] > threshold
44
  boxes = output_dict["boxes"][keep].tolist()
45
  scores = output_dict["scores"][keep].tolist()
 
48
  labels = [id2label[x] for x in labels]
49
 
50
  plt.figure(figsize=(18, 13))
 
 
 
 
51
  plt.imshow(img)
52
  ax = plt.gca()
53
  colors = COLORS * 100