Files
Copies/default_config.py
T
sebastien 0a4f4a80d0 Detect and confirm page orientation during automatic splitting
Bundle the trained heatmap/image orientation model and run it after provisional
blank-page and split analysis. Confirm candidates with Gemini using low thinking;
resolve mixed A3 sheet ordering with the complete statement and medium thinking.
Keep A4 scans independent and export paired A3 scans in booklet reading order.

Reanalyse uniformly inverted source sheets, validate ordering permutations, and
preserve source provenance, corrected rotations and reading slots in manual review.
Document the experiments, rejected approaches, calibration and runtime limits.

Validation: focused splitting/orientation regression suites pass; bundled model
checksum and wheel assets verified. Full Interro07 offline run: 44.26 seconds,
eight candidates, mocked upright confirmations, source hashes and geometry intact.
2026-11-04 21:07:20 +01:00

152 lines
4.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import os
from pathlib import Path
API_KEY = os.environ.get("GEMINI_API_KEY")
# None inherits MODEL_FOR_LABEL_ID, including existing personal overrides.
MODEL_FOR_PAGE_ORIENTATION = None
EXPORT_DIR = Path("Export")
IMPORT_DIR = Path("Import")
# Espace ajouté à gauche des réponses annotées, en pixels à 200 dpi.
ANNOTATION_MARGIN_LEFT = 300
# (Marge mesurée en mm, espace ajouté en pixels à 200 dpi).
# Interpolation linéaire entre les points ; valeurs constantes aux extrémités.
ANNOTATION_MARGIN_POINTS = [(10, 450), (20, 400), (35, 300)]
# Hauteur maximale des documents Bnot et des groupes BGnot, en pixels.
# Les blocs d'élèves trop grands sont séparés entre deux réponses.
ANNOTATION_MAX_HEIGHT_PX = 33000
# Surface maximale : largeur maximale du document × hauteur totale, en pixels.
# Sur DS02VA, les quatre groupes dépassant 2**26 pixels deviennent flous dans
# Squid Android. Cela correspond à 256 Mio pour un bitmap à 4 octets/pixel.
# Seuil déduit des observations, pas une limite documentée par Squid.
ANNOTATION_MAX_PIXELS = 67_108_864
# Fichiers à inclure dans A Rendre (les sources d'annotations sont conservées).
RETURN_JPEG_ENABLED = True
RETURN_PDF_ENABLED = True
RETURN_ANSWERS_ENABLED = False
RETURN_ANSWERS_CONTEXT = False
RETURN_ANSWERS_QUESTION = True
RETURN_ANSWERS_SOLUTION = False
# Les étapes gestion_classe, ODS et publication sont masquées par défaut.
SHOW_PERSONAL_STEPS = False
# Lance automatiquement les deux étapes facultatives de rognage dans le GUI.
ALWAYS_CROP = False
# Chemins utilisés uniquement par les étapes personnelles.
CURRENT_SCORE_ODS_PATH = Path("current_eval.ods")
FINAL_SCORE_ODS_PATH = Path("simple_eval.ods")
FINAL_SCORE_OUTPUT_DIR = Path("Server") / "copies"
FINAL_SCORE_HISTOGRAM_PATH = Path("histogramme.pdf")
FINAL_SCORE_FONT_PATH = None
# Niveaux de réflexion : "minimal", "low", "medium", "high", ou None
# pour utiliser le défaut du modèle. Choisir un niveau supporté par le modèle
# (Gemini 3.8 Flash ne supporte pas "minimal" ; Gemini 2.5 : utiliser None).
# Modèle pour des choses très légères
# Le modèle 3.5-flash-lite est un peu moins bon pour la duplication de contexte pour des questions, dans l'analyse de l'énoncé.
# MODEL_LITE_ID = "gemini-3.5-flash-lite"
MODEL_LITE_ID = "gemini-3.8-flash"
THINKING_LEVEL_LITE = "low"
# Modèle pour identifier visuellement les labels
# MODEL_FOR_LABEL_ID = "gemini-3.5-flash-lite" # 3.5 flash lite marche plutôt mal, il insiste pour mettre les labels dans l'ordre, sans considérer ce qu'il y a écrit
MODEL_FOR_LABEL_ID = "gemini-3.8-flash"
THINKING_LEVEL_FOR_LABEL = "low"
# Modèle pour reconnaître les noms sur les grilles de premières pages.
MODEL_FOR_NAME_ID = "gemini-3.8-flash"
THINKING_LEVEL_FOR_NAME = "low"
# Modèle pour des choses normales
MODEL_FLASH_ID = "gemini-3.8-flash"
THINKING_LEVEL_FLASH = "medium"
# Modèle pour des choses dures
MODEL_PRO_ID = "gemini-3.8-flash"
THINKING_LEVEL_PRO = "medium"
# THINKING_LEVEL_PRO = "high"
# MODEL_PRO_ID = "gemini-3.1-pro-preview"
PAGE_SPLITTER_KB = {
"add_secondary_splitter": "<Insert>", # Current page only; arrows move newest
"delete_secondary_splitter": "<Delete>", # Remove newest secondary splitter
"move_left": "<Left>",
"move_right": "<Right>",
"rotate_page": "r",
"rotate_all_pages": "R",
"rotate_all_files": ",",
"keep_left": "q",
"keep_right": "d",
"keep_as_is": "f",
"next_page": "s",
"discard_page": "z",
"send_end": "a", # Send this page to the end
"reverse_pages": "i", # Reverse page order and restart at the new first page
"restart_file": "T",
"arranger": "A", # Call `pdf arranger` software, if available
"prev_file": "P",
}
PLOTTING_KB = {
"OK": "<Return>",
"previous": "p",
"edit": "e",
"open pdf": "o",
"open original pdf": "O",
"open eval": "i",
}
### Latex templates
### Pour la génération d'énoncés
LATEX_BEFORE = r"""\documentclass[varwidth=24.8cm,margin=0.4cm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath, amssymb}
\usepackage{minted}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{multicol}
\begin{document}
\begin{minipage}{24.8cm}
"""
LATEX_AFTER = r"""
\end{minipage}
\end{document}
"""
### Pour les annotations sur copies
from string import Template
LATEX_ANOT_BEFORE = Template(
r"""\documentclass[varwidth=${width_in}in,margin=0.2cm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} % Enables arbitrary font scaling
\usepackage{amsmath, amssymb}
\usepackage{mathabx} % larger inline operators.
%\usepackage{anyfontsize} % replaced by lmodern
\begin{document}
\fontsize{${fontsize}}{${line_spacing}}\selectfont
"""
)
LATEX_ANOT_AFTER = r"""
\end{document}
"""