Hi! Having trouble doing the API call to get extracted markdown as a string. I have installed nougat-ocr[api] and have started the server using nougat_api. I am on M1 Mac. Here is my extractor code and traceback:
CODE:
class NougatExtractor(Extractor):
def extract_text(self, pdf_file):
# ensure the file pointer is at the beginning of the file
pdf_file.seek(0)
# send the PDF file to the Nougat API
response = requests.post("http://127.0.0.1:8503/predict", files={"file": pdf_file})
# check for successful response and return markdown text
if response.status_code == 200:
return response.text
else:
raise Exception(f"Error: {response.status_code}: {response.text}")
TRACEBACK:
INFO: 127.0.0.1:54720 - "POST /predict HTTP/1.1" 307 Temporary Redirect
0%| | 0/1 [00:00<?, ?it/s]
INFO: 127.0.0.1:54720 - "POST /predict/ HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/////venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/////venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/////venv/lib/python3.11/site-packages/fastapi/applications.py", line 292, in __call__
await super().__call__(scope, receive, send)
File "/////venv/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
await self.middleware_stack(scope, receive, send)
File "/////venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/////venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/////venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 83, in __call__
await self.app(scope, receive, send)
File "/////venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/////venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/////venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
raise e
File "/////venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
await self.app(scope, receive, send)
File "/////venv/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "/////venv/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/////venv/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
^^^^^^^^^^^^^^^^^^^
File "/////venv/lib/python3.11/site-packages/fastapi/routing.py", line 273, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/////venv/lib/python3.11/site-packages/fastapi/routing.py", line 190, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/////venv/lib/python3.11/site-packages/app.py", line 128, in predict
model_output = model.inference(image_tensors=sample)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/////venv/lib/python3.11/site-packages/nougat/model.py", line 590, in inference
# get decoder output
^
File "/////venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/////venv/lib/python3.11/site-packages/nougat/model.py", line 125, in forward
File "/////venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/////venv/lib/python3.11/site-packages/timm/models/layers/patch_embed.py", line 35, in forward
x = self.proj(x)
^^^^^^^^^^^^
File "/////venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/////venv/lib/python3.11/site-packages/torch/nn/modules/conv.py", line 463, in forward
return self._conv_forward(input, self.weight, self.bias)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/////venv/lib/python3.11/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Input type (float) and bias type (c10::BFloat16) should be the same
I really appreciate an assistance you can provide! Thanks so much!
Hi! Having trouble doing the API call to get extracted markdown as a string. I have installed nougat-ocr[api] and have started the server using nougat_api. I am on M1 Mac. Here is my extractor code and traceback:
CODE:
TRACEBACK:
I really appreciate an assistance you can provide! Thanks so much!