deepseek-ai / deepseek-ai/DeepSeek-OCR
Unexpected Output for a Non-Intentional Adversarial Picture
- Dominant language
- Python
- Stars
- 23.9k
- Forks
- 2.2k
- PR merge metrics
- No merged PRs in 30d
Description
While I was trying to test the locally downloaded hf model for an image and ask the model to "parse the picture", the output looks like "拖欠 的 的 的 的 的 的 的...".
The prompt in hf reference is `"\n<|grounding|>OCR this image"`. I think the word "grounding" may cause some troubles. But I do not understand what happened.
The image is just an arbitrary image about the zebrafish that I searched from google.

Here is the execution record in case you all need them. The hyperparameters are `res = model.infer(tokenizer, prompt=prompt, image_file=image_file, output_path = output_path, base_size = 1280, image_size = 1280, crop_mode=False, save_results = True, test_compress = True)`.
```bash
DeepSeek-OCR/DeepSeek-OCR-master/DeepSeek-OCR-hf/run_dpsk_ocr.py
You are using a model of type deepseek_vl_v2 to instantiate a model of type DeepseekOCR. This is not supported for all configurations of models and can yield errors.
You are attempting to use Flash Attention 2.0 without specifying a torch dtype. This might lead to unexpected behaviour
You are attempting to use Flash Attention 2.0 with a model not initialized on GPU. Make sure to move the model to GPU after initializing it on CPU with `model.to('cuda')`.
Some weights of DeepseekOCRForCausalLM were not initialized from the model checkpoint at deepseek-ai/DeepSeek-OCR and are newly initialized: ['model.vision_model.embeddings.position_ids']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
/myenv/configuration_utils.py:590: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0.0` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`.
warnings.warn(
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:None for open-end generation.
The attention mask is not set and cannot be inferred from input because pad token is same as eos token. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
The `seen_tokens` attribute is deprecated and will be removed in v4.41. Use the `cache_position` model input instead.
`get_max_cache()` is deprecated for all Cache classes. Use `get_max_cache_shape()` instead. Calling `get_max_cache()` will raise error from v4.48
=====================
BASE: torch.Size([1, 400, 1280])
NO PATCHES
=====================
The attention layers in this model are transitioning from computing the RoPE embeddings internally through `position_ids` (2D tensor with the indexes of the tokens), to using externally computed `position_embeddings` (Tuple of tensors, containing cos and sin). In v4.46 `position_ids` will be removed and `position_embeddings` will be mandatory.
拖欠 的 的 的 的 的 的 的 的 的 的 人 的 的 的 的 的 的 的 的 的 的人 的 的 的 的 的 的 的 的 的 人的 的 的 的 的 的 的 的 的 的 的人的 的 的 的 的 的 的 的 的 的 人人 的 的 的 的 的 的 的 的 的 个 的 的 的 的 的 的 的 的 的 们 的 的 的 的 的 的 的 的 的 们的 的 的 的 的 的 的 的 的 的 个个 的 的 的 的 的 的 的 的 的 个人 的 的 的 的 的 的 的 的 的 的个人 的 的 的 的 的 的 的 的 的 个人的 的 的 的 的 的 的 的 的 的 个体 的 的 的 的 的 的 的 的 的 体 的 的 的 [Delete all the other unexpected tokens] This is a friendly reminder - the current text generation call will exceed the model's predefined maximum length (8192). Depending on the model, you may observe exceptions, performance degradation, or nothing at all.
之 之 之 の の 之 的 之 之 之 之 之 之 の の 之 的 の 之 之 之 之 の 之 之 之 的 の 之 之 之 之 の 之 の 之 的 の 之 之 之 之 之 之 の 之 的 の 之 之 之 之 の の 之 之 的 の 之 之 之 之 の の の 之 的 之 の 之 之 之 之 の の の 的 之 の 之 之 之 之 之 の の 的 之 の 之 之 之 之 の の 之 的 之 の 之 之 之 の の の の 的 之 の 之 之 之 の 之 之 の 的 之 の 之 之 之 之 の 之 之 的 之 の 之 之 之 の の 之 の 的 之 之 之 之 の の の 之 の 的 之 之 之 之 之 の の 之 の 的 之 の 之 之 之 の の の 之 的 の 之 之 の の の の の の 的 の 之 之 の 之 の の の の 的 的 の 之 の 之 の の の の の 的 の 之 の 之 之 の の の の 的 の 的 之 の 之 ==================================================
image size: (685, 601)
valid image tokens: 350
output texts tokens (valid): 8192
compression ratio: 23.41
==================================================
===============save results:===============
image: 0it [00:00, ?it/s]
other: 0it [00:00, ?it/s]
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.