Skip to content

Genocs/form-recognizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

162 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Build Downloads Contributors Forks Stargazers Issues Discord Gitter Twitter Twitterx LinkedIn

icon

Nuget package & Web Api service built with .NET8. This repo contains the source code for the Genocs.FormRecognizer project.

Genocs.FormRecognizer is a .NET library that allows to extract tag coming from images. The ML model is built using Azure Cognitive services.

NOTE: Version 5.x.x doesn't support Microsoft Face Api any more

Prerequisites

The project requires to have an Azure subscription with

  • Storage account
  • Cognitive Services
  • Redis Cache

Distributed cache

The project use a cache to store the classification modelId. You have two options:

  1. Use in memory cache
  2. Use Redis cache

The system by default use the singleton object to store the classification key value pair data.

To use the library remember to setup the classification modelId calling: POST {{root_url}}/api/Settings

Setup the environment by using environment variables

  "AppSettings": {
    "PassportModel": "{{PassportModelUrl}}"
  },
  "AzureStorage": {
    "AccountName": "{{accountName}}",
    "AccountKey": "{{AccountKey}}",
    "UploadContainer": "{{UploadContainer}}",
    "TrainingSetContainerUrl": "{{TrainingSetContainerUrl}}",
    "ThumbnailContainer": "{{ThumbnailContainer}}",
    "InspectingFileUrl": "{{InspectingFileUrl}}"
  },
  "ImageClassifier": {
    "Endpoint": "https://westeurope.api.cognitive.microsoft.com",
    "SubscriptionKey": "{{SubscriptionKey}}",
    "ModelId": "{{ModelId}}"
  },
  "FormRecognizer": {
    "Endpoint": "https://westeurope.api.cognitive.microsoft.com",
    "SubscriptionKey": "{{SubscriptionKey}}"
  },
  "AzureVision": {
    "Endpoint": "https://westeurope.cognitiveservices.azure.com",
    "SubscriptionKey": "{{SubscriptionKey}}"
  },
  "RedisSettings": {
    "ConnectionString": "{{ConnectionString}}"
  },
  "RabbitMQ": {
    "HostName": "localhost",
    "Username": "guest",
    "Password": "guest",
    "VirtualHost": "/"
  }

Integration Events

The system use RabbitMQ to publish events. The following events are published:

FormDataExtractionCompleted

namespace Genocs.Integration.CognitiveServices.IntegrationEvents;

/// <summary>
/// The event to raised when Form Data extraction is completed.
/// </summary>
public class FormDataExtractionCompleted
{
    /// <summary>
    /// The reference id. Client can use it to keep external reference.
    /// </summary>
    public string? ReferenceId { get; set; }

    /// <summary>
    /// The request id.
    /// </summary>
    public string? RequestId { get; set; }

    /// <summary>
    /// The context id.
    /// </summary>
    public string? ContextId { get; set; }

    /// <summary>
    /// The processed resource url.
    /// </summary>
    public string ResourceUrl { get; set; } = default!;

    /// <summary>
    /// The classification object.
    /// </summary>
    public Classification? Classification { get; set; }

    /// <summary>
    /// The dynamic data about the results.
    /// </summary>
    public List<dynamic>? ContentData { get; set; }
}

Build and Test

# Restore packages
dotnet restore

# Build solution
dotnet build

# Run tests
dotnet test

# Pack nuget package
dotnet pack

# Run WebApi
dotnet run --project ./src/Genocs.FormRecognizer.WebApi

# Run worker
dotnet run --project ./src/Genocs.FormRecognizer.Worker

# Build docker image
docker build -f webapi.dockerfile -t genocs/formrecognizer-webapi:5.0.4 -t genocs/formrecognizer-webapi:latest .
docker build -f worker.dockerfile -t genocs/formrecognizer-worker:5.0.4 -t genocs/formrecognizer-worker:latest .

# Push image on dockerhub
docker push genocs/formrecognizer-webapi:5.0.4
docker push genocs/formrecognizer-webapi:latest

docker push genocs/formrecognizer-worker:5.0.4
docker push genocs/formrecognizer-worker:latest

# Build using docker compose
docker-compose -f docker-compose.yml build

# Run using docker compose
docker-compose -f docker-compose.yml up -d

api-workbench.rest

Use this file inside Visual Studio code with REST Client plugin

License

This project is licensed with the MIT license.

Changelogs

View Complete Changelogs.

Community

Support

Has this Project helped you learn something New? or Helped you at work? Here are a few ways by which you can support.

  • ⭐ Leave a star!
  • 🥇 Recommend this project to your colleagues.
  • 🦸 Do consider endorsing me on LinkedIn for ASP.NET Core - Connect via LinkedIn
  • ☕ If you want to support this project in the long run, consider buying me a coffee!

buy-me-a-coffee

Code Contributors

This project exists thanks to all the people who contribute. Submit your PR and join the team!

genocs contributors

Financial Contributors

Become a financial contributor and help me sustain the project. Support the Project!

Acknowledgements

About

Form Recognizer built on top of Azure Cognitive Services

Topics

Resources

License

Code of conduct

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Sponsor this project

Packages

 
 
 

Contributors

Languages