asrs777 commited on
Commit
8237488
1 Parent(s): 7456cc8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -32,7 +32,7 @@ def draw_results_ssd(detected, input_img, ad):
32
  confidence = detected[0, 0, i, 2]
33
 
34
  # filter out weak detections
35
- if confidence > 0.5:
36
  # compute the (x, y)-coordinates of the bounding box for
37
  # the face and extract the face ROI
38
  (h0, w0) = input_img.shape[:2]
@@ -126,22 +126,26 @@ def face_detector(input_img):
126
  return cropped_list
127
 
128
  def predict(image):
129
- print(type(image))
130
  cropped_list = face_detector(image)
131
- print(cropped_list)
132
- output = [None for _ in range(20)]
133
- for i in range(len(cropped_list)):
134
- predictions = pipe(Image.fromarray(cropped_list[i]))
135
- output[int(i*2)] = Image.fromarray(cropped_list[i])
136
- output[int(i*2+1)] = {p["label"]: p["score"] for p in predictions}
137
- # return [output[0], output[1]]
138
- return output
 
 
 
139
 
140
  # outputs=list(itertools.chain(*[[gr.outputs.Image(label="Image {}".format(ind)), gr.outputs.Label(num_top_classes=7, label="Result {}".format(ind))] for ind in range(10)])),
 
141
  gr.Interface(
142
  predict,
143
  inputs=gr.inputs.Image(label="Upload image"),
144
- outputs=list(itertools.chain(*[["image", "label"] for _ in range(10)])), #Maximum number of face: 10
145
  examples=[["examples/9_peoples.jpg"], ["examples/sad.jpg"], ["examples/angry.jpg"], ["examples/surprise.jpg"]],
146
  title="FER trained on DiffusionFER dataset",
147
  ).launch()
 
32
  confidence = detected[0, 0, i, 2]
33
 
34
  # filter out weak detections
35
+ if confidence > 0.6:
36
  # compute the (x, y)-coordinates of the bounding box for
37
  # the face and extract the face ROI
38
  (h0, w0) = input_img.shape[:2]
 
126
  return cropped_list
127
 
128
  def predict(image):
129
+ # print(type(image))
130
  cropped_list = face_detector(image)
131
+ # print(cropped_list)
132
+ # output = [None for _ in range(20)]
133
+ output_img = Image.fromarray(cropped_list[i])
134
+ predictions = pipe(output_img)
135
+ return output_img, predictions
136
+ # for i in range(len(cropped_list)):
137
+ # predictions = pipe(Image.fromarray(cropped_list[i]))
138
+ # output[int(i*2)] = Image.fromarray(cropped_list[i])
139
+ # output[int(i*2+1)] = {p["label"]: p["score"] for p in predictions}
140
+ # # return [output[0], output[1]]
141
+ # return output
142
 
143
  # outputs=list(itertools.chain(*[[gr.outputs.Image(label="Image {}".format(ind)), gr.outputs.Label(num_top_classes=7, label="Result {}".format(ind))] for ind in range(10)])),
144
+ # list(itertools.chain(*[["image", "label"] for _ in range(10)])), #Maximum number of face: 10
145
  gr.Interface(
146
  predict,
147
  inputs=gr.inputs.Image(label="Upload image"),
148
+ outputs=["image", "label"],
149
  examples=[["examples/9_peoples.jpg"], ["examples/sad.jpg"], ["examples/angry.jpg"], ["examples/surprise.jpg"]],
150
  title="FER trained on DiffusionFER dataset",
151
  ).launch()