Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- train/side_by_side.py +25 -0
train/side_by_side.py
CHANGED
|
@@ -117,6 +117,8 @@ def main():
|
|
| 117 |
help="Hand-picked clip IDs for the side-by-side")
|
| 118 |
parser.add_argument("--out", required=True, help="Output HTML path")
|
| 119 |
parser.add_argument("--out-json", default=None, help="Optional JSON dump")
|
|
|
|
|
|
|
| 120 |
args = parser.parse_args()
|
| 121 |
|
| 122 |
scenarios = load_scenarios()
|
|
@@ -211,6 +213,29 @@ def main():
|
|
| 211 |
print(f" baseline: {n_baseline_correct}/{len(rows)} correct")
|
| 212 |
print(f" trained: {n_trained_correct}/{len(rows)} correct")
|
| 213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
if __name__ == "__main__":
|
| 216 |
main()
|
|
|
|
| 117 |
help="Hand-picked clip IDs for the side-by-side")
|
| 118 |
parser.add_argument("--out", required=True, help="Output HTML path")
|
| 119 |
parser.add_argument("--out-json", default=None, help="Optional JSON dump")
|
| 120 |
+
parser.add_argument("--push-to-space", default=None,
|
| 121 |
+
help="If set, e.g. 'aamrinder/subtext-arena', upload outputs to that Space's docs/ dir")
|
| 122 |
args = parser.parse_args()
|
| 123 |
|
| 124 |
scenarios = load_scenarios()
|
|
|
|
| 213 |
print(f" baseline: {n_baseline_correct}/{len(rows)} correct")
|
| 214 |
print(f" trained: {n_trained_correct}/{len(rows)} correct")
|
| 215 |
|
| 216 |
+
# Push to HF Space so artifacts survive the ephemeral container
|
| 217 |
+
if args.push_to_space:
|
| 218 |
+
try:
|
| 219 |
+
from huggingface_hub import HfApi
|
| 220 |
+
api = HfApi()
|
| 221 |
+
for local, remote in [
|
| 222 |
+
(args.out, "docs/side_by_side.html"),
|
| 223 |
+
(args.out_json, "docs/side_by_side.json") if args.out_json else (None, None),
|
| 224 |
+
]:
|
| 225 |
+
if local and Path(local).exists():
|
| 226 |
+
api.upload_file(
|
| 227 |
+
path_or_fileobj=local,
|
| 228 |
+
path_in_repo=remote,
|
| 229 |
+
repo_id=args.push_to_space,
|
| 230 |
+
repo_type="space",
|
| 231 |
+
commit_message="add side-by-side baseline-vs-trained demo",
|
| 232 |
+
)
|
| 233 |
+
print(f"[done] {remote} pushed to {args.push_to_space}")
|
| 234 |
+
except Exception as e:
|
| 235 |
+
print(f"[error] push_to_space failed: {e}")
|
| 236 |
+
print("\n[main] side-by-side run finished cleanly.")
|
| 237 |
+
sys.exit(0)
|
| 238 |
+
|
| 239 |
|
| 240 |
if __name__ == "__main__":
|
| 241 |
main()
|