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

AssertionError: Padding_idx must be within num_embeddings, demo.py #528

Open
Lynnzake opened this issue Aug 31, 2024 · 1 comment
Open

Comments

@Lynnzake
Copy link

Describe the bug
during the running of demo.py, when i upload the picture, and chat with the model, it raised error

PS D:\Courses\gitHub Projects\MiniGPT4main> python demo.py --cfg-path eval_configs/minigpt4_eval.yaml  --gpu-id 0                                                                                        
bin C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\bitsandbytes\libbitsandbytes_cuda118.dll
Initializing Chat
Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:30<00:00, 15.40s/it]
Loading Q-Former
C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\huggingface_hub\file_download.py:1150: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
  warnings.warn(
Loading Q-Former Done
Load MiniGPT-4 Checkpoint: D:\Courses\gitHub Projects\MiniGPT4main\pretrained_minigptv\prerained_minigpt4_7b.pth
Initialization Finished
D:\Courses\gitHub Projects\MiniGPT4main\demo.py:171: GradioDeprecationWarning: The `enable_queue` parameter has been deprecated. Please use the `.queue()` method instead.
  demo.launch(share=True, enable_queue=True)
Running on local URL:  http://127.0.0.1:7860

Could not create share link. Please check your internet connection or our status page: https://status.gradio.app.
IMPORTANT: You are using gradio version 3.47.1, however version 4.29.0 is available, please upgrade.
--------
C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\gradio\helpers.py:818: UserWarning: Using the update method is deprecated. Simply return a new object instead, e.g. `return gr.Textbox(...)` instead of `return gr.update(...)
  warnings.warn(
C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\gradio\components\button.py:89: UserWarning: Using the update method is deprecated. Simply return a new object instead, e.g. `return gr.Button(...)` instead of `return gr.Button.update(...)`.
  warnings.warn(
C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\gradio\helpers.py:818: UserWarning: Using the update method is deprecated. Simply return a new object instead, e.g. `return gr.Textbox(...)` instead of `return gr.update(...)
  warnings.warn(
C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\gradio\components\image.py:193: UserWarning: Using the update method is deprecated. Simply return a new object instead, e.g. `return gr.Image(...)` instead of `return gr.Image.update(...)`.
  warnings.warn(
C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\gradio\components\textbox.py:163: UserWarning: Using the update method is deprecated. Simply return a new object instead, e.g. `return gr.Textbox(...)` instead of `return gr.Textbox.update(...)`.
  warnings.warn(
C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\gradio\components\button.py:89: UserWarning: Using the update method is deprecated. Simply return a new object instead, e.g. `return gr.Button(...)` instead of `return gr.Button.update(...)`.
  warnings.warn(
Traceback (most recent call last):
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\gradio\queueing.py", line 406, in call_prediction
    output = await route_utils.call_process_api(
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\gradio\route_utils.py", line 226, in call_process_api
    output = await app.get_blocks().process_api(
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\gradio\blocks.py", line 1554, in process_api
    result = await self.call_function(
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\gradio\blocks.py", line 1192, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\anyio\to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\anyio\_backends\_asyncio.py", line 2177, in run_sync_in_worker_thread
    return await future
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\anyio\_backends\_asyncio.py", line 859, in run
    result = context.run(func, *args)
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\gradio\utils.py", line 659, in wrapper
    response = f(*args, **kwargs)
  File "D:\Courses\gitHub Projects\MiniGPT4main\demo.py", line 112, in gradio_answer
    llm_message = chat.answer(conv=chat_state,
  File "D:\Courses\gitHub Projects\MiniGPT4main\minigpt4\conversation\conversation.py", line 186, in answer
    generation_dict = self.answer_prepare(conv, img_list, **kargs)
  File "D:\Courses\gitHub Projects\MiniGPT4main\minigpt4\conversation\conversation.py", line 162, in answer_prepare
    embs = self.model.get_context_emb(prompt, img_list)
  File "D:\Courses\gitHub Projects\MiniGPT4main\minigpt4\models\minigpt_base.py", line 77, in get_context_emb
    seg_embs = [self.embed_tokens(seg_t) for seg_t in seg_tokens]
  File "D:\Courses\gitHub Projects\MiniGPT4main\minigpt4\models\minigpt_base.py", line 77, in <listcomp>
    seg_embs = [self.embed_tokens(seg_t) for seg_t in seg_tokens]
  File "D:\Courses\gitHub Projects\MiniGPT4main\minigpt4\models\minigpt_base.py", line 314, in embed_tokens
    embeds = self.llama_model.base_model.embed_tokens(token_ids)
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\accelerate\hooks.py", line 165, in new_forward
    output = old_forward(*args, **kwargs)
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\torch\nn\modules\sparse.py", line 163, in forward
    return F.embedding(
  File "C:\Users\12871\anaconda3\envs\minigptv\lib\site-packages\torch\nn\functional.py", line 2219, in embedding
    assert padding_idx < weight.size(0), "Padding_idx must be within num_embeddings"
AssertionError: Padding_idx must be within num_embeddings

Screenshots
image

what's the cause of this problem, and how to solve it, help!

@12138k
Copy link

12138k commented Sep 15, 2024

Do you solve the problem? I meet the same problem.

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

2 participants