aegishield commited on
Commit
60556a5
·
1 Parent(s): d2d5fd3
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -23,7 +23,7 @@ def show_fingername(fingernum):
23
  else: fingername += "thumb"
24
  return fingername
25
 
26
- def predict_image(img, image_file):
27
  # Ensure the image is a PIL Image
28
  if not isinstance(img, Image.Image):
29
  img = Image.fromarray(img)
@@ -44,15 +44,13 @@ def predict_image(img, image_file):
44
  y_SubjectID_pred = idpred.predict(img_array)
45
  y_fingerNum_pred = fingpred.predict(img_array)
46
 
47
- image_name = image_file.name if image_file is not None else "No file name"
48
-
49
  # Extract prediction and confidence
50
  subject_id = np.argmax(y_SubjectID_pred, axis=1)[0] + 1
51
  finger_num = np.argmax(y_fingerNum_pred, axis=1)[0]
52
  subject_confidence = np.max(y_SubjectID_pred) * 100
53
  finger_confidence = np.max(y_fingerNum_pred) * 100
54
 
55
- output_message = f"Image Name: {image_name}\nPredicted Subject ID: {subject_id} (Confidence: {subject_confidence:.2f}%)\nPredicted Finger Type: {finger_num} (Confidence: {finger_confidence:.2f}%)"
56
 
57
  return output_message
58
 
 
23
  else: fingername += "thumb"
24
  return fingername
25
 
26
+ def predict_image(img):
27
  # Ensure the image is a PIL Image
28
  if not isinstance(img, Image.Image):
29
  img = Image.fromarray(img)
 
44
  y_SubjectID_pred = idpred.predict(img_array)
45
  y_fingerNum_pred = fingpred.predict(img_array)
46
 
 
 
47
  # Extract prediction and confidence
48
  subject_id = np.argmax(y_SubjectID_pred, axis=1)[0] + 1
49
  finger_num = np.argmax(y_fingerNum_pred, axis=1)[0]
50
  subject_confidence = np.max(y_SubjectID_pred) * 100
51
  finger_confidence = np.max(y_fingerNum_pred) * 100
52
 
53
+ output_message = f"Predicted Subject ID: {subject_id} (Confidence: {subject_confidence:.2f}%)\nPredicted Finger Type: {finger_num} (Confidence: {finger_confidence:.2f}%)"
54
 
55
  return output_message
56