Spaces:
Running
Running
Akshayram1
commited on
Commit
•
ef9bfa1
1
Parent(s):
1d9753d
Update app.py
Browse files
app.py
CHANGED
@@ -28,10 +28,17 @@ def extract_text(image, processor, model):
|
|
28 |
inputs = processor(images=image_resized, return_tensors="pt", do_resize=False).to("cpu")
|
29 |
pixel_values = inputs.get("pixel_values")
|
30 |
|
|
|
|
|
|
|
31 |
# Check if pixel values are valid
|
32 |
if pixel_values is None or pixel_values.shape[0] == 0:
|
33 |
raise ValueError("Preprocessing failed: Empty tensor generated for image.")
|
34 |
|
|
|
|
|
|
|
|
|
35 |
progress_bar.progress(50) # Step 2: Image preprocessed
|
36 |
time.sleep(0.5)
|
37 |
|
|
|
28 |
inputs = processor(images=image_resized, return_tensors="pt", do_resize=False).to("cpu")
|
29 |
pixel_values = inputs.get("pixel_values")
|
30 |
|
31 |
+
# Debugging: Check the pixel_values tensor shape
|
32 |
+
st.write(f"Pixel Values Shape: {pixel_values.shape}")
|
33 |
+
|
34 |
# Check if pixel values are valid
|
35 |
if pixel_values is None or pixel_values.shape[0] == 0:
|
36 |
raise ValueError("Preprocessing failed: Empty tensor generated for image.")
|
37 |
|
38 |
+
# Additional check to ensure it has expected shape
|
39 |
+
if pixel_values.shape[0] != 81 or pixel_values.shape[1] != 2048:
|
40 |
+
raise ValueError(f"Unexpected tensor shape: {pixel_values.shape}. Expected shape: [batch_size, 2048].")
|
41 |
+
|
42 |
progress_bar.progress(50) # Step 2: Image preprocessed
|
43 |
time.sleep(0.5)
|
44 |
|