Reaumur commited on
Commit
c9fe372
·
verified ·
1 Parent(s): 18fac15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -62,14 +62,14 @@ def prepare_image(img):
62
 
63
  return pred_texts, preds
64
 
65
- # Define a simple batch decoder (adjust as needed)
66
  def decode_batch_predictions(pred):
67
- # This function should convert the predictions (logits) to text
68
- # Modify this function based on your specific character map
69
  pred_texts = []
70
- for i in range(pred.shape[0]):
71
- pred_text = ''.join([characters[int(c)] for c in pred[i] if c != -1]) # Map to characters
 
72
  pred_texts.append(pred_text)
 
73
  return pred_texts
74
 
75
  def run():
 
62
 
63
  return pred_texts, preds
64
 
 
65
  def decode_batch_predictions(pred):
66
+ characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" # Update sesuai dengan karakter yang digunakan
 
67
  pred_texts = []
68
+
69
+ for i in range(len(pred)): # Looping melalui prediksi batch
70
+ pred_text = ''.join([characters[int(c)] for c in pred[i].tolist() if c != -1]) # Convert pred[i] ke list dan menghindari -1
71
  pred_texts.append(pred_text)
72
+
73
  return pred_texts
74
 
75
  def run():