|
""" |
|
Configuration settings for Florence-2 Document & Image Analyzer |
|
""" |
|
|
|
|
|
FLORENCE_MODEL_ID = "microsoft/Florence-2-large" |
|
|
|
|
|
|
|
|
|
|
|
MAX_PDF_PAGES = 20 |
|
PDF_DPI = 200 |
|
MAX_IMAGE_SIZE = (1920, 1920) |
|
|
|
|
|
GRADIO_THEME = "soft" |
|
SHARE_LINK = False |
|
SERVER_PORT = 7860 |
|
|
|
|
|
FORCE_CPU = False |
|
|
|
|
|
BBOX_COLORS = ["red", "blue", "green", "orange", "purple", "yellow", "pink", "cyan"] |
|
BBOX_WIDTH = 2 |
|
FONT_SIZE = 12 |
|
|
|
|
|
FLORENCE_TASKS = { |
|
"detailed_caption": { |
|
"prompt": "<MORE_DETAILED_CAPTION>", |
|
"description": "Generate detailed descriptions of the image content", |
|
"max_tokens": 1024 |
|
}, |
|
"object_detection": { |
|
"prompt": "<OD>", |
|
"description": "Detect and locate objects with bounding boxes", |
|
"max_tokens": 512 |
|
}, |
|
"dense_captioning": { |
|
"prompt": "<DENSE_REGION_CAPTION>", |
|
"description": "Provide captions for different regions in the image", |
|
"max_tokens": 1024 |
|
}, |
|
"ocr": { |
|
"prompt": "<OCR>", |
|
"description": "Extract and locate text in the image", |
|
"max_tokens": 512 |
|
}, |
|
"region_proposal": { |
|
"prompt": "<REGION_PROPOSAL>", |
|
"description": "Identify interesting regions in the image", |
|
"max_tokens": 256 |
|
} |
|
} |
|
|
|
|
|
ERROR_MESSAGES = { |
|
"model_not_loaded": "Florence-2 model is not available. Please check your internet connection and try again.", |
|
"unsupported_format": "Unsupported file format. Please upload PNG, JPG, JPEG, or PDF files.", |
|
"pdf_too_large": f"PDF has too many pages (max: {MAX_PDF_PAGES}). Please use a smaller document.", |
|
"processing_failed": "Failed to process the file. Please try again with a different image.", |
|
"no_file": "Please upload a file first.", |
|
} |