Spaces:
Running on Zero
Running on Zero
Upload batch.py with huggingface_hub
Browse files
batch.py
CHANGED
|
@@ -31,8 +31,11 @@ def export_csv(rows, destination):
|
|
| 31 |
def run(folder, output, threshold=0.5, review_confidence=0.8, limit=None, device=None):
|
| 32 |
folder, output = Path(folder).resolve(), Path(output).resolve()
|
| 33 |
output.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
|
| 34 |
files = sorted(p for p in folder.rglob("*") if p.is_file() and p.suffix.lower() in EXTENSIONS
|
| 35 |
-
and output not in p.parents and not
|
|
|
|
| 36 |
if limit:
|
| 37 |
files = files[:limit]
|
| 38 |
settings = {"model": MODEL_ID, "revision": REVISION, "policy": POLICY_VERSION,
|
|
@@ -100,7 +103,7 @@ def run(folder, output, threshold=0.5, review_confidence=0.8, limit=None, device
|
|
| 100 |
if __name__ == "__main__":
|
| 101 |
parser = argparse.ArgumentParser(description=__doc__)
|
| 102 |
parser.add_argument("folder", type=Path)
|
| 103 |
-
parser.add_argument("--output", type=Path, default=Path("
|
| 104 |
parser.add_argument("--threshold", type=float, default=0.5)
|
| 105 |
parser.add_argument("--review-confidence", type=float, default=0.8)
|
| 106 |
parser.add_argument("--limit", type=int)
|
|
|
|
| 31 |
def run(folder, output, threshold=0.5, review_confidence=0.8, limit=None, device=None):
|
| 32 |
folder, output = Path(folder).resolve(), Path(output).resolve()
|
| 33 |
output.mkdir(parents=True, exist_ok=True)
|
| 34 |
+
source = Path(__file__).resolve().parent
|
| 35 |
+
skip_source = not folder.is_relative_to(source)
|
| 36 |
files = sorted(p for p in folder.rglob("*") if p.is_file() and p.suffix.lower() in EXTENSIONS
|
| 37 |
+
and output not in p.parents and (not skip_source or source not in p.parents)
|
| 38 |
+
and not any(x.startswith('.') for x in p.relative_to(folder).parts))
|
| 39 |
if limit:
|
| 40 |
files = files[:limit]
|
| 41 |
settings = {"model": MODEL_ID, "revision": REVISION, "policy": POLICY_VERSION,
|
|
|
|
| 103 |
if __name__ == "__main__":
|
| 104 |
parser = argparse.ArgumentParser(description=__doc__)
|
| 105 |
parser.add_argument("folder", type=Path)
|
| 106 |
+
parser.add_argument("--output", type=Path, default=Path("document-results"))
|
| 107 |
parser.add_argument("--threshold", type=float, default=0.5)
|
| 108 |
parser.add_argument("--review-confidence", type=float, default=0.8)
|
| 109 |
parser.add_argument("--limit", type=int)
|