modified: app.py
Browse files
app.py
CHANGED
|
@@ -35,15 +35,7 @@ def _is_allowed_image(filename: str) -> bool:
|
|
| 35 |
return "." in filename and filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS
|
| 36 |
|
| 37 |
|
| 38 |
-
def solve_worksheet(
|
| 39 |
-
image_path: str,
|
| 40 |
-
model_name: str,
|
| 41 |
-
local: bool,
|
| 42 |
-
think: bool,
|
| 43 |
-
thinking_budget: int,
|
| 44 |
-
debug: bool,
|
| 45 |
-
experimental: bool,
|
| 46 |
-
):
|
| 47 |
if not image_path:
|
| 48 |
raise gr.Error("Please upload an image first.")
|
| 49 |
|
|
@@ -66,12 +58,12 @@ def solve_worksheet(
|
|
| 66 |
solver = WorksheetSolver(
|
| 67 |
input_path,
|
| 68 |
gap_detection_model_path=model_path,
|
| 69 |
-
llm_model_name=
|
| 70 |
-
think=
|
| 71 |
-
local=
|
| 72 |
-
thinking_budget=
|
| 73 |
-
debug=
|
| 74 |
-
experimental=
|
| 75 |
)
|
| 76 |
|
| 77 |
gaps, detected_image = solver.detect_gaps()
|
|
@@ -104,7 +96,7 @@ def build_app() -> gr.Blocks:
|
|
| 104 |
"""
|
| 105 |
<div class='hero'>
|
| 106 |
<h1>Worksheet Solver</h1>
|
| 107 |
-
<p>Upload a worksheet image
|
| 108 |
</div>
|
| 109 |
"""
|
| 110 |
)
|
|
@@ -117,29 +109,6 @@ def build_app() -> gr.Blocks:
|
|
| 117 |
sources=["upload"],
|
| 118 |
)
|
| 119 |
|
| 120 |
-
model_name = gr.Textbox(
|
| 121 |
-
label="LLM Model Name",
|
| 122 |
-
value="gemini-2.5-flash",
|
| 123 |
-
placeholder="e.g. gemini-2.5-flash or qwen3.5:35b",
|
| 124 |
-
)
|
| 125 |
-
|
| 126 |
-
with gr.Row():
|
| 127 |
-
local = gr.Checkbox(label="Local Mode (Ollama)", value=False)
|
| 128 |
-
think = gr.Checkbox(label="Thinking", value=True)
|
| 129 |
-
|
| 130 |
-
thinking_budget = gr.Slider(
|
| 131 |
-
minimum=0,
|
| 132 |
-
maximum=8192,
|
| 133 |
-
step=1,
|
| 134 |
-
value=2048,
|
| 135 |
-
label="Thinking Budget",
|
| 136 |
-
info="Only relevant when Thinking is enabled.",
|
| 137 |
-
)
|
| 138 |
-
|
| 139 |
-
with gr.Row():
|
| 140 |
-
debug = gr.Checkbox(label="Debug Mode", value=False)
|
| 141 |
-
experimental = gr.Checkbox(label="Experimental Mode", value=False)
|
| 142 |
-
|
| 143 |
solve_button = gr.Button("Solve", variant="primary")
|
| 144 |
|
| 145 |
with gr.Column(scale=1):
|
|
@@ -147,15 +116,7 @@ def build_app() -> gr.Blocks:
|
|
| 147 |
|
| 148 |
solve_button.click(
|
| 149 |
fn=solve_worksheet,
|
| 150 |
-
inputs=
|
| 151 |
-
image_input,
|
| 152 |
-
model_name,
|
| 153 |
-
local,
|
| 154 |
-
think,
|
| 155 |
-
thinking_budget,
|
| 156 |
-
debug,
|
| 157 |
-
experimental,
|
| 158 |
-
],
|
| 159 |
outputs=image_output,
|
| 160 |
)
|
| 161 |
|
|
|
|
| 35 |
return "." in filename and filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS
|
| 36 |
|
| 37 |
|
| 38 |
+
def solve_worksheet(image_path: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
if not image_path:
|
| 40 |
raise gr.Error("Please upload an image first.")
|
| 41 |
|
|
|
|
| 58 |
solver = WorksheetSolver(
|
| 59 |
input_path,
|
| 60 |
gap_detection_model_path=model_path,
|
| 61 |
+
llm_model_name="gemini-2.5-flash",
|
| 62 |
+
think=True,
|
| 63 |
+
local=False,
|
| 64 |
+
thinking_budget=1024,
|
| 65 |
+
debug=False,
|
| 66 |
+
experimental=False,
|
| 67 |
)
|
| 68 |
|
| 69 |
gaps, detected_image = solver.detect_gaps()
|
|
|
|
| 96 |
"""
|
| 97 |
<div class='hero'>
|
| 98 |
<h1>Worksheet Solver</h1>
|
| 99 |
+
<p>Upload a worksheet image and generate the solved version.</p>
|
| 100 |
</div>
|
| 101 |
"""
|
| 102 |
)
|
|
|
|
| 109 |
sources=["upload"],
|
| 110 |
)
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
solve_button = gr.Button("Solve", variant="primary")
|
| 113 |
|
| 114 |
with gr.Column(scale=1):
|
|
|
|
| 116 |
|
| 117 |
solve_button.click(
|
| 118 |
fn=solve_worksheet,
|
| 119 |
+
inputs=image_input,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
outputs=image_output,
|
| 121 |
)
|
| 122 |
|