32 lines
626 B
Python
32 lines
626 B
Python
import argparse
|
|
import json
|
|
|
|
from image_prediction.default_objects import load_pipeline
|
|
|
|
|
|
def parse_args():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("pdf")
|
|
|
|
args = parser.parse_args()
|
|
|
|
return args
|
|
|
|
|
|
def main(args):
|
|
pipeline = load_pipeline()
|
|
|
|
with open(args.pdf, "rb") as f:
|
|
predictions = pipeline(f.read())
|
|
|
|
with open("/tmp/f2dc689ca794fccb8cd38b95f2bf6ba9_predictions.json", "w") as f:
|
|
json.dump(list(predictions), f, indent=2)
|
|
|
|
for prd in predictions:
|
|
print(json.dumps(prd, indent=2))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
args = parse_args()
|
|
main(args)
|