Views
No views yet
1from transformers import AutoFeatureExtractor
2from onnxruntime import InferenceSession
3from datasets import load_dataset
4
5# load image
6dataset = load_dataset("huggingface/cats-image")
7image = dataset["test"]["image"][0]
8
9# load model
10feature_extractor = AutoFeatureExtractor.from_pretrained("openai/imagegpt-small")
11session = InferenceSession("model/model.onnx")
12
13# ONNX Runtime expects NumPy arrays as input
14inputs = feature_extractor(image, return_tensors="np")
15outputs = session.run(output_names=["last_hidden_state"], input_feed=dict(inputs))1from transformers import AutoFeatureExtractor
2from onnxruntime import InferenceSession
3from datasets import load_dataset
4
5# load image
6dataset = load_dataset("huggingface/cats-image")
7image = dataset["test"]["image"][0]
8
9# load model
10feature_extractor = AutoFeatureExtractor.from_pretrained("openai/imagegpt-small")
11session = InferenceSession("model/model_classification.onnx")
12
13# ONNX Runtime expects NumPy arrays as input
14inputs = feature_extractor(image, return_tensors="np")
15outputs = session.run(output_names=["logits"], input_feed=dict(inputs))1@InProceedings{pmlr-v119-chen20s,
2 title = {Generative Pretraining From Pixels},
3 author = {Chen, Mark and Radford, Alec and Child, Rewon and Wu, Jeffrey and Jun, Heewoo and Luan, David and Sutskever, Ilya},
4 booktitle = {Proceedings of the 37th International Conference on Machine Learning},
5 pages = {1691--1703},
6 year = {2020},
7 editor = {III, Hal Daumé and Singh, Aarti},
8 volume = {119},
9 series = {Proceedings of Machine Learning Research},
10 month = {13--18 Jul},
11 publisher = {PMLR},
12 pdf = {http://proceedings.mlr.press/v119/chen20s/chen20s.pdf},
13 url = {https://proceedings.mlr.press/v119/chen20s.html
14}1@inproceedings{deng2009imagenet,
2 title={Imagenet: A large-scale hierarchical image database},
3 author={Deng, Jia and Dong, Wei and Socher, Richard and Li, Li-Jia and Li, Kai and Fei-Fei, Li},
4 booktitle={2009 IEEE conference on computer vision and pattern recognition},
5 pages={248--255},
6 year={2009},
7 organization={Ieee}
8}