Project

General

Profile

Actions

CompressPdf #467

open

Implement API Endpoint for Data Collection for ML Model

Added by Zahid Hassan over 1 year ago. Updated over 1 year ago.

Status:
Complete
Priority:
High
Assignee:
Category:
feature
Target version:
Start date:
09/26/2024
Due date:
09/26/2024 (about 19 months late)
% Done:

100%

Estimated time:
8:00 h

Description

Description:

We need to create an API endpoint that collects necessary parameters for our machine learning model to predict the parameters required for PDF compression. This endpoint will store these collected data in the remote database .

Requirements:

Endpoint Definition:

  • Method: POST
  • Path: /v1/define-parameters/
  • Input Data Structure: The API should accept the following fields :
{
    "files[]": {},
    "encoding_type": "1",
    "compress_font": "true",
    "embed_font": "true"
}

Here, both compress_font and embed_font can be true or false.
And encoding_type can be 1 or 2.

  • 1 → DCTEncode (lossy compression) → yields high compression - low quality
  • 2 → FlateEncode (lossless compression) → yields low compression - high quality

Response Structure:

On successful data collection, return a response with a success message and the processed data. Here is a sample response.

{
  "success": true,
  "status_code": 200,
  "message": "Your Pdf files has been compressed successfully within 0.3 sec",
  "uid": "92098ac6-7084-447f-a6f2-bec5e0520393",
  "file_data": [
    {
      "file_name": "0_test2.pdf",
      "file_path": "storage/output/92098ac6-7084-447f-a6f2-bec5e0520393/0_test2.pdf",
      "output_file_size": 0.145,
      "input_file_size": 0.15,
      "expire": "2024-09-30T06:06:57.204578+00:00",
      "file_upload_time": 0,
      "compression_ratio": 3.231,
      "no_of_pages": 19,
      "text_ratio": 14.667,
      "image_ratio": 27.333,
      "processing_time": 0.212,
      "dpi": 50,
      "project_name": "FastAPI",
      "encoding_type": 1,
      "uid_fk": "92098ac6-7084-447f-a6f2-bec5e0520393",
      "compress_font": 1,
      "embed_font": 1,
      "tool_id_fk": 1,
      "endpoint_fk": 6
    }
  ]
}

Acceptance Criteria:

  • The API endpoint is fully functional and successfully adds processing data into the remote database.

This endpoint will serve as a critical component in our data collection process for the machine learning model, enabling us to make accurate predictions for PDF compression parameters based on user-provided data.

Actions #1

Updated by Redmine Admin over 1 year ago

  • Status changed from To Do to Complete
Actions

Also available in: Atom PDF