app.py CHANGED
@@ -170,8 +170,14 @@ def save_model(model, path):
170
  torch.save(model.state_dict(), path)
171
 
172
 
173
- def load_model(path):
174
  global ocr_model
 
 
 
 
 
 
175
  model = OCRModel(num_classes=len(CHAR2IDX))
176
  model.load_state_dict(torch.load(path, map_location=device))
177
  model.to(device)
@@ -434,8 +440,15 @@ def generate_labels(font_file=None, num_labels: int = 25):
434
  return [error_img]
435
 
436
  def list_fonts():
437
- fonts = [f for f in os.listdir() if f.lower().endswith((".ttf", ".otf"))]
438
- return ["None"] + fonts if fonts else ["None"]
 
 
 
 
 
 
 
439
 
440
  custom_css = """
441
  #label-gallery .gallery-item img {
 
170
  torch.save(model.state_dict(), path)
171
 
172
 
173
+ def load_model(filename):
174
  global ocr_model
175
+ model_dir = "./models"
176
+ path = os.path.join(model_dir, filename)
177
+
178
+ if not os.path.exists(path):
179
+ return f"Model file '{path}' does not exist."
180
+
181
  model = OCRModel(num_classes=len(CHAR2IDX))
182
  model.load_state_dict(torch.load(path, map_location=device))
183
  model.to(device)
 
440
  return [error_img]
441
 
442
  def list_fonts():
443
+ font_dir = "./fonts"
444
+ if not os.path.exists(font_dir):
445
+ return ["None"]
446
+ fonts = [
447
+ (f, os.path.join(font_dir, f)) for f in os.listdir(font_dir)
448
+ if f.lower().endswith((".ttf", ".otf"))
449
+ ]
450
+ return [("None", "None")] + fonts
451
+
452
 
453
  custom_css = """
454
  #label-gallery .gallery-item img {
daenow.otf β†’ fonts/Daemon.otf RENAMED
File without changes
fonts/Glipervelz.ttf ADDED
Binary file (20.6 kB). View file
 
aAnnyeongHaseyo.otf β†’ fonts/aAnnyeongHaseyo.otf RENAMED
File without changes
Daemon_OCR.pth β†’ models/Daemon.pth RENAMED
File without changes
DaemonOCR.pth β†’ models/DaemonOCR.pth RENAMED
File without changes
models/Glipervelz_4096ep_lr1e-03_20250803060008.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:003cba654cea4a725f1eb920a58a3e43d088c23069b0f22f8f11807c9e68b3fa
3
+ size 4388527
aAnnyeongHaseyo.pth β†’ models/aAnnyeongHaseyo.pth RENAMED
File without changes