DAPPER (Document Analysis, Processing, and Pattern Extraction Repository)
Statistical Learning Final Project for Document Classification
 
Loading...
Searching...
No Matches
server Namespace Reference

Functions

 extract_text (image)
 
 image_to_base64 (image, format="PNG")
 
 lifespan (FastAPI app)
 
 get_index ()
 
 health_check ()
 
 classify_document (UploadFile file=File(...))
 
 extract_invoice_data (UploadFile file=File(...))
 
 list_models ()
 
 list_classes ()
 

Variables

 root_dir = str(Path(__file__).parent.parent)
 
list CLASSES = ["correspondence", "forms", "invoice", "other", "personal", "promotional", "scientific"]
 
 device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
 
str model_name = "resnet50"
 
dict models
 
str extractor_dir = "models/invoice_extractor"
 
 model = None
 
 transformations
 
 app
 
 allow_origins
 
 allow_credentials
 
 allow_methods
 
 allow_headers
 
 name
 
 host
 
 port
 

Function Documentation

◆ classify_document()

server.classify_document ( UploadFile   file = File(...))
Classify a document image

◆ extract_invoice_data()

server.extract_invoice_data ( UploadFile   file = File(...))
Extract information from an invoice image

◆ extract_text()

server.extract_text (   image)

◆ get_index()

server.get_index ( )
Serve the index.html file

◆ health_check()

server.health_check ( )

◆ image_to_base64()

server.image_to_base64 (   image,
  format = "PNG" 
)
Convert a PIL Image to base64 encoded string

◆ lifespan()

server.lifespan ( FastAPI  app)

◆ list_classes()

server.list_classes ( )
List supported document classes

◆ list_models()

server.list_models ( )
List available classification models

Variable Documentation

◆ allow_credentials

server.allow_credentials

◆ allow_headers

server.allow_headers

◆ allow_methods

server.allow_methods

◆ allow_origins

server.allow_origins

◆ app

server.app
Initial value:
1= FastAPI(
2 title="Document Classification API",
3 description="API for classifying document images using trained models",
4 version="1.0.0",
5 lifespan=lifespan
6)

◆ CLASSES

list server.CLASSES = ["correspondence", "forms", "invoice", "other", "personal", "promotional", "scientific"]

◆ device

server.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

◆ extractor_dir

str server.extractor_dir = "models/invoice_extractor"

◆ host

server.host

◆ model

server.model = None

◆ model_name

str server.model_name = "resnet50"

◆ models

dict server.models
Initial value:
1= {
2 "resnet50": "/home/velocitatem/Documents/University/Third Year/Statistical Learning/final_project/models/resnet/resnet_sunday_night_baseline.pth",
3 "eaml": "/home/velocitatem/Documents/University/Third Year/Statistical Learning/final_project/models/eaml/eaml_sunday_night_baseline.pth",
4 "cnn": "/home/velocitatem/Documents/University/Third Year/Statistical Learning/final_project/models/cnn/cnn_sunday_night_baseline.pth",
5}

◆ name

server.name

◆ port

server.port

◆ root_dir

server.root_dir = str(Path(__file__).parent.parent)

◆ transformations

server.transformations
Initial value:
1= transforms.Compose([
2 transforms.Resize((224, 224)),
3 transforms.ToTensor(),
4 transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
5])