sandygmaharaj commited on
Commit
06fa033
·
1 Parent(s): 9f7e9cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -20,15 +20,16 @@ emotions = {"x": [], "y": [], "State": []}
20
  def predict(img):
21
  img = PILImage.create(img)
22
  boxes, _ = mtcnn.detect(img)
23
- o_img = img.copy()
24
  #draw = ImageDraw.Draw(o_img)
25
  draw = Image.new("RGBA", img.size, color = "white")
 
26
  for box in boxes:
27
  coords = tuple(box.tolist())
28
  pred,pred_idx,probs = learn.predict(img.crop(coords))
29
- draw.rectangle(coords, fill=e_colors[pred], outline=(0, 0, 0), width=1)
30
- draw.text((coords[0]-10, coords[1]-10), pred, font=ImageFont.truetype("arial.ttf"))
31
- return o_img
32
  '''
33
  emotions["x"].append((coords[0] + coords[2])/2)
34
  emotions["y"].append((coords[1] + coords[3])/2)
 
20
  def predict(img):
21
  img = PILImage.create(img)
22
  boxes, _ = mtcnn.detect(img)
23
+ #o_img = img.copy()
24
  #draw = ImageDraw.Draw(o_img)
25
  draw = Image.new("RGBA", img.size, color = "white")
26
+ img1 = ImageDraw.Draw(img)
27
  for box in boxes:
28
  coords = tuple(box.tolist())
29
  pred,pred_idx,probs = learn.predict(img.crop(coords))
30
+ img1.rectangle(coords, fill=e_colors[pred], outline=(0, 0, 0), width=1)
31
+ img1.text((coords[0]-10, coords[1]-10), pred, font=ImageFont.truetype("arial.ttf"))
32
+ return draw
33
  '''
34
  emotions["x"].append((coords[0] + coords[2])/2)
35
  emotions["y"].append((coords[1] + coords[3])/2)