niqun123123 commited on
Commit
74c9217
·
verified ·
1 Parent(s): 2c7bf74

Update code/infer.py

Browse files
Files changed (1) hide show
  1. infer.py +13 -0
infer.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Native multi-question CLI using the same bridge as the evaluated HTTP service."""
3
+ import argparse,json,os
4
+ from pathlib import Path
5
+ from serve_312k import LemonDeciderHFService
6
+ p=argparse.ArgumentParser()
7
+ p.add_argument('--checkpoint',type=Path,default=Path(__file__).resolve().parents[1])
8
+ p.add_argument('--device',default='cuda:0')
9
+ p.add_argument('--input',type=Path,required=True,help='One state/questions HTTP-format JSON request')
10
+ a=p.parse_args()
11
+ os.environ.setdefault('AIS_SERVER_CPU_THREADS','4')
12
+ s=LemonDeciderHFService(a.checkpoint,a.device,None)
13
+ print(json.dumps(s.predict(json.loads(a.input.read_text())),ensure_ascii=False,indent=2))