Turing311 commited on
Commit
80fb04c
1 Parent(s): 11cb3ae
Files changed (1) hide show
  1. gradio/demo.py +5 -9
gradio/demo.py CHANGED
@@ -9,7 +9,7 @@ def compare_face(frame1, frame2):
9
 
10
  r = requests.post(url=url, files=files)
11
  faces = None
12
- log = "start"
13
  try:
14
  image1 = Image.open(frame1)
15
  image2 = Image.open(frame2)
@@ -38,15 +38,14 @@ def compare_face(frame1, frame2):
38
  resized_h = 150
39
 
40
  face1 = face1.resize((int(resized_w), int(resized_h)))
41
- log += "2 " + str(face1.width) + "\n"
42
  if data.get('face2') is not None:
43
- log += "3 \n"
44
  face = data.get('face2')
45
  x1 = face.get('x1')
46
  y1 = face.get('y1')
47
  x2 = face.get('x2')
48
  y2 = face.get('y2')
49
- log += "3-1 \n"
50
  if x1 < 0:
51
  x1 = 0
52
  if y1 < 0:
@@ -55,7 +54,7 @@ def compare_face(frame1, frame2):
55
  x2 = image2.width - 1
56
  if y2 >= image2.height:
57
  y2 = image2.height - 1
58
- log += "3-2 " + str(x1) + " " + str(y1) + " " + str(x2) + " " + str(y2) + "\n"
59
  face2 = image2.crop((x1, y1, x2, y2))
60
  face_image_ratio = face2.width / float(face2.height)
61
  resized_w = int(face_image_ratio * 150)
@@ -63,7 +62,6 @@ def compare_face(frame1, frame2):
63
 
64
  face2 = face2.resize((int(resized_w), int(resized_h)))
65
 
66
- log += "3 " + str(face2) + "\n"
67
  if face1 is not None and face2 is not None:
68
  new_image = Image.new('RGB',(face1.width + face2.width + 10, 150), (80,80,80))
69
 
@@ -80,12 +78,10 @@ def compare_face(frame1, frame2):
80
 
81
  new_image.paste(face2,(face2.width + 10, 0))
82
  faces = new_image.copy()
83
-
84
- log += "4 " + str(faces)
85
  except:
86
  pass
87
 
88
- return [{"log": log}, faces]
89
 
90
  with gr.Blocks() as demo:
91
  gr.Markdown(
 
9
 
10
  r = requests.post(url=url, files=files)
11
  faces = None
12
+
13
  try:
14
  image1 = Image.open(frame1)
15
  image2 = Image.open(frame2)
 
38
  resized_h = 150
39
 
40
  face1 = face1.resize((int(resized_w), int(resized_h)))
41
+
42
  if data.get('face2') is not None:
 
43
  face = data.get('face2')
44
  x1 = face.get('x1')
45
  y1 = face.get('y1')
46
  x2 = face.get('x2')
47
  y2 = face.get('y2')
48
+
49
  if x1 < 0:
50
  x1 = 0
51
  if y1 < 0:
 
54
  x2 = image2.width - 1
55
  if y2 >= image2.height:
56
  y2 = image2.height - 1
57
+
58
  face2 = image2.crop((x1, y1, x2, y2))
59
  face_image_ratio = face2.width / float(face2.height)
60
  resized_w = int(face_image_ratio * 150)
 
62
 
63
  face2 = face2.resize((int(resized_w), int(resized_h)))
64
 
 
65
  if face1 is not None and face2 is not None:
66
  new_image = Image.new('RGB',(face1.width + face2.width + 10, 150), (80,80,80))
67
 
 
78
 
79
  new_image.paste(face2,(face2.width + 10, 0))
80
  faces = new_image.copy()
 
 
81
  except:
82
  pass
83
 
84
+ return [r.json(), faces]
85
 
86
  with gr.Blocks() as demo:
87
  gr.Markdown(