Update app.py
Browse files
app.py
CHANGED
|
@@ -187,17 +187,13 @@ def inference_image(model, image, device, tokenizer):
|
|
| 187 |
img_tensor = transform(image).unsqueeze(0).to(device)
|
| 188 |
|
| 189 |
with torch.no_grad():
|
| 190 |
-
#
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
logits = model(image=img_tensor)
|
| 198 |
-
except TypeError:
|
| 199 |
-
# Try with just the tensor
|
| 200 |
-
logits = model(img_tensor)
|
| 201 |
|
| 202 |
predicted_text = decode_prediction(logits, tokenizer)
|
| 203 |
|
|
|
|
| 187 |
img_tensor = transform(image).unsqueeze(0).to(device)
|
| 188 |
|
| 189 |
with torch.no_grad():
|
| 190 |
+
# Call forward with both images and tokenizer
|
| 191 |
+
logits = model(images=img_tensor, tokenizer=tokenizer)
|
| 192 |
+
|
| 193 |
+
# Get predicted text from logits
|
| 194 |
+
# For PARSeq, the output might be logits or the model might return predictions directly
|
| 195 |
+
if isinstance(logits, tuple):
|
| 196 |
+
logits = logits[0] # Sometimes returns (logits, attention_weights)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
predicted_text = decode_prediction(logits, tokenizer)
|
| 199 |
|