|
|
@@ -1,22 +1,22 @@
|
|
|
[简体中文](seal_recognition.md) | English
|
|
|
-
|
|
|
-# Tutorial for Using Seal Text Recognition Pipeline
|
|
|
-
|
|
|
-## 1. Introduction to the Seal Text Recognition Pipeline
|
|
|
-Seal text recognition is a technology that automatically extracts and recognizes seal content from documents or images. The recognition of seal text is part of document processing and has various applications in many scenarios, such as contract comparison, inventory access approval, and invoice reimbursement approval.
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-The **Seal Text Recognition** pipeline includes a layout area analysis module, a seal text detection module, and a text recognition module.
|
|
|
-
|
|
|
-**If you prioritize model accuracy, please choose a model with higher accuracy. If you prioritize inference speed, please choose a model with faster inference. If you prioritize model storage size, please choose a model with a smaller storage footprint.**
|
|
|
-
|
|
|
-<details>
|
|
|
- <summary> 👉 Detailed Model List </summary>
|
|
|
-
|
|
|
+
|
|
|
+# Tutorial for Using Seal Text Recognition Pipeline
|
|
|
+
|
|
|
+## 1. Introduction to the Seal Text Recognition Pipeline
|
|
|
+Seal text recognition is a technology that automatically extracts and recognizes seal content from documents or images. The recognition of seal text is part of document processing and has various applications in many scenarios, such as contract comparison, inventory access approval, and invoice reimbursement approval.
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+The **Seal Text Recognition** pipeline includes a layout area analysis module, a seal text detection module, and a text recognition module.
|
|
|
+
|
|
|
+**If you prioritize model accuracy, please choose a model with higher accuracy. If you prioritize inference speed, please choose a model with faster inference. If you prioritize model storage size, please choose a model with a smaller storage footprint.**
|
|
|
+
|
|
|
+<details>
|
|
|
+ <summary> 👉 Detailed Model List </summary>
|
|
|
+
|
|
|
|
|
|
**Layout Analysis Module Models:**
|
|
|
-
|
|
|
+
|
|
|
|Model Name|mAP (%)|GPU Inference Time (ms)|CPU Inference Time|Model Size (M)|
|
|
|
|-|-|-|-|-|
|
|
|
|PicoDet-L_layout_3cls|89.3|15.7425|159.771|22.6 M|
|
|
|
@@ -45,7 +45,7 @@ The **Seal Text Recognition** pipeline includes a layout area analysis module, a
|
|
|
|
|
|
**Note: The evaluation set for the above accuracy indicators is a self-built Chinese dataset from PaddleOCR, covering various scenarios such as street scenes, web images, documents, and handwriting. The text recognition subset includes 11,000 images. The GPU inference time for all models above is based on an NVIDIA Tesla T4 machine with a precision type of FP32. The CPU inference speed is based on an Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz with 8 threads, and the precision type is also FP32.**
|
|
|
|
|
|
-</details>
|
|
|
+</details>
|
|
|
|
|
|
## 2. Quick Start
|
|
|
The pre trained model production line provided by PaddleX can quickly experience the effect. You can experience the effect of the seal text recognition production line online, or use the command line or Python locally to experience the effect of the seal text recognition production line.
|
|
|
@@ -64,7 +64,7 @@ Before using the seal text recognition production line locally, please ensure th
|
|
|
One command can quickly experience the effect of seal text recognition production line, use [test file](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/seal_text_det.png), and replace ` --input ` with the local path for prediction
|
|
|
|
|
|
```
|
|
|
-paddlex --pipeline seal_recognition --input seal_text_det.png --device gpu:0 --save_path output
|
|
|
+paddlex --pipeline seal_recognition --input seal_text_det.png --device gpu:0 --save_path output
|
|
|
```
|
|
|
|
|
|
Parameter description:
|
|
|
@@ -87,13 +87,13 @@ paddlex --get_pipeline_config seal_recognition
|
|
|
After execution, the seal text recognition production line configuration file will be saved in the current path. If you want to customize the save location, you can execute the following command (assuming the custom save location is `./my_path `):
|
|
|
|
|
|
```bash
|
|
|
-paddlex --get_pipeline_config seal_recognition --save_path ./my_path --save_path output
|
|
|
+paddlex --get_pipeline_config seal_recognition --save_path ./my_path --save_path output
|
|
|
```
|
|
|
|
|
|
After obtaining the production line configuration file, you can replace '-- pipeline' with the configuration file save path to make the configuration file effective. For example, if the configuration file save path is `/ seal_recognition.yaml`, Just need to execute:
|
|
|
|
|
|
```bash
|
|
|
-paddlex --pipeline ./seal_recognition.yaml --input seal_text_det.png --save_path output
|
|
|
+paddlex --pipeline ./seal_recognition.yaml --input seal_text_det.png --save_path output
|
|
|
```
|
|
|
Among them, parameters such as `--model` and `--device` do not need to be specified and will use the parameters in the configuration file. If the parameters are still specified, the specified parameters will prevail.
|
|
|
|
|
|
@@ -217,7 +217,7 @@ After running, the result obtained is:
|
|
|
|
|
|

|
|
|
|
|
|
-The visualized image not saved by default. You can customize the save path through `--save_path`, and then all results will be saved in the specified path.
|
|
|
+The visualized image not saved by default. You can customize the save path through `--save_path`, and then all results will be saved in the specified path.
|
|
|
|
|
|
|
|
|
### 2.2 Python Script Integration
|
|
|
@@ -230,7 +230,7 @@ pipeline = create_pipeline(pipeline="seal_recognition")
|
|
|
|
|
|
output = pipeline.predict("seal_text_det.png")
|
|
|
for res in output:
|
|
|
- res.print()
|
|
|
+ res.print()
|
|
|
res.save_to_img("./output/") # Save the results in img
|
|
|
```
|
|
|
|
|
|
@@ -292,9 +292,442 @@ In addition, PaddleX also offers three other deployment methods, detailed as fol
|
|
|
|
|
|
☁️ ** Service deployment * *: Service deployment is a common form of deployment in actual production environments. By encapsulating inference functions as services, clients can access these services through network requests to obtain inference results. PaddleX supports users to achieve service-oriented deployment of production lines at low cost. For detailed service-oriented deployment processes, please refer to the PaddleX Service Deployment Guide (../../../ipeline_deploy/service_deploy. md).
|
|
|
|
|
|
-Here are API references and examples of calling multilingual services:
|
|
|
+Below are the API references and multi-language service invocation examples:
|
|
|
+
|
|
|
+<details>
|
|
|
+<summary>API Reference</summary>
|
|
|
+
|
|
|
+For all operations provided by the service:
|
|
|
+
|
|
|
+- Both the response body and the request body for POST requests are JSON data (JSON objects).
|
|
|
+- When the request is processed successfully, the response status code is `200`, and the response body properties are as follows:
|
|
|
+
|
|
|
+ | Name | Type | Description |
|
|
|
+ |------|------|-------------|
|
|
|
+ |`errorCode`|`integer`|Error code. Fixed as `0`.|
|
|
|
+ |`errorMsg`|`string`|Error message. Fixed as `"Success"`.|
|
|
|
+
|
|
|
+ The response body may also have a `result` property of type `object`, which stores the operation result information.
|
|
|
+
|
|
|
+- When the request is not processed successfully, the response body properties are as follows:
|
|
|
+
|
|
|
+ | Name | Type | Description |
|
|
|
+ |------|------|-------------|
|
|
|
+ |`errorCode`|`integer`|Error code. Same as the response status code.|
|
|
|
+ |`errorMsg`|`string`|Error message.|
|
|
|
+
|
|
|
+Operations provided by the service:
|
|
|
+
|
|
|
+- **`infer`**
|
|
|
+
|
|
|
+ Obtain seal text recognition results from an image.
|
|
|
+
|
|
|
+ `POST /seal-recognition`
|
|
|
+
|
|
|
+ - Request body properties:
|
|
|
+
|
|
|
+ | Name | Type | Description | Required |
|
|
|
+ |------|------|-------------|----------|
|
|
|
+ |`image`|`string`|The URL of an image file accessible by the service or the Base64 encoded result of the image file content.|Yes|
|
|
|
+ |`inferenceParams`|`object`|Inference parameters.|No|
|
|
|
+
|
|
|
+ Properties of `inferenceParams`:
|
|
|
+
|
|
|
+ | Name | Type | Description | Required |
|
|
|
+ |------|------|-------------|----------|
|
|
|
+ |`maxLongSide`|`integer`|During inference, if the length of the longer side of the input image for the text detection model is greater than `maxLongSide`, the image will be scaled so that the length of the longer side equals `maxLongSide`.|No|
|
|
|
+
|
|
|
+ - When the request is processed successfully, the `result` of the response body has the following properties:
|
|
|
+
|
|
|
+ | Name | Type | Description |
|
|
|
+ |------|------|-------------|
|
|
|
+ |`sealImpressions`|`array`|Seal text recognition results.|
|
|
|
+ |`layoutImage`|`string`|Layout area detection result image. The image is in JPEG format and encoded using Base64.|
|
|
|
+
|
|
|
+ Each element in `sealImpressions` is an `object` with the following properties:
|
|
|
+
|
|
|
+ | Name | Type | Description |
|
|
|
+ |------|------|-------------|
|
|
|
+ |`poly`|`array`|Text position. Elements in the array are the vertex coordinates of the polygon enclosing the text.|
|
|
|
+ |`text`|`string`|Text content.|
|
|
|
+ |`score`|`number`|Text recognition score.|
|
|
|
+
|
|
|
+</details>
|
|
|
+
|
|
|
+<details>
|
|
|
+<summary>Multi-Language Service Invocation Examples</summary>
|
|
|
+
|
|
|
+<details>
|
|
|
+<summary>Python</summary>
|
|
|
+
|
|
|
+```python
|
|
|
+import base64
|
|
|
+import requests
|
|
|
+
|
|
|
+API_URL = "http://localhost:8080/seal-recognition"
|
|
|
+image_path = "./demo.jpg"
|
|
|
+layout_image_path = "./layout.jpg"
|
|
|
+
|
|
|
+with open(image_path, "rb") as file:
|
|
|
+ image_bytes = file.read()
|
|
|
+ image_data = base64.b64encode(image_bytes).decode("ascii")
|
|
|
+
|
|
|
+payload = {"image": image_data}
|
|
|
+
|
|
|
+response = requests.post(API_URL, json=payload)
|
|
|
+
|
|
|
+assert response.status_code == 200
|
|
|
+result = response.json()["result"]
|
|
|
+with open(layout_image_path, "wb") as file:
|
|
|
+ file.write(base64.b64decode(result["layoutImage"]))
|
|
|
+print(f"Output image saved at {layout_image_path}")
|
|
|
+print("\nDetected seal impressions:")
|
|
|
+print(result["sealImpressions"])
|
|
|
+```
|
|
|
+
|
|
|
+</details>
|
|
|
+
|
|
|
+<details>
|
|
|
+<summary>C++</summary>
|
|
|
+
|
|
|
+```cpp
|
|
|
+#include <iostream>
|
|
|
+#include "cpp-httplib/httplib.h" // https://github.com/Huiyicc/cpp-httplib
|
|
|
+#include "nlohmann/json.hpp" // https://github.com/nlohmann/json
|
|
|
+#include "base64.hpp" // https://github.com/tobiaslocker/base64
|
|
|
+
|
|
|
+int main() {
|
|
|
+ httplib::Client client("localhost:8080");
|
|
|
+ const std::string imagePath = "./demo.jpg";
|
|
|
+ const std::string layoutImagePath = "./layout.jpg";
|
|
|
+
|
|
|
+ httplib::Headers headers = {
|
|
|
+ {"Content-Type", "application/json"}
|
|
|
+ };
|
|
|
+
|
|
|
+ std::ifstream file(imagePath, std::ios::binary | std::ios::ate);
|
|
|
+ std::streamsize size = file.tellg();
|
|
|
+ file.seekg(0, std::ios::beg);
|
|
|
+
|
|
|
+ std::vector<char> buffer(size);
|
|
|
+ if (!file.read(buffer.data(), size)) {
|
|
|
+ std::cerr << "Error reading file." << std::endl;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ std::string bufferStr(reinterpret_cast<const char*>(buffer.data()), buffer.size());
|
|
|
+ std::string encodedImage = base64::to_base64(bufferStr);
|
|
|
+
|
|
|
+ nlohmann::json jsonObj;
|
|
|
+ jsonObj["image"] = encodedImage;
|
|
|
+ std::string body = jsonObj.dump();
|
|
|
+
|
|
|
+ auto response = client.Post("/seal-recognition", headers, body, "application/json");
|
|
|
+ if (response && response->status == 200) {
|
|
|
+ nlohmann::json jsonResponse = nlohmann::json::parse(response->body);
|
|
|
+ auto result = jsonResponse["result"];
|
|
|
+
|
|
|
+ encodedImage = result["layoutImage"];
|
|
|
+ decodedString = base64::from_base64(encodedImage);
|
|
|
+ std::vector<unsigned char> decodedLayoutImage(decodedString.begin(), decodedString.end());
|
|
|
+ std::ofstream outputLayoutFile(layoutImagePath, std::ios::binary | std::ios::out);
|
|
|
+ if (outputLayoutFile.is_open()) {
|
|
|
+ outputLayoutFile.write(reinterpret_cast<char*>(decodedLayoutImage.data()), decodedLayoutImage.size());
|
|
|
+ outputLayoutFile.close();
|
|
|
+ std::cout << "Output image saved at " << layoutImagePath << std::endl;
|
|
|
+ } else {
|
|
|
+ std::cerr << "Unable to open file for writing: " << layoutImagePath << std::endl;
|
|
|
+ }
|
|
|
+
|
|
|
+ auto impressions = result["sealImpressions"];
|
|
|
+ std::cout << "\nDetected seal impressions:" << std::endl;
|
|
|
+ for (const auto& impression : impressions) {
|
|
|
+ std::cout << impression << std::endl;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ std::cout << "Failed to send HTTP request." << std::endl;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+</details>
|
|
|
+
|
|
|
+<details>
|
|
|
+<summary>Java</summary>
|
|
|
+
|
|
|
+```java
|
|
|
+import okhttp3.*;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
+import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Base64;
|
|
|
+
|
|
|
+public class Main {
|
|
|
+ public static void main(String[] args) throws IOException {
|
|
|
+ String API_URL = "http://localhost:8080/seal-recognition";
|
|
|
+ String imagePath = "./demo.jpg";
|
|
|
+ String layoutImagePath = "./layout.jpg";
|
|
|
+
|
|
|
+ File file = new File(imagePath);
|
|
|
+ byte[] fileContent = java.nio.file.Files.readAllBytes(file.toPath());
|
|
|
+ String imageData = Base64.getEncoder().encodeToString(fileContent);
|
|
|
+
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ ObjectNode params = objectMapper.createObjectNode();
|
|
|
+ params.put("image", imageData);
|
|
|
+
|
|
|
+ OkHttpClient client = new OkHttpClient();
|
|
|
+ MediaType JSON = MediaType.Companion.get("application/json; charset=utf-8");
|
|
|
+ RequestBody body = RequestBody.Companion.create(params.toString(), JSON);
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(API_URL)
|
|
|
+ .post(body)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ try (Response response = client.newCall(request).execute()) {
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ String responseBody = response.body().string();
|
|
|
+ JsonNode resultNode = objectMapper.readTree(responseBody);
|
|
|
+ JsonNode result = resultNode.get("result");
|
|
|
+ String layoutBase64Image = result.get("layoutImage").asText();
|
|
|
+ JsonNode impressions = result.get("sealImpressions");
|
|
|
+
|
|
|
+ imageBytes = Base64.getDecoder().decode(layoutBase64Image);
|
|
|
+ try (FileOutputStream fos = new FileOutputStream(layoutImagePath)) {
|
|
|
+ fos.write(imageBytes);
|
|
|
+ }
|
|
|
+ System.out.println("Output image saved at " + layoutImagePath);
|
|
|
+
|
|
|
+ System.out.println("\nDetected seal impressions: " + impressions.toString());
|
|
|
+ } else {
|
|
|
+ System.err.println("Request failed with code: " + response.code());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+</details>
|
|
|
+
|
|
|
+<details>
|
|
|
+<summary>Go</summary>
|
|
|
+
|
|
|
+```go
|
|
|
+package main
|
|
|
+
|
|
|
+import (
|
|
|
+ "bytes"
|
|
|
+ "encoding/base64"
|
|
|
+ "encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "io/ioutil"
|
|
|
+ "net/http"
|
|
|
+)
|
|
|
+
|
|
|
+func main() {
|
|
|
+ API_URL := "http://localhost:8080/seal-recognition"
|
|
|
+ imagePath := "./demo.jpg"
|
|
|
+ layoutImagePath := "./layout.jpg"
|
|
|
+
|
|
|
+ imageBytes, err := ioutil.ReadFile(imagePath)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error reading image file:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ imageData := base64.StdEncoding.EncodeToString(imageBytes)
|
|
|
+
|
|
|
+ payload := map[string]string{"image": imageData}
|
|
|
+ payloadBytes, err := json.Marshal(payload)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error marshaling payload:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ client := &http.Client{}
|
|
|
+ req, err := http.NewRequest("POST", API_URL, bytes.NewBuffer(payloadBytes))
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error creating request:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ res, err := client.Do(req)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error sending request:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer res.Body.Close()
|
|
|
+
|
|
|
+ body, err := ioutil.ReadAll(res.Body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error reading response body:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ type Response struct {
|
|
|
+ Result struct {
|
|
|
+ LayoutImage string `json:"layoutImage"`
|
|
|
+ Impressions []map[string]interface{} `json:"sealImpressions"`
|
|
|
+ } `json:"result"`
|
|
|
+ }
|
|
|
+ var respData Response
|
|
|
+ err = json.Unmarshal([]byte(string(body)), &respData)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error unmarshaling response body:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ layoutImageData, err := base64.StdEncoding.DecodeString(respData.Result.LayoutImage)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error decoding base64 image data:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = ioutil.WriteFile(layoutImagePath, layoutImageData, 0644)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error writing image to file:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Printf("Image saved at %s.jpg\n", layoutImagePath)
|
|
|
+
|
|
|
+ fmt.Println("\nDetected seal impressions:")
|
|
|
+ for _, impression := range respData.Result.Impressions {
|
|
|
+ fmt.Println(impression)
|
|
|
+ }
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+</details>
|
|
|
+
|
|
|
+<details>
|
|
|
+<summary>C#</summary>
|
|
|
+
|
|
|
+```csharp
|
|
|
+using System;
|
|
|
+using System.IO;
|
|
|
+using System.Net.Http;
|
|
|
+using System.Net.Http.Headers;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
+
|
|
|
+class Program
|
|
|
+{
|
|
|
+ static readonly string API_URL = "http://localhost:8080/seal-recognition";
|
|
|
+ static readonly string imagePath = "./demo.jpg";
|
|
|
+ static readonly string layoutImagePath = "./layout.jpg";
|
|
|
+
|
|
|
+ static async Task Main(string[] args)
|
|
|
+ {
|
|
|
+ var httpClient = new HttpClient();
|
|
|
+
|
|
|
+ byte[] imageBytes = File.ReadAllBytes(imagePath);
|
|
|
+ string image_data = Convert.ToBase64String(imageBytes);
|
|
|
+
|
|
|
+ var payload = new JObject{ { "image", image_data } };
|
|
|
+ var content = new StringContent(payload.ToString(), Encoding.UTF8, "application/json");
|
|
|
+
|
|
|
+ HttpResponseMessage response = await httpClient.PostAsync(API_URL, content);
|
|
|
+ response.EnsureSuccessStatusCode();
|
|
|
+
|
|
|
+ string responseBody = await response.Content.ReadAsStringAsync();
|
|
|
+ JObject jsonResponse = JObject.Parse(responseBody);
|
|
|
+
|
|
|
+ string layoutBase64Image = jsonResponse["result"]["layoutImage"].ToString();
|
|
|
+ byte[] layoutImageBytes = Convert.FromBase64String(layoutBase64Image);
|
|
|
+ File.WriteAllBytes(layoutImagePath, layoutImageBytes);
|
|
|
+ Console.WriteLine($"Output image saved at {layoutImagePath}");
|
|
|
+
|
|
|
+ Console.WriteLine("\nDetected seal impressions:");
|
|
|
+ Console.WriteLine(jsonResponse["result"]["sealImpressions"].ToString());
|
|
|
+ }
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+</details>
|
|
|
+
|
|
|
+<details>
|
|
|
+<summary>Node.js</summary>
|
|
|
+
|
|
|
+```js
|
|
|
+const axios = require('axios');
|
|
|
+const fs = require('fs');
|
|
|
+
|
|
|
+const API_URL = 'http://localhost:8080/seal-recognition'
|
|
|
+const imagePath = './demo.jpg'
|
|
|
+const layoutImagePath = "./layout.jpg";
|
|
|
+
|
|
|
+let config = {
|
|
|
+ method: 'POST',
|
|
|
+ maxBodyLength: Infinity,
|
|
|
+ url: API_URL,
|
|
|
+ data: JSON.stringify({
|
|
|
+ 'image': encodeImageToBase64(imagePath)
|
|
|
+ })
|
|
|
+};
|
|
|
+
|
|
|
+function encodeImageToBase64(filePath) {
|
|
|
+ const bitmap = fs.readFileSync(filePath);
|
|
|
+ return Buffer.from(bitmap).toString('base64');
|
|
|
+}
|
|
|
+
|
|
|
+axios.request(config)
|
|
|
+.then((response) => {
|
|
|
+ const result = response.data["result"];
|
|
|
+
|
|
|
+ imageBuffer = Buffer.from(result["layoutImage"], 'base64');
|
|
|
+ fs.writeFile(layoutImagePath, imageBuffer, (err) => {
|
|
|
+ if (err) throw err;
|
|
|
+ console.log(`Output image saved at ${layoutImagePath}`);
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log("\nDetected seal impressions:");
|
|
|
+ console.log(result["sealImpressions"]);
|
|
|
+})
|
|
|
+.catch((error) => {
|
|
|
+ console.log(error);
|
|
|
+});
|
|
|
+```
|
|
|
+
|
|
|
+</details>
|
|
|
+
|
|
|
+<details>
|
|
|
+<summary>PHP</summary>
|
|
|
+
|
|
|
+```php
|
|
|
+<?php
|
|
|
|
|
|
+$API_URL = "http://localhost:8080/seal-recognition";
|
|
|
+$image_path = "./demo.jpg";
|
|
|
+$layout_image_path = "./layout.jpg";
|
|
|
|
|
|
+$image_data = base64_encode(file_get_contents($image_path));
|
|
|
+$payload = array("image" => $image_data);
|
|
|
+
|
|
|
+$ch = curl_init($API_URL);
|
|
|
+curl_setopt($ch, CURLOPT_POST, true);
|
|
|
+curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
|
|
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
+$response = curl_exec($ch);
|
|
|
+curl_close($ch);
|
|
|
+
|
|
|
+$result = json_decode($response, true)["result"];
|
|
|
+
|
|
|
+file_put_contents($layout_image_path, base64_decode($result["layoutImage"]));
|
|
|
+echo "Output image saved at " . $layout_image_path . "\n";
|
|
|
+
|
|
|
+echo "\nDetected seal impressions:\n";
|
|
|
+print_r($result["sealImpressions"]);
|
|
|
+
|
|
|
+?>
|
|
|
+```
|
|
|
+
|
|
|
+</details>
|
|
|
+</details>
|
|
|
+<br/>
|
|
|
|
|
|
## 4. Secondary development
|
|
|
If the default model weights provided by the seal text recognition production line are not satisfactory in terms of accuracy or speed in your scenario, you can try using your own specific domain or application scenario data to further fine tune the existing model to improve the recognition performance of the seal text recognition production line in your scenario.
|
|
|
@@ -344,11 +777,3 @@ paddlex --pipeline seal_recognition --input seal_text_det.png --device npu:0 --s
|
|
|
```
|
|
|
|
|
|
If you want to use the seal text recognition production line on a wider range of hardware, please refer to the [PaddleX Multi Hardware Usage Guide](../../../other_devices_support/installation_other_devices_en.md)。
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|