Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inference result #2

Open
lerndeep opened this issue Sep 5, 2024 · 0 comments
Open

inference result #2

lerndeep opened this issue Sep 5, 2024 · 0 comments

Comments

@lerndeep
Copy link

lerndeep commented Sep 5, 2024

I tried to check inference result.
0000001
Generated LaTeX formula: iabilityiabilitybenniaiabilityiabilityiabilityiornianm Dekazaazaazanmnmiabilityben Dek Dekexpexp Dekexpnmiabilityiabilityonductnm Dekexpazaaza recessexpexpexpiabilityiabilityercexpruns recess recess Dekazanm recess recessrunsnmruns recessnmexp Dek recess recessexprunsazaexprunsnm Dek recessnm recessnmrunsazaazarunsnm recessruns recessrunsexpiabilitybennmexprunsexpnm Deknmnm recessiabilityiabilityonest recess recessiabilitybeniabilityben recessnm Call recessrunsazanmrunsexpntnm recessexpiabilityercrunsnm Callazaazaexpexprunsiabilityerc recessnmnmexpexpbenexp recessexpnm recessben recessrunsrunsrunsiabilityiabilityiacnmnmnmntnmazaaza Callaza recess recess Callexpnmnmrunsrunsnmnt recessazaexpnmazarunsexpexp Call recessnmntexprunsnt recessrunsntexpazaexpntaza recessntrunsrunsbenexpexp Skipexpexp recessiabilityerciabilityercnt recessnt recessiabilityonductexp recess Dek recessntazaruns recess Callnm recessnt Call recess recessbennt recessexp Dekaza recessruns Callexprunsbenazaazant recessbenazarunsrunsexpercazaaza Dek recessiabilityonestexpexp fungiruns recessexp

I don't know why this result is so bad. Could you please let me know.

from transformers import VisionEncoderDecoderModel, AutoTokenizer, AutoFeatureExtractor
import torch
from PIL import Image

load model, tokenizer, and feature extractor

model = VisionEncoderDecoderModel.from_pretrained("DGurgurov/im2latex")
tokenizer = AutoTokenizer.from_pretrained("DGurgurov/im2latex")
feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/swin-base-patch4-window7-224-in22k") # using the original feature extractor for now

prepare an image

image = Image.open("path/to/your/image.png")
pixel_values = feature_extractor(images=image, return_tensors="pt").pixel_values

generate LaTeX formula

generated_ids = model.generate(pixel_values)
generated_texts = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)

print("Generated LaTeX formula:", generated_texts[0])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant