Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
0450dc0
1
Parent(s):
dcad7ce
AA
Browse files
app.py
CHANGED
|
@@ -514,9 +514,9 @@ model, diffusion = create_model_and_diffusion(
|
|
| 514 |
)
|
| 515 |
setattr(diffusion, "settings", settings)
|
| 516 |
|
| 517 |
-
|
| 518 |
pretrained_dewarp_model = GeoTr_Seg_Inf()
|
| 519 |
-
settings.env.seg_model_path = hf_hub_download(repo_id="hanquansanren/DvD", filename="seg.pth"
|
| 520 |
reload_segmodel(pretrained_dewarp_model.msk, settings.env.seg_model_path)
|
| 521 |
# reload_model(pretrained_dewarp_model.GeoTr, settings.env.dewarping_model_path)
|
| 522 |
pretrained_dewarp_model.to(dist_util.dev())
|
|
@@ -525,19 +525,19 @@ pretrained_dewarp_model.eval()
|
|
| 525 |
if settings.env.use_line_mask:
|
| 526 |
pretrained_line_seg_model = UNet(n_channels=3, n_classes=1)
|
| 527 |
pretrained_seg_model = Seg()
|
| 528 |
-
settings.env.line_seg_model_path = hf_hub_download(repo_id="hanquansanren/DvD", filename="line_model2.pth"
|
| 529 |
line_model_ckpt = dist_util.load_state_dict(settings.env.line_seg_model_path, map_location='cpu')['model']
|
| 530 |
pretrained_line_seg_model.load_state_dict(line_model_ckpt, strict=True)
|
| 531 |
pretrained_line_seg_model.to(dist_util.dev())
|
| 532 |
pretrained_line_seg_model.eval()
|
| 533 |
|
| 534 |
-
settings.env.new_seg_model_path = hf_hub_download(repo_id="hanquansanren/DvD", filename="seg_model.pth"
|
| 535 |
seg_model_ckpt = dist_util.load_state_dict(settings.env.new_seg_model_path, map_location='cpu')['model']
|
| 536 |
pretrained_seg_model.load_state_dict(seg_model_ckpt, strict=True)
|
| 537 |
pretrained_seg_model.to(dist_util.dev())
|
| 538 |
pretrained_seg_model.eval()
|
| 539 |
|
| 540 |
-
settings.env.model_path = hf_hub_download(repo_id="hanquansanren/DvD", filename="model1852000.pt"
|
| 541 |
model.cpu().load_state_dict(dist_util.load_state_dict(settings.env.model_path, map_location="cpu"), strict=False)
|
| 542 |
logger.log(f"Model loaded with {settings.env.model_path}")
|
| 543 |
|
|
@@ -558,4 +558,5 @@ if __name__ == '__main__':
|
|
| 558 |
description="This is a demo for document image dewarping using a trained model.",
|
| 559 |
)
|
| 560 |
|
| 561 |
-
demo.launch(share=True, debug=True, server_name="10.7.88.77")
|
|
|
|
|
|
| 514 |
)
|
| 515 |
setattr(diffusion, "settings", settings)
|
| 516 |
|
| 517 |
+
|
| 518 |
pretrained_dewarp_model = GeoTr_Seg_Inf()
|
| 519 |
+
settings.env.seg_model_path = hf_hub_download(repo_id="hanquansanren/DvD", filename="seg.pth")
|
| 520 |
reload_segmodel(pretrained_dewarp_model.msk, settings.env.seg_model_path)
|
| 521 |
# reload_model(pretrained_dewarp_model.GeoTr, settings.env.dewarping_model_path)
|
| 522 |
pretrained_dewarp_model.to(dist_util.dev())
|
|
|
|
| 525 |
if settings.env.use_line_mask:
|
| 526 |
pretrained_line_seg_model = UNet(n_channels=3, n_classes=1)
|
| 527 |
pretrained_seg_model = Seg()
|
| 528 |
+
settings.env.line_seg_model_path = hf_hub_download(repo_id="hanquansanren/DvD", filename="line_model2.pth")
|
| 529 |
line_model_ckpt = dist_util.load_state_dict(settings.env.line_seg_model_path, map_location='cpu')['model']
|
| 530 |
pretrained_line_seg_model.load_state_dict(line_model_ckpt, strict=True)
|
| 531 |
pretrained_line_seg_model.to(dist_util.dev())
|
| 532 |
pretrained_line_seg_model.eval()
|
| 533 |
|
| 534 |
+
settings.env.new_seg_model_path = hf_hub_download(repo_id="hanquansanren/DvD", filename="seg_model.pth")
|
| 535 |
seg_model_ckpt = dist_util.load_state_dict(settings.env.new_seg_model_path, map_location='cpu')['model']
|
| 536 |
pretrained_seg_model.load_state_dict(seg_model_ckpt, strict=True)
|
| 537 |
pretrained_seg_model.to(dist_util.dev())
|
| 538 |
pretrained_seg_model.eval()
|
| 539 |
|
| 540 |
+
settings.env.model_path = hf_hub_download(repo_id="hanquansanren/DvD", filename="model1852000.pt")
|
| 541 |
model.cpu().load_state_dict(dist_util.load_state_dict(settings.env.model_path, map_location="cpu"), strict=False)
|
| 542 |
logger.log(f"Model loaded with {settings.env.model_path}")
|
| 543 |
|
|
|
|
| 558 |
description="This is a demo for document image dewarping using a trained model.",
|
| 559 |
)
|
| 560 |
|
| 561 |
+
# demo.launch(share=True, debug=True, server_name="10.7.88.77")
|
| 562 |
+
demo.launch()
|