Hawk3388 commited on
Commit
4951c19
·
1 Parent(s): b7a88eb

modified: app.py

Browse files

deleted: model/gap_detection_model.pt

Files changed (2) hide show
  1. app.py +5 -15
  2. model/gap_detection_model.pt +0 -3
app.py CHANGED
@@ -13,12 +13,7 @@ from main import WorksheetSolver
13
 
14
  warnings.filterwarnings("ignore")
15
 
16
- ALLOWED_EXTENSIONS = {"png", "jpg", "jpeg", "webp", "bmp"}
17
- GAP_DETECTION_MODEL_PATH = "./model/gap_detection_model.pt"
18
- RELEASES_URL = "https://github.com/Hawk3388/solver/releases"
19
-
20
-
21
- def ensure_gap_model() -> str:
22
  download = False
23
 
24
  os.makedirs("./model", exist_ok=True)
@@ -90,14 +85,6 @@ def solve_worksheet(image_path: str):
90
  if not _is_allowed_image(image_path):
91
  raise gr.Error("Please upload a valid image file (PNG, JPG, JPEG, WEBP, BMP).")
92
 
93
- if not os.path.exists(GAP_DETECTION_MODEL_PATH):
94
- try:
95
- model_path = ensure_gap_model()
96
- except Exception as error:
97
- raise gr.Error(f"Could not load the gap detection model: {error}") from error
98
- else:
99
- model_path = GAP_DETECTION_MODEL_PATH
100
-
101
  with tempfile.TemporaryDirectory() as tmp_dir:
102
  unique_id = uuid.uuid4().hex
103
  input_path = os.path.join(tmp_dir, f"{unique_id}.png")
@@ -108,7 +95,7 @@ def solve_worksheet(image_path: str):
108
 
109
  solver = WorksheetSolver(
110
  input_path,
111
- gap_detection_model_path=model_path,
112
  llm_model_name="gemini-3-flash-preview",
113
  think=True,
114
  local=False,
@@ -173,6 +160,9 @@ def build_app() -> gr.Blocks:
173
 
174
  return demo
175
 
 
 
 
176
 
177
  demo = build_app()
178
 
 
13
 
14
  warnings.filterwarnings("ignore")
15
 
16
+ def get_gap_model() -> str:
 
 
 
 
 
17
  download = False
18
 
19
  os.makedirs("./model", exist_ok=True)
 
85
  if not _is_allowed_image(image_path):
86
  raise gr.Error("Please upload a valid image file (PNG, JPG, JPEG, WEBP, BMP).")
87
 
 
 
 
 
 
 
 
 
88
  with tempfile.TemporaryDirectory() as tmp_dir:
89
  unique_id = uuid.uuid4().hex
90
  input_path = os.path.join(tmp_dir, f"{unique_id}.png")
 
95
 
96
  solver = WorksheetSolver(
97
  input_path,
98
+ gap_detection_model_path=GAP_DETECTION_MODEL_PATH,
99
  llm_model_name="gemini-3-flash-preview",
100
  think=True,
101
  local=False,
 
160
 
161
  return demo
162
 
163
+ ALLOWED_EXTENSIONS = {"png", "jpg", "jpeg", "webp", "bmp"}
164
+ RELEASES_URL = "https://github.com/Hawk3388/solver/releases"
165
+ GAP_DETECTION_MODEL_PATH = get_gap_model()
166
 
167
  demo = build_app()
168
 
model/gap_detection_model.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2593fee314b21afead4fc047f7c545b7e117ef37fba80bac452880e89ab1fb18
3
- size 53167589