Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -12,12 +12,13 @@ def load_model():
|
|
12 |
|
13 |
# Extract text from image
|
14 |
def extract_text(image, processor, model):
|
15 |
-
# Preprocess image
|
16 |
-
inputs = processor(images=image, return_tensors="pt")
|
|
|
17 |
|
18 |
# Perform generation
|
19 |
with torch.no_grad():
|
20 |
-
outputs = model.generate(
|
21 |
|
22 |
# Decode outputs
|
23 |
result = processor.batch_decode(outputs, skip_special_tokens=True)[0]
|
|
|
12 |
|
13 |
# Extract text from image
|
14 |
def extract_text(image, processor, model):
|
15 |
+
# Preprocess image (extract pixel values only)
|
16 |
+
inputs = processor(images=image, return_tensors="pt").to("cpu")
|
17 |
+
pixel_values = inputs.get("pixel_values") # Only pass necessary inputs
|
18 |
|
19 |
# Perform generation
|
20 |
with torch.no_grad():
|
21 |
+
outputs = model.generate(pixel_values=pixel_values) # Use pixel_values here
|
22 |
|
23 |
# Decode outputs
|
24 |
result = processor.batch_decode(outputs, skip_special_tokens=True)[0]
|