handschecker / config.py
Nur Arifin Akbar
Fix Gemini model name and add detailed error handling for sample data loading
0b4d45d
# Configuration for Hugging Face Spaces
import os
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
# App configuration
APP_TITLE = "Handwriting Assessment App"
APP_DESCRIPTION = "AI-powered handwriting assessment tool for teachers and students"
# Gradio configuration
GRADIO_CONFIG = {
"title": APP_TITLE,
"theme": "soft"
}
# File upload settings
ALLOWED_IMAGE_TYPES = ['.png', '.jpg', '.jpeg']
ALLOWED_DOCUMENT_TYPES = ['.pdf']
MAX_FILE_SIZE_MB = 10
# Scoring thresholds
SCORE_THRESHOLDS = {
'excellent': 0.9,
'very_good': 0.8,
'good': 0.7,
'fair': 0.6
}
# API settings
GEMINI_API_KEY = os.getenv('GEMINI_API_KEY', '')
# Using gemini-2.0-flash-exp for vision and text processing
GEMINI_MODEL = os.getenv('GEMINI_MODEL', 'gemini-2.0-flash-exp')
ENVIRONMENT = os.getenv('ENVIRONMENT', 'development')
# Image preprocessing settings for gemini3n series models
SUPPORTED_RESOLUTIONS = [(256, 256), (512, 512), (768, 768)]
DEFAULT_RESOLUTION = (768, 768) # Use highest resolution for best OCR quality
OCR_PROMPT = """
Please extract all the handwritten text from this image.
Focus on accuracy and maintain the original structure and formatting as much as possible.
If there are mathematical equations, formulas, or special symbols, please transcribe them clearly.
Return only the extracted text without any additional commentary.
"""