{"id":469593,"date":"2025-08-05T09:01:44","date_gmt":"2025-08-05T09:01:44","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=469593"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=469593","title":{"rendered":"<span>\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0438 \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c. Paddle OCR + LLM<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/128\/c27\/428\/128c274282b77d82ca17ca91863ba7af.png\" alt=\"\u041a\u0430\u0434\u0440 \u0438\u0437 \u0444\u0438\u043b\u044c\u043c\u0430 \u0434\u0432\u0443\u0445\u0441\u043e\u0442\u043b\u0435\u0442\u043d\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\" title=\"\u041a\u0430\u0434\u0440 \u0438\u0437 \u0444\u0438\u043b\u044c\u043c\u0430 \u0434\u0432\u0443\u0445\u0441\u043e\u0442\u043b\u0435\u0442\u043d\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\" width=\"3266\" height=\"1732\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/128\/c27\/428\/128c274282b77d82ca17ca91863ba7af.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/128\/c27\/428\/128c274282b77d82ca17ca91863ba7af.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041a\u0430\u0434\u0440 \u0438\u0437 \u0444\u0438\u043b\u044c\u043c\u0430 \u0434\u0432\u0443\u0445\u0441\u043e\u0442\u043b\u0435\u0442\u043d\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0438 \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c.\u00a0<\/p>\n<h2>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<ul>\n<li>\n<p>\u042f\u0437\u044b\u043a: <strong><em>Python<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0421\u0438\u043c\u0432\u043e\u043b\u043e\u0432(OCR): <strong><em>Paddle OCR<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u043e\u0449\u0430\u0434\u043a\u0430 \u0434\u043b\u044f \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438: <strong><em>Ollama<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p>\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u044f\u0437\u044b\u043a\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c(LLM): <strong><em>qwen2:7b<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p>\u0421\u0435\u0442\u0435\u0432\u043e\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f API: <strong><em>FastAPI<\/em><\/strong><\/p>\n<\/li>\n<\/ul>\n<h2>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/h2>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/123\/cf4\/4be\/123cf44be972ae562feb8f4cab91a186.png\" alt=\"\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\" title=\"\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\" width=\"962\" height=\"328\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/123\/cf4\/4be\/123cf44be972ae562feb8f4cab91a186.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/123\/cf4\/4be\/123cf44be972ae562feb8f4cab91a186.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/figcaption><\/div>\n<\/figure>\n<h2>\u042d\u0442\u0430\u043f\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<ol>\n<li>\n<p>API \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>API \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c<\/p>\n<\/li>\n<\/ol>\n<h2>\u042d\u0442\u0430\u043f 1. API \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p><strong>\u041f\u0440\u043e\u0446\u0435\u0441:<\/strong> 1.\u00a0\u0421\u043e\u0437\u0434\u0430\u0451\u043c\u00a0\u043a\u043e\u0434 -&gt; 2.\u00a0\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u00a0\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 -&gt; 3.\u00a0\u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c\u00a0\u0441\u0435\u0440\u0432\u0435\u0440 -&gt; 4.\u00a0\u0414\u0435\u043b\u0430\u0435\u043c\u00a0\u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 -&gt; 5.\u00a0\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u00a0\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<h3>1. \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u0434<\/h3>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u0436\u0435\u043b\u0435\u0437\u043e \u043c\u0430\u0448\u0438\u043d\u044b \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0441 \u0440\u0430\u0431\u043e\u0442\u043e\u0439, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0436\u0438\u043c\u0430\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f <em>COMPRESS_SCALE <\/em>\u0442\u0435\u0431\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u0441\u0432\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0448\u044c.<\/p>\n<pre><code class=\"python\">import numpy as np from fastapi import FastAPI, File, UploadFile from fastapi.responses import JSONResponse from paddleocr import PaddleOCR from PIL import Image import io  app = FastAPI(     title=\"PaddleOCR API\",     description=\"A simple API for OCR using PaddleOCR\",     version=\"1.0.0\" )  ocr = PaddleOCR(     use_doc_orientation_classify=False,     use_doc_unwarping=False,     use_textline_orientation=False )  def ocr_pdf_paddle(image):     print(\"START COMPRESSING...\")     COMPRESS_SCALE = 0.5     width, height = image.size     new_size = (int(width * COMPRESS_SCALE), int(height * COMPRESS_SCALE))     img_resized = image.resize(new_size, Image.LANCZOS)     image_array = np.array(img_resized)      print(\"START PREDICTION...\")     page_text = ocr.predict(image_array)      return page_text  @app.post(\"\/ocr\") async def perform_ocr(file: UploadFile = File(...)):     print(\"IMAGE READING...\")      contents = await file.read()     image = Image.open(io.BytesIO(contents)).convert(\"RGB\")  # Ensure RGB      # Perform OCR     result = ocr_pdf_paddle(image)     print(\"FILE PREDICTION ENDED\")      if isinstance(result, list) and len(result) &gt; 0:         rec_texts = result[0].get(\"rec_texts\", [])     elif isinstance(result, dict):         rec_texts = result.get(\"rec_texts\", [])     else:         rec_texts = []      print(\"SENDING RESPONSE...\")     return JSONResponse(content=rec_texts) <\/code><\/pre>\n<h3>2. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h3>\n<h4>\u0430) \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Paddlepaddle:\u00a0<\/h4>\n<p>\u041b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 <a href=\"https:\/\/www.paddlepaddle.org.cn\/en\/install\/quick?docurl=undefined\" rel=\"noopener noreferrer nofollow\">\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439<\/a>\u00a0\u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c <a href=\"https:\/\/www.paddlepaddle.org.cn\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0430\u0439\u0442\u0435<\/a><\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 paddlepaddle \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0430\u043c\u044b\u043c \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442.\u043a. \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0432\u043e\u0435 \u0436\u0435\u043b\u0435\u0437\u043e, \u0441 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 paddlepaddle. \u0422\u043e-\u0435\u0441\u0442\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f.\u00a0<\/p>\n<p><strong><em>\u041e\u0431\u043d\u0430\u0440\u0443\u0436\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0441\u0432\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b:<\/em><\/strong><\/p>\n<ul>\n<li>\n<p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430<\/p>\n<\/li>\n<li>\n<p>\u0416\u0435\u043b\u0435\u0437\u043e: \u0422\u0438\u043f \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u044b \u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430(GPU): \u0432\u0435\u0440\u0441\u0438\u044e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430(GPU): \u0412\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0436\u0435\u043b\u0435\u0437\u043e\u043c (\u0421UDA, ArmV8 \u0438 \u0442\u0434 )\u00a0<\/p>\n<\/li>\n<\/ul>\n<p><strong><em>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e:<\/em><\/strong> \u0443\u0431\u0435\u0434\u0438\u0441\u044c, \u0447\u0442\u043e \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0436\u0435\u043b\u0435\u0437\u0430(\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430) \u0438 \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0436\u0435\u043b\u0435\u0437\u043e\u043c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b.\u00a0<\/p>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0442\u0432\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b, \u043f\u043e\u0434\u0431\u0435\u0440\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 paddlepaddle \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435 paddlepaddle.<\/p>\n<h4>\u0431) \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Paddle OCR:<\/h4>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 pip install paddleocr<\/code><\/pre>\n<p>\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a Paddle OCR: <a href=\"https:\/\/github.com\/PaddlePaddle\/PaddleOCR\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/PaddlePaddle\/PaddleOCR<\/a><\/p>\n<h4>\u0432) \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 FastAPI:\u00a0<\/h4>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 pip install fastapi<\/code><\/pre>\n<h3>3. \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440:<\/h3>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f # ocr_api_test - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c uvicorn ocr_api_test:app --reload --host 0.0.0.0 --port 8000<\/code><\/pre>\n<h3>4. \u0414\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/h3>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443 curl -X POST \"http:\/\/localhost:8000\/ocr\" \\      -F \"file=@\\\"\/yourTestPathDir\/yourTestImageName.png\\\"\" \\      | python -m json.tool<\/code><\/pre>\n<p><strong><em>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441 Paddle OCR:<\/em><\/strong><\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0443\u043f\u0430\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u0434\u043b\u044f \u0436\u0435\u043b\u0435\u0437\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439 \u0441\u0436\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u043d\u0442, \u0447\u0442\u043e \u0431\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u0436\u0435\u043b\u0435\u0437\u0430 \u0445\u0432\u0430\u0442\u0438\u043b\u043e \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h3>5. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h3>\n<h4>\u0430) \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435<\/h4>\n<pre><code class=\"python\"># ... \u0422\u0423\u0422 \u041a\u041e\u0414 \u0418\u0417 API \u041c\u0415\u0422\u041e\u0414\u0410 result = ocr_pdf_paddle(image)  # \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f  # \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 outputDirPath = \"\/yourRootPath\/yourOutputDirPath\" for res in result:   result_base = os.path.join(outputDirPath)   res.save_to_img(result_base)  # e.g., page_1_result.jpg   res.save_to_json(result_base)  # e.g., page_1_result.json<\/code><\/pre>\n<h4>\u0431) \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <\/h4>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/780\/ff9\/e70\/780ff9e70fbb720bec8c4d3ca60a5e24.png\" alt=\"\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f\" title=\"\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f\" width=\"3298\" height=\"1894\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/780\/ff9\/e70\/780ff9e70fbb720bec8c4d3ca60a5e24.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/780\/ff9\/e70\/780ff9e70fbb720bec8c4d3ca60a5e24.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ac4\/8b0\/f23\/ac48b0f238ad338b33f6466c50d764c7.png\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438\" width=\"3298\" height=\"947\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/ac4\/8b0\/f23\/ac48b0f238ad338b33f6466c50d764c7.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ac4\/8b0\/f23\/ac48b0f238ad338b33f6466c50d764c7.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438<\/figcaption><\/div>\n<\/figure>\n<p><em>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e: <\/em><\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e PaddleOCR \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043b \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0435, \u043d\u043e \u0438 \u043a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0435 \u0431\u0443\u043a\u0432\u044b. \u0414\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 lang. \u0421\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 paddleOCR \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c <a href=\"https:\/\/github.com\/PaddlePaddle\/PaddleOCR\" rel=\"noopener noreferrer nofollow\">\u0441\u0430\u0439\u0442\u0435<\/a> \u0438\u043b\u0438 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0448\u044c JSON, c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0438 \u0442.\u0434. <\/p>\n<pre><code class=\"bash\"># \u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 JSON: \"rec_texts\": [         \"WOOD\",         \"JOINING\",         \"AND CHISELING TOOLS\",         \"CUTTING\",         \"ng projeet you\",         \"take on\",         \"W\",         \"hatever\", ... ],<\/code><\/pre>\n<h2>\u042d\u0442\u0430\u043f 2. API \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c<\/h2>\n<p><strong>\u041f\u0440\u043e\u0446\u0435\u0441:\u00a0<\/strong>1. \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u0434 -&gt; 2. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 -&gt; 3. \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 LLM -&gt; 4. \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c -&gt; 5. \u0414\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 -&gt; 6.\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<h3>1. \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u0434<\/h3>\n<pre><code class=\"python\"># ... \u0422\u0423\u0422 \u0414\u041e\u041b\u0416\u0415\u041d \u0411\u042b\u0422\u042c \u041a\u041e\u0414 \u0418\u0417 \u041f\u0415\u0420\u0412\u041e\u0413\u041e \u041f\u0420\u0418\u041c\u0415\u0420\u0410  @app.post(\"\/ocrWithLlm\") async def perform_ocr(file: UploadFile = File(...)):     print(\"IMAGE READING...\")      contents = await file.read()     image = Image.open(io.BytesIO(contents)).convert(\"RGB\")  # Ensure RGB      result = ocr_pdf_paddle(image)     print(\"FILE PREDICTION ENDED\")      if isinstance(result, list) and len(result) &gt; 0:         rec_texts = result[0].get(\"rec_texts\", [])     elif isinstance(result, dict):         rec_texts = result.get(\"rec_texts\", [])     else:         rec_texts = []      print(\"SENDING REQUEST TO OLLAMA...\")     resFromOllama = analyze_ocr_text(rec_texts)     print(\"RESPONSE FROM OLLAMA FETCHED SUCCESSFULLY\")      print(\"SENDING RESPONSE...\")     return JSONResponse(content={'ocrText': rec_texts, 'llmResult': resFromOllama})   def analyze_ocr_text(text: str, model: str = \"ollama\/qwen2:7b\"):     print(\"LLM MODEL IS: \", model)     try:         response = completion(             model=model,             api_base=\"http:\/\/localhost:11434\",  # Ollama address             messages=[                 {\"role\": \"system\", \"content\": \"You are an OCR analyzer. Extract key facts, summarize, and detect language.\"},                 {\"role\": \"system\",                  \"content\": \"Given a text, carefully analyze the text and categorize document into JSON format.\"},                 {\"role\": \"user\", \"content\": f\"Analyze this OCR text:\\n\\n{text}\"}             ],             timeout=60         )         return response.choices[0].message.content     except Exception as e:         return f\"Error: {str(e)}\"<\/code><\/pre>\n<h3>2.\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h3>\n<ul>\n<li>\n<p>\u041f\u043b\u043e\u0449\u0430\u0434\u043a\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 LLM: Ollama \u0438\u043b\u0438 LM Studio<\/p>\n<\/li>\n<li>\n<p>\u041a\u043b\u0438\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 LLM: litellm \u0438\u043b\u0438 OpenAI<\/p>\n<\/li>\n<\/ul>\n<p><em>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Ollama \u0438 litellm. <\/em>Ollama \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0442.\u043a. \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b. <em>\u0415\u0441\u043b\u0438 \u0442\u0435\u0431\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439 LM Studio<\/em>, \u044d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0432 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435.<\/p>\n<h4>\u0430) \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Ollama:<\/h4>\n<p>\u0422\u0443\u0442 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442: 1 \u0447\u0435\u0440\u0435\u0437 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 <a href=\"https:\/\/ollama.com\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0430\u0439\u0442<\/a> \u043b\u0438\u0431\u043e 2 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b.<\/p>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 ollama \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b curl -fsSL https:\/\/ollama.com\/install.sh | sh<\/code><\/pre>\n<h4>\u0431) \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0434\u043b\u044f LLM litelm:<\/h4>\n<pre><code># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 litellm \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b pip install litellm\u00a0 <\/code><\/pre>\n<h3>3. \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 LLM \u0447\u0435\u0440\u0435\u0437 ollama<\/h3>\n<h4>\u0430) \u0432\u044b\u0431\u0440\u0430\u0442\u044c LLM:<\/h4>\n<p>\u041d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435 <a href=\"https:\/\/ollama.com\/search\" rel=\"noopener noreferrer nofollow\">ollama<\/a> \u0441\u0430\u0439\u0442\u0435 \u0432\u044b\u0431\u0435\u0440\u0438 LLM \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0435\u0441\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c qwen:7b, \u0438\u043b\u0438 qwen2:7b \u043e\u043d\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0435\u0433\u043a\u0438\u0435. <\/p>\n<h4>\u0431) \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c ollama:<\/h4>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443\u00a0<\/p>\n<pre><code># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 ollama ollama serve<\/code><\/pre>\n<p>\u041f\u0443\u043d\u043a\u0442\u044b \u0412 \u0438 \u0413 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u043d\u043e\u0432\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u043a\u043d\u0435. <\/p>\n<h4>\u0432) \u0441\u043a\u0430\u0447\u0430\u0442\u044c LLM \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ollama:<\/h4>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439 \u043d\u043e\u0432\u043e\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u0438 \u0434\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f LLM \u0432\u044b\u043f\u043e\u043b\u043d\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443: <\/p>\n<pre><code># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f LLM qwen2:7b ollama pull qwen2:7b<\/code><\/pre>\n<h4>\u0433) \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c LLM \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ollama:<\/h4>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u0442\u0432\u043e\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 ollama: <\/p>\n<pre><code># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 LLM qwen2:7b ollama run qwen2:7b<\/code><\/pre>\n<h4>\u0434) \u043f\u0440\u043e\u0432\u0435\u0440\u044c \u0440\u0430\u0431\u043e\u0442\u0443 LLM:<\/h4>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0443 \u0442\u0435\u0431\u044f \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u043a\u043d\u0430. \u041e\u0434\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 ollama, \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 LLM. \u041d\u0430\u043f\u0438\u0448\u0438 \u0447\u0442\u043e \u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<h3>4. \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c<\/h3>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f # ocr_api_test - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c uvicorn ocr_api_test:app --reload --host 0.0.0.0 --port 8000<\/code><\/pre>\n<h3>5. \u0414\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/h3>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443 curl -X POST \"http:\/\/localhost:8000\/ocrWithLlm\" \\      -F \"file=@\\\"\/yourTestPathDir\/yourTestImageName.png\\\"\" \\      | python -m json.tool<\/code><\/pre>\n<h3>6. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h3>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043e\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 \/ocrWithLlm: <\/p>\n<pre><code class=\"bash\">{   \"categories\": [     \"Wood Joining\",     \"Cutting Tools\",     \"Project Guidance\",     \"Quality of Cuts\",     \"Joint Selection\",     \"Layout and Marking\",     \"Power Tools\",     \"Measuring Tools\"   ],   \"text_content\": {     \"title\": \"WOOD JOINING AND CHISELING TOOLS\",     \"paragraphs\": [       \"Cutting ng project you take on whatever woodwork box ora tne EZE le you'l isa umg The quality of the loints, cutters whether joinifs.\",       \"FE Doveralsaw\\u8679LEXO., N Themou com wihadoren or so. lap.\",       \"gone in this chapter the right joint questions for choosing layout and marking.and results mo.\",       \"You joint tip on for the Miter saw for achieving and power tools. procedures try to be withaw varietyof\",       \"to make Ifyou're new at the yet meets your require and appearance. For Cranked-neck paring chisel selecting joints for spe.\",       \"dific applications, tum to pages 95 to 114; the chapter beginning on page 4I contains infomation on how to use\",       \"the various tools.Keep Comer chisel Skew chesel the basic measuring and marking tools on your workbench you'll he using them often\",       \"For a properly fitted joint, the dimensions must have an accura cy greater than the Morise chitel Bure chisel Thee Netr jnn ig\",       \"graduations on your wth ther soreron cove the masuring tools.Achiey pd ing this precislon may seem impossible but Firmer chisel drg pin fid ad\",       \"mor co Bhin chapr the relative tit of the two in practice its actually the actual stock.\"     ]   },   \"language\": \"English\" }<\/code><\/pre>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a:<\/p>\n<pre><code class=\"python\"># \u0414\u043e\u0431\u0430\u0432\u044c \u043f\u0440\u043e\u0441\u044c\u0431\u0443 \u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a {\"role\": \"user\", \"content\": f\" Translate your answer into Russian language. Analyze this OCR text:\\n\\n{text}\"}<\/code><\/pre>\n<p>\u041e\u0442\u0432\u0435\u0442:<\/p>\n<pre><code class=\"bash\">{   \"category\": \"\u0421\u0435\u0440\u0432\u0438\u0441\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0438 \u0440\u0435\u0437\u043a\u0438 \u0434\u0440\u0435\u0432\u0435\u0441\u0438\u043d\u044b\",   \"text_segments\": [     {       \"header\": \"\u0421\u0415\u0420\u0412\u0418\u0421\u042b \u0421\u041e\u0415\u0414\u0418\u041d\u0415\u041d\u0418\u042f \u0418 \u0420\u0415\u0417\u041a\u0418 \u0414\u0420\u0415\u0412\u0415\u0421\u0418\u041d\u042b\"     },     {       \"sub_header\": \"\u0421\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0431\u0435\u0440\u0435\u0442\u0435 \u043d\u0430 \u0441\u0435\u0431\u044f, \u0432\u0441\u0451, \u0447\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0434\u0435\u0440\u0435\u0432\u043e\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u2014 \u043f\u0440\u043e\u0435\u043a\u0442\u044b, \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u0438\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0435.\"     },     {       \"details\": [         \"\u041a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439\",         \"\u0411\u0443\u0434\u044c \u0442\u043e \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u044f.\"       ]     },     {       \"brands_and_products\": [         {           \"brand\": \"\u0421\u0432\u0435\u0440\u043b\u0435\u043d\u0438\u0435 Saw\",           \"model\": \"Lexo.\"         },         {           \"note\": \"\u0414\u043b\u044f \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u0432 \u0434\u0435\u0440\u0435\u0432\u0430, \u0441 \u0441\u043e\u0432\u0435\u0442\u0430\u043c\u0438 \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438. \u041b\u0430\u043f.\"         }       ]     },     {       \"info_chapter\": [         \"\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u0438 \u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u043a\u0438.\",         \"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u0438 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440.\"       ]     },     {       \"layout_and_tools\": [         {           \"note\": \"\u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0443\u043c\u043d\u043e\",           \"tools_information\": \"\u0421\u0445\u0435\u043c\u0430 \u0438 \u043c\u0435\u0442\u043e\u0447\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b.\"         }       ]     },     {       \"power_tools_section\": [         {           \"tool_type\": \"\u041c\u0438\u0442\u0435\u0440 saw\"         },         {           \"note\": \"\u0414\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0449\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432.\"         }       ]     },     {       \"tutorials_chapter\": [         {           \"page_numbers\": [\"95 to 114\"],           \"content\": \"\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b.\"         },         {           \"note\": \"\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 4I \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b.\"         }       ]     },     {       \"measuring_tools_notes\": [         {           \"note\": \"\u0425\u0440\u0430\u043d\u0438\u0442\u0435 \u0438\u0437\u043c\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438 \u043c\u0435\u0442\u043e\u0447\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u0441\u0432\u043e\u0451\u043c \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u0441\u0442\u043e\u043b\u0435: \u0432\u044b \u0447\u0430\u0441\u0442\u043e \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.\"         },         {           \"tip_for_joints\": \"\u0414\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043e\u0433\u043d\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0443\u044e, \u0447\u0435\u043c \u0434\u0440\u0435\u0432\u0435\u0441\u0438\u043d\u0430.\"         }       ]     }   ] }<\/code><\/pre>\n<h2>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430<\/h2>\n<h4>1. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u043c\u0438 \u0438 \u0442\u0435\u043a\u0441\u0442\u0430\u043c\u0438<\/h4>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8f2\/8a5\/464\/8f28a54642f4b5fc16e73c056f7b4859.png\" alt=\"\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f\" title=\"\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f\" width=\"2108\" height=\"1380\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/8f2\/8a5\/464\/8f28a54642f4b5fc16e73c056f7b4859.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8f2\/8a5\/464\/8f28a54642f4b5fc16e73c056f7b4859.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f<\/figcaption><\/div>\n<\/figure>\n<h4>2. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u043c\u0438 \u0438 \u0442\u0435\u043a\u0441\u0442\u0430\u043c\u0438<\/h4>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3f2\/81c\/eba\/3f281ceba44a3f75c6736574425faede.png\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438\" width=\"2950\" height=\"965\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/3f2\/81c\/eba\/3f281ceba44a3f75c6736574425faede.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3f2\/81c\/eba\/3f281ceba44a3f75c6736574425faede.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438<\/figcaption><\/div>\n<\/figure>\n<h4>3. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u0442 Paddle OCR<\/h4>\n<pre><code class=\"bash\">... \"rec_texts\": [         \"\u0407\u041c\u0438\u0425\u042f\u0438\u0419 \u0422\u0438\u04389\u0424\u0415\u0415\u0411\u0418\u0427\",         \"\u0417\u0430\u0433\u043e\u0440\u043e\u0434\u043d\u044b\u0439 \u0434\u043e\u043c\",         \"\u043f\u0440\u0435\u043e\u0411\u0440\u042f\u0436\u0435\u041d\u0441\u041a\u0418\u0439\",         \"\u043d \u0434\u0435\u0442\u0430\u043b\u0438 \u043a \u043d\u0435\u043c\u0443\",         \"\u0410\u0440\u0445. \u041c. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0441\u043a\u0438\u0438\",         \"1860 70R\",         \"\u041f\u0440\u0430\u0437\u0434\u043d\u0438\u0447\u043d\u044b\u0439 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u0441\u0442\u0438\u043b\u044c \u043f\u0440\u0438\u0442\u044f\u0433\u0438\u0432\u0430\u043b \u043a \u0441\u0435\u0431\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e-\",         \"\u0440\u043e\u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u043e\u0432 \u0438 \u0443\u0441\u0442\u0440\u0435\u043c\u043b\u0435\u043d\u0438\u0439. \u0422\u0430\u043a\u0438\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a\",         \"\u043c\u043e\u043b\u043e\u0434\u043e\u0439 \u041c.\u0422. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0441\u043a\u0438\u0439 (1854\u20141930). \u0442\u043e\u0433\u0434\u0430 \u0435\u0449\u0435\",         \"\u0441\u0442\u0443\u0434\u0435\u043d\u0442 \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u043e\u0433\u043e \u0443\u0447\u0438\u043b\u0438\u0448\u0430 \u0436\u0438\u0432\u043e\u043f\u0438\u0441\u0438. \u0432\u0430\u044f\u043d\u0438\u044f \u0438 \u0437\u043e\u0434\u0447\u0435-\",         \"\u0441\u0442\u0432\u0430 \u0438 \u041f\u0435\u0442\u0435\u0440\u0431\u0443\u0440\u0433\u0441\u043a\u043e\u0439 \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0438 \u0445\u0443\u0434\u043e\u0436\u0435\u0441\u0442\u0432. \u0410 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u2014\",         \"\u043c\u0430\u0441\u0442\u0438\u0442\u044b\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440. \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u043e\u0440 \u0410\u043a\u0430\u0434\u0435\u043c\u0438\u0438, \u043a\u0440\u0443\u043f\u043d\u0435\u0439\u0448\u0438\u0439\",         \"\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442 \u043f\u043e \u0440\u0435\u0441\u0442\u0430\u0432\u0440\u0430\u0448\u0438\u0438. \u041b\u044e\u0431\u043e\u0432\u044c \u043a \u0438\u0441\u0442\u043e\u0440\u0438\u0438, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0432-\",         \"\u0448\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u0441\u0442\u0438\u043b\u044f, \u043f\u0440\u0438\u0432\u0435\u043b\u0430 \u0435\u0433\u043e \u0432 \u0438\u043c\u043f\u0435\u0440\u0430-\",         \"\u0442\u043e\u0440\u0441\u043a\u0443\u044e \u0410\u0440\u0445\u0435\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u044e, \u0447\u043b\u0435\u043d\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d\",         \"\u0431\u044b\u043b \u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u0415\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0430 \u0441\u043e-\",         \"\u0445\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0431\u0435\u0441\u0446\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u043c\u044f\u0442\u043d\u0438\u043a\u043e\u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b: \u0413\u0435\u043d\u0443\u044d\u0437\u0441\u043a\u043e\u0439\",         \"\u0441\u0442\u0435\u043d\u044b \u0432 \u0424\u0435\u043e\u0434\u043e\u0441\u0438\u0438, \u043f\u0441\u043a\u043e\u0432\u0441\u043a\u0438\u0445 \u041f\u043e\u0433\u0430\u043d\u043a\u0438\u043d\u044b\u0445 \u043f\u0430\u043b\u0430\u0442. \u0421\u043c\u043e\u043b\u0435\u043d-\",         \"\u0441\u043a\u043e\u0439 \u043a\u0440\u0435\u043f\u043e\u0441\u0442\u043d\u043e\u0439 \u0441\u0442\u0435\u043d\u044b. \u0418\u0441\u0430\u0430\u043a\u0438\u0435\u0432\u0441\u043a\u043e\u0433\u043e \u0441\u043e\u0431\u043e\u0440\u0430 \u0432 \u041f\u0435\u0442\u0435\u0440\u0431\u0443\u0440-\",         \"\u0433\u0435. \u0421\u043e\u0444\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0441\u043e\u0431\u043e\u0440\u0430 \u0432 \u041d\u043e\u0432\u0433\u043e\u0440\u043e\u0434\u0435.\"     ], ...<\/code><\/pre>\n<h2>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b<\/h2>\n<p>\u041e Paddle OCR:  <a href=\"https:\/\/habr.com\/ru\/companies\/jetinfosystems\/articles\/660405\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/companies\/jetinfosystems\/articles\/660405\/<\/a><\/p>\n<p>\u041e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 ollama \u0447\u0435\u0440\u0435\u0440\u0437 UI: <a href=\"https:\/\/habr.com\/ru\/articles\/879076\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/articles\/879076\/<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/933634\/\"> https:\/\/habr.com\/ru\/articles\/933634\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\">\n<div><figcaption>\u041a\u0430\u0434\u0440 \u0438\u0437 \u0444\u0438\u043b\u044c\u043c\u0430 \u0434\u0432\u0443\u0445\u0441\u043e\u0442\u043b\u0435\u0442\u043d\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0438 \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c.\u00a0<\/p>\n<h2>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<ul>\n<li>\n<p>\u042f\u0437\u044b\u043a: <strong><em>Python<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0421\u0438\u043c\u0432\u043e\u043b\u043e\u0432(OCR): <strong><em>Paddle OCR<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u043e\u0449\u0430\u0434\u043a\u0430 \u0434\u043b\u044f \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438: <strong><em>Ollama<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p>\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u044f\u0437\u044b\u043a\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c(LLM): <strong><em>qwen2:7b<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p>\u0421\u0435\u0442\u0435\u0432\u043e\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f API: <strong><em>FastAPI<\/em><\/strong><\/p>\n<\/li>\n<\/ul>\n<h2>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/h2>\n<figure class=\"full-width\">\n<div><figcaption>\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/figcaption><\/div>\n<\/figure>\n<h2>\u042d\u0442\u0430\u043f\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<ol>\n<li>\n<p>API \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>API \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c<\/p>\n<\/li>\n<\/ol>\n<h2>\u042d\u0442\u0430\u043f 1. API \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p><strong>\u041f\u0440\u043e\u0446\u0435\u0441:<\/strong> 1.\u00a0\u0421\u043e\u0437\u0434\u0430\u0451\u043c\u00a0\u043a\u043e\u0434 -&gt; 2.\u00a0\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u00a0\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 -&gt; 3.\u00a0\u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c\u00a0\u0441\u0435\u0440\u0432\u0435\u0440 -&gt; 4.\u00a0\u0414\u0435\u043b\u0430\u0435\u043c\u00a0\u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 -&gt; 5.\u00a0\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u00a0\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<h3>1. \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u0434<\/h3>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u0436\u0435\u043b\u0435\u0437\u043e \u043c\u0430\u0448\u0438\u043d\u044b \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0441 \u0440\u0430\u0431\u043e\u0442\u043e\u0439, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0436\u0438\u043c\u0430\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f <em>COMPRESS_SCALE <\/em>\u0442\u0435\u0431\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u0441\u0432\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0448\u044c.<\/p>\n<pre><code class=\"python\">import numpy as np from fastapi import FastAPI, File, UploadFile from fastapi.responses import JSONResponse from paddleocr import PaddleOCR from PIL import Image import io  app = FastAPI(     title=\"PaddleOCR API\",     description=\"A simple API for OCR using PaddleOCR\",     version=\"1.0.0\" )  ocr = PaddleOCR(     use_doc_orientation_classify=False,     use_doc_unwarping=False,     use_textline_orientation=False )  def ocr_pdf_paddle(image):     print(\"START COMPRESSING...\")     COMPRESS_SCALE = 0.5     width, height = image.size     new_size = (int(width * COMPRESS_SCALE), int(height * COMPRESS_SCALE))     img_resized = image.resize(new_size, Image.LANCZOS)     image_array = np.array(img_resized)      print(\"START PREDICTION...\")     page_text = ocr.predict(image_array)      return page_text  @app.post(\"\/ocr\") async def perform_ocr(file: UploadFile = File(...)):     print(\"IMAGE READING...\")      contents = await file.read()     image = Image.open(io.BytesIO(contents)).convert(\"RGB\")  # Ensure RGB      # Perform OCR     result = ocr_pdf_paddle(image)     print(\"FILE PREDICTION ENDED\")      if isinstance(result, list) and len(result) &gt; 0:         rec_texts = result[0].get(\"rec_texts\", [])     elif isinstance(result, dict):         rec_texts = result.get(\"rec_texts\", [])     else:         rec_texts = []      print(\"SENDING RESPONSE...\")     return JSONResponse(content=rec_texts) <\/code><\/pre>\n<h3>2. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h3>\n<h4>\u0430) \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Paddlepaddle:\u00a0<\/h4>\n<p>\u041b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 <a href=\"https:\/\/www.paddlepaddle.org.cn\/en\/install\/quick?docurl=undefined\" rel=\"noopener noreferrer nofollow\">\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439<\/a>\u00a0\u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c <a href=\"https:\/\/www.paddlepaddle.org.cn\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0430\u0439\u0442\u0435<\/a><\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 paddlepaddle \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0430\u043c\u044b\u043c \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442.\u043a. \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0432\u043e\u0435 \u0436\u0435\u043b\u0435\u0437\u043e, \u0441 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 paddlepaddle. \u0422\u043e-\u0435\u0441\u0442\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f.\u00a0<\/p>\n<p><strong><em>\u041e\u0431\u043d\u0430\u0440\u0443\u0436\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0441\u0432\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b:<\/em><\/strong><\/p>\n<ul>\n<li>\n<p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430<\/p>\n<\/li>\n<li>\n<p>\u0416\u0435\u043b\u0435\u0437\u043e: \u0422\u0438\u043f \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u044b \u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430(GPU): \u0432\u0435\u0440\u0441\u0438\u044e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430(GPU): \u0412\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0436\u0435\u043b\u0435\u0437\u043e\u043c (\u0421UDA, ArmV8 \u0438 \u0442\u0434 )\u00a0<\/p>\n<\/li>\n<\/ul>\n<p><strong><em>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e:<\/em><\/strong> \u0443\u0431\u0435\u0434\u0438\u0441\u044c, \u0447\u0442\u043e \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0436\u0435\u043b\u0435\u0437\u0430(\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430) \u0438 \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0436\u0435\u043b\u0435\u0437\u043e\u043c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b.\u00a0<\/p>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0442\u0432\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b, \u043f\u043e\u0434\u0431\u0435\u0440\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 paddlepaddle \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435 paddlepaddle.<\/p>\n<h4>\u0431) \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Paddle OCR:<\/h4>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 pip install paddleocr<\/code><\/pre>\n<p>\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a Paddle OCR: <a href=\"https:\/\/github.com\/PaddlePaddle\/PaddleOCR\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/PaddlePaddle\/PaddleOCR<\/a><\/p>\n<h4>\u0432) \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 FastAPI:\u00a0<\/h4>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 pip install fastapi<\/code><\/pre>\n<h3>3. \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440:<\/h3>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f # ocr_api_test - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c uvicorn ocr_api_test:app --reload --host 0.0.0.0 --port 8000<\/code><\/pre>\n<h3>4. \u0414\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/h3>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443 curl -X POST \"http:\/\/localhost:8000\/ocr\" \\      -F \"file=@\\\"\/yourTestPathDir\/yourTestImageName.png\\\"\" \\      | python -m json.tool<\/code><\/pre>\n<p><strong><em>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441 Paddle OCR:<\/em><\/strong><\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0443\u043f\u0430\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u0434\u043b\u044f \u0436\u0435\u043b\u0435\u0437\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439 \u0441\u0436\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u043d\u0442, \u0447\u0442\u043e \u0431\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u0436\u0435\u043b\u0435\u0437\u0430 \u0445\u0432\u0430\u0442\u0438\u043b\u043e \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h3>5. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h3>\n<h4>\u0430) \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435<\/h4>\n<pre><code class=\"python\"># ... \u0422\u0423\u0422 \u041a\u041e\u0414 \u0418\u0417 API \u041c\u0415\u0422\u041e\u0414\u0410 result = ocr_pdf_paddle(image)  # \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f  # \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 outputDirPath = \"\/yourRootPath\/yourOutputDirPath\" for res in result:   result_base = os.path.join(outputDirPath)   res.save_to_img(result_base)  # e.g., page_1_result.jpg   res.save_to_json(result_base)  # e.g., page_1_result.json<\/code><\/pre>\n<h4>\u0431) \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <\/h4>\n<figure class=\"full-width\">\n<div><figcaption>\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438<\/figcaption><\/div>\n<\/figure>\n<p><em>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e: <\/em><\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e PaddleOCR \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043b \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0435, \u043d\u043e \u0438 \u043a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0435 \u0431\u0443\u043a\u0432\u044b. \u0414\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 lang. \u0421\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 paddleOCR \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c <a href=\"https:\/\/github.com\/PaddlePaddle\/PaddleOCR\" rel=\"noopener noreferrer nofollow\">\u0441\u0430\u0439\u0442\u0435<\/a> \u0438\u043b\u0438 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0448\u044c JSON, c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0438 \u0442.\u0434. <\/p>\n<pre><code class=\"bash\"># \u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 JSON: \"rec_texts\": [         \"WOOD\",         \"JOINING\",         \"AND CHISELING TOOLS\",         \"CUTTING\",         \"ng projeet you\",         \"take on\",         \"W\",         \"hatever\", ... ],<\/code><\/pre>\n<h2>\u042d\u0442\u0430\u043f 2. API \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c<\/h2>\n<p><strong>\u041f\u0440\u043e\u0446\u0435\u0441:\u00a0<\/strong>1. \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u0434 -&gt; 2. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 -&gt; 3. \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 LLM -&gt; 4. \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c -&gt; 5. \u0414\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 -&gt; 6.\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<h3>1. \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u0434<\/h3>\n<pre><code class=\"python\"># ... \u0422\u0423\u0422 \u0414\u041e\u041b\u0416\u0415\u041d \u0411\u042b\u0422\u042c \u041a\u041e\u0414 \u0418\u0417 \u041f\u0415\u0420\u0412\u041e\u0413\u041e \u041f\u0420\u0418\u041c\u0415\u0420\u0410  @app.post(\"\/ocrWithLlm\") async def perform_ocr(file: UploadFile = File(...)):     print(\"IMAGE READING...\")      contents = await file.read()     image = Image.open(io.BytesIO(contents)).convert(\"RGB\")  # Ensure RGB      result = ocr_pdf_paddle(image)     print(\"FILE PREDICTION ENDED\")      if isinstance(result, list) and len(result) &gt; 0:         rec_texts = result[0].get(\"rec_texts\", [])     elif isinstance(result, dict):         rec_texts = result.get(\"rec_texts\", [])     else:         rec_texts = []      print(\"SENDING REQUEST TO OLLAMA...\")     resFromOllama = analyze_ocr_text(rec_texts)     print(\"RESPONSE FROM OLLAMA FETCHED SUCCESSFULLY\")      print(\"SENDING RESPONSE...\")     return JSONResponse(content={'ocrText': rec_texts, 'llmResult': resFromOllama})   def analyze_ocr_text(text: str, model: str = \"ollama\/qwen2:7b\"):     print(\"LLM MODEL IS: \", model)     try:         response = completion(             model=model,             api_base=\"http:\/\/localhost:11434\",  # Ollama address             messages=[                 {\"role\": \"system\", \"content\": \"You are an OCR analyzer. Extract key facts, summarize, and detect language.\"},                 {\"role\": \"system\",                  \"content\": \"Given a text, carefully analyze the text and categorize document into JSON format.\"},                 {\"role\": \"user\", \"content\": f\"Analyze this OCR text:\\n\\n{text}\"}             ],             timeout=60         )         return response.choices[0].message.content     except Exception as e:         return f\"Error: {str(e)}\"<\/code><\/pre>\n<h3>2.\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h3>\n<ul>\n<li>\n<p>\u041f\u043b\u043e\u0449\u0430\u0434\u043a\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 LLM: Ollama \u0438\u043b\u0438 LM Studio<\/p>\n<\/li>\n<li>\n<p>\u041a\u043b\u0438\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 LLM: litellm \u0438\u043b\u0438 OpenAI<\/p>\n<\/li>\n<\/ul>\n<p><em>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Ollama \u0438 litellm. <\/em>Ollama \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0442.\u043a. \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b. <em>\u0415\u0441\u043b\u0438 \u0442\u0435\u0431\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439 LM Studio<\/em>, \u044d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0432 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435.<\/p>\n<h4>\u0430) \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Ollama:<\/h4>\n<p>\u0422\u0443\u0442 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442: 1 \u0447\u0435\u0440\u0435\u0437 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 <a href=\"https:\/\/ollama.com\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0430\u0439\u0442<\/a> \u043b\u0438\u0431\u043e 2 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b.<\/p>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 ollama \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b curl -fsSL https:\/\/ollama.com\/install.sh | sh<\/code><\/pre>\n<h4>\u0431) \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0434\u043b\u044f LLM litelm:<\/h4>\n<pre><code># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 litellm \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b pip install litellm\u00a0 <\/code><\/pre>\n<h3>3. \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 LLM \u0447\u0435\u0440\u0435\u0437 ollama<\/h3>\n<h4>\u0430) \u0432\u044b\u0431\u0440\u0430\u0442\u044c LLM:<\/h4>\n<p>\u041d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435 <a href=\"https:\/\/ollama.com\/search\" rel=\"noopener noreferrer nofollow\">ollama<\/a> \u0441\u0430\u0439\u0442\u0435 \u0432\u044b\u0431\u0435\u0440\u0438 LLM \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0435\u0441\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c qwen:7b, \u0438\u043b\u0438 qwen2:7b \u043e\u043d\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0435\u0433\u043a\u0438\u0435. <\/p>\n<h4>\u0431) \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c ollama:<\/h4>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443\u00a0<\/p>\n<pre><code># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 ollama ollama serve<\/code><\/pre>\n<p>\u041f\u0443\u043d\u043a\u0442\u044b \u0412 \u0438 \u0413 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u043d\u043e\u0432\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u043a\u043d\u0435. <\/p>\n<h4>\u0432) \u0441\u043a\u0430\u0447\u0430\u0442\u044c LLM \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ollama:<\/h4>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439 \u043d\u043e\u0432\u043e\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u0438 \u0434\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f LLM \u0432\u044b\u043f\u043e\u043b\u043d\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443: <\/p>\n<pre><code># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f LLM qwen2:7b ollama pull qwen2:7b<\/code><\/pre>\n<h4>\u0433) \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c LLM \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ollama:<\/h4>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u0442\u0432\u043e\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 ollama: <\/p>\n<pre><code># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 LLM qwen2:7b ollama run qwen2:7b<\/code><\/pre>\n<h4>\u0434) \u043f\u0440\u043e\u0432\u0435\u0440\u044c \u0440\u0430\u0431\u043e\u0442\u0443 LLM:<\/h4>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0443 \u0442\u0435\u0431\u044f \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u043a\u043d\u0430. \u041e\u0434\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 ollama, \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 LLM. \u041d\u0430\u043f\u0438\u0448\u0438 \u0447\u0442\u043e \u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<h3>4. \u0421\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c<\/h3>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f # ocr_api_test - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c uvicorn ocr_api_test:app --reload --host 0.0.0.0 --port 8000<\/code><\/pre>\n<h3>5. \u0414\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/h3>\n<pre><code class=\"bash\"># \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443 curl -X POST \"http:\/\/localhost:8000\/ocrWithLlm\" \\      -F \"file=@\\\"\/yourTestPathDir\/yourTestImageName.png\\\"\" \\      | python -m json.tool<\/code><\/pre>\n<h3>6. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h3>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043e\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 \/ocrWithLlm: <\/p>\n<pre><code class=\"bash\">{   \"categories\": [     \"Wood Joining\",     \"Cutting Tools\",     \"Project Guidance\",     \"Quality of Cuts\",     \"Joint Selection\",     \"Layout and Marking\",     \"Power Tools\",     \"Measuring Tools\"   ],   \"text_content\": {     \"title\": \"WOOD JOINING AND CHISELING TOOLS\",     \"paragraphs\": [       \"Cutting ng project you take on whatever woodwork box ora tne EZE le you'l isa umg The quality of the loints, cutters whether joinifs.\",       \"FE Doveralsaw\\u8679LEXO., N Themou com wihadoren or so. lap.\",       \"gone in this chapter the right joint questions for choosing layout and marking.and results mo.\",       \"You joint tip on for the Miter saw for achieving and power tools. procedures try to be withaw varietyof\",       \"to make Ifyou're new at the yet meets your require and appearance. For Cranked-neck paring chisel selecting joints for spe.\",       \"dific applications, tum to pages 95 to 114; the chapter <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-469593","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/469593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=469593"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/469593\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=469593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=469593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=469593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}