https://github.com/genocs/form-recognizer
Form Recognizer built on top of Azure Cognitive Services
https://github.com/genocs/form-recognizer
azure cognitive-services ml webapi
Last synced: 12 months ago
JSON representation
Form Recognizer built on top of Azure Cognitive Services
- Host: GitHub
- URL: https://github.com/genocs/form-recognizer
- Owner: Genocs
- License: mit
- Created: 2021-04-10T06:53:25.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-02-26T03:26:44.000Z (over 2 years ago)
- Last Synced: 2024-12-03T10:43:14.359Z (over 1 year ago)
- Topics: azure, cognitive-services, ml, webapi
- Language: C#
- Homepage:
- Size: 372 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![License][license-shield]][license-url]
[![Build][build-shield]][build-url]
[![Downloads][downloads-shield]][downloads-url]
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![Discord][discord-shield]][discord-url]
[![Gitter][gitter-shield]][gitter-url]
[![Twitter][twitter-shield]][twitter-url]
[![Twitterx][twitterx-shield]][twitterx-url]
[![LinkedIn][linkedin-shield]][linkedin-url]
[license-shield]: https://img.shields.io/github/license/Genocs/form-recognizer?color=2da44e&style=flat-square
[license-url]: https://github.com/Genocs/form-recognizer/blob/main/LICENSE
[build-shield]: https://github.com/Genocs/form-recognizer/actions/workflows/build_and_test.yml/badge.svg?branch=main
[build-url]: https://github.com/Genocs/form-recognizer/actions/workflows/build_and_test.yml
[downloads-shield]: https://img.shields.io/nuget/dt/Genocs.Microservice.Template.svg?color=2da44e&label=downloads&logo=nuget
[downloads-url]: https://www.nuget.org/packages/Genocs.Microservice.Template
[contributors-shield]: https://img.shields.io/github/contributors/Genocs/form-recognizer.svg?style=flat-square
[contributors-url]: https://github.com/Genocs/form-recognizer/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/Genocs/form-recognizer?style=flat-square
[forks-url]: https://github.com/Genocs/form-recognizer/network/members
[stars-shield]: https://img.shields.io/github/stars/Genocs/form-recognizer.svg?style=flat-square
[stars-url]: https://img.shields.io/github/stars/Genocs/form-recognizer?style=flat-square
[issues-shield]: https://img.shields.io/github/issues/Genocs/form-recognizer?style=flat-square
[issues-url]: https://github.com/Genocs/form-recognizer/issues
[discord-shield]: https://img.shields.io/discord/1106846706512953385?color=%237289da&label=Discord&logo=discord&logoColor=%237289da&style=flat-square
[discord-url]: https://discord.com/invite/fWwArnkV
[gitter-shield]: https://img.shields.io/badge/chat-on%20gitter-blue.svg
[gitter-url]: https://gitter.im/genocs/
[twitter-shield]: https://img.shields.io/twitter/follow/genocs?color=1DA1F2&label=Twitter&logo=Twitter&style=flat-square
[twitter-url]: https://twitter.com/genocs
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square&logo=linkedin&colorB=555
[linkedin-url]: https://www.linkedin.com/in/giovanni-emanuele-nocco-b31a5169/
[twitterx-shield]: https://img.shields.io/twitter/url/https/twitter.com/genocs.svg?style=social
[twitterx-url]: https://twitter.com/genocs
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
``` bash
"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`
``` csharp
namespace Genocs.Integration.CognitiveServices.IntegrationEvents;
///
/// The event to raised when Form Data extraction is completed.
///
public class FormDataExtractionCompleted
{
///
/// The reference id. Client can use it to keep external reference.
///
public string? ReferenceId { get; set; }
///
/// The request id.
///
public string? RequestId { get; set; }
///
/// The context id.
///
public string? ContextId { get; set; }
///
/// The processed resource url.
///
public string ResourceUrl { get; set; } = default!;
///
/// The classification object.
///
public Classification? Classification { get; set; }
///
/// The dynamic data about the results.
///
public List? ContentData { get; set; }
}
```
# Build and Test
``` bash
# 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](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) plugin
## License
This project is licensed with the [MIT license](LICENSE).
## Changelogs
View Complete [Changelogs](https://github.com/Genocs/form-recognizer/blob/main/CHANGELOGS.md).
## Community
- Discord [@genocs](https://discord.com/invite/fWwArnkV)
- Facebook Page [@genocs](https://facebook.com/Genocs)
- Youtube Channel [@genocs](https://youtube.com/c/genocs)
## 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](https://www.linkedin.com/in/giovanni-emanuele-nocco-b31a5169/)
- ☕ If you want to support this project in the long run, [consider buying me a coffee](https://www.buymeacoffee.com/genocs)!
[](https://www.buymeacoffee.com/genocs)
## Code Contributors
This project exists thanks to all the people who contribute. [Submit your PR and join the team!](CONTRIBUTING.md)
[](https://github.com/genocs/form-recognizer/graphs/contributors)
## Financial Contributors
Become a financial contributor and help me sustain the project. [Support the Project!](https://opencollective.com/genocs/contribute)
## Acknowledgements