Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,7 +48,12 @@ async def extract_text(file: UploadFile = File(...)):
|
|
| 48 |
contents = await file.read()
|
| 49 |
image = Image.open(io.BytesIO(contents)).convert("RGB")
|
| 50 |
|
| 51 |
-
inputs = processor(images=image, return_tensors="pt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
with torch.no_grad():
|
| 54 |
outputs = model.generate(**inputs, max_new_tokens=1024)
|
|
|
|
| 48 |
contents = await file.read()
|
| 49 |
image = Image.open(io.BytesIO(contents)).convert("RGB")
|
| 50 |
|
| 51 |
+
# inputs = processor(images=image, return_tensors="pt")
|
| 52 |
+
inputs = processor(
|
| 53 |
+
text="Extract all text from the document",
|
| 54 |
+
images=image,
|
| 55 |
+
return_tensors="pt"
|
| 56 |
+
)
|
| 57 |
|
| 58 |
with torch.no_grad():
|
| 59 |
outputs = model.generate(**inputs, max_new_tokens=1024)
|