可以帮忙提供一下使用代码吗

#1
by dafen - opened

from transformers import NougatProcessor, VisionEncoderDecoderModel,AutoProcessor
from PIL import Image

max_length = 100 # defing max length of output
processor = NougatProcessor.from_pretrained("zphilip48/nougat-middle-cn", max_length = max_length)
model = VisionEncoderDecoderModel.from_pretrained("zphilip48/nougat-middle-cn")

image = Image.open("math.png")
image = processor(image, return_tensors="pt").pixel_values # The processor will resize the image according to our model

result_tensor = model.generate(
image,
max_length=max_length,
bad_words_ids=[[processor.tokenizer.unk_token_id]]
) # generate id tensor

result = processor.batch_decode(result_tensor, skip_special_tokens=True) # Using the processor to decode the result
result = processor.post_process_generation(result, fix_markdown=False)

print(*result)
。报错OSError: zphilip48/nougat-middle-cn does not appear to have a file named preprocessor_config.json.

table2.png
这个图片是测试使用的

Sign up or log in to comment