ongkn commited on
Commit
c412d9f
·
1 Parent(s): acc0e22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -72,14 +72,17 @@ pipe = pipeline("image-classification", model=model, feature_extractor=processor
72
 
73
  def classify_image(input):
74
  face = grab_faces(np.array(input))
 
 
 
75
  face = Image.fromarray(face)
76
  result = pipe(face)
77
- return result[0]["label"], result[0]["score"]
78
 
79
  iface = gr.Interface(
80
  fn=classify_image,
81
  inputs="image",
82
- outputs=["text", "number"],
83
  title="Attraction Classifier - subjective",
84
  description="Takes in a (224, 224) image and outputs an attraction class: {\"pos\", \"neg\"}"
85
  )
 
72
 
73
  def classify_image(input):
74
  face = grab_faces(np.array(input))
75
+ if face is not None:
76
+ x, y, w, h = face
77
+ cv.rectangle(input, (x, y), (x + w, y + h), (255, 255, 0), 2)
78
  face = Image.fromarray(face)
79
  result = pipe(face)
80
+ return result[0]["label"], result[0]["score"], input
81
 
82
  iface = gr.Interface(
83
  fn=classify_image,
84
  inputs="image",
85
+ outputs=["text", "number", "image"],
86
  title="Attraction Classifier - subjective",
87
  description="Takes in a (224, 224) image and outputs an attraction class: {\"pos\", \"neg\"}"
88
  )