Yi icon indicating copy to clipboard operation
Yi copied to clipboard

Error when trying to run quick start code

Open sudhir2016 opened this issue 1 year ago • 3 comments

Reminder

  • [X] I have searched the Github Discussion and issues and have not found anything similar to this.

Environment

- OS:
- Python:
- PyTorch:
- CUDA:

Current Behavior

Getting this error when single_inference.py is trying to load model from HF Hub.

huggingface_hub.utils._validators.HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': '../model/Yi-VL-6B'. Use repo_type argument if needed.

Expected Behavior

Load should load.

Steps to Reproduce

I was using this code provide for quick start in Google Colab free tier.

! CUDA_VISIBLE_DEVICES=0 python /content/Yi/VL/single_inference.py --model-path ../model/Yi-VL-6B --image-file images/cats.jpg --question "Describe the cats and what they are doing in detail."

Anything Else?

Nil

sudhir2016 avatar Jan 25 '24 15:01 sudhir2016

I have successfully launched the demo in Google Colab with this line of code:

!CUDA_VISIBLE_DEVICES=0 python /content/Yi/VL/single_inference.py --model-path ./Yi-VL-6B --image-file Yi/VL/images/cats.jpg --question "Describe the cats and what they are doing in detail."

Notice that my folder looks something like this:

|-- content
|   |-- Yi
|   |-- Yi-VL-6B
|   |-- sample_data

and here is the output:

----------
question: Describe the cats and what they are doing in detail.
outputs: In the image, there are three cats situated on a stone floor. The cat on the left is a calico cat, its coat a mix of white, orange, and black. It's standing and eating from a metal bowl. The middle cat is a gray cat, also standing and eating from a metal bowl. The cat on the right is a black cat, sitting and eating from a plastic bowl. The cats are all facing away from the camera, engrossed in their meal. The stone floor they're on is gray, providing a neutral backdrop to the colorful spectacle of the cats.
----------

I think the issue is probably due to the incorrect model path. If you can paste your directory structure, that would be helpful.

markli404 avatar Jan 25 '24 16:01 markli404

My directory is different from yours. I used this code to set us environment.

!git clone https://github.com/01-ai/Yi.git !cd Yi/VL !export PYTHONPATH=$PYTHONPATH:$(pwd) !pip install -r requirements.txt

Please suggest.

sudhir2016 avatar Jan 25 '24 18:01 sudhir2016

!git clone https://github.com/01-ai/Yi.git !cd Yi/VL !export PYTHONPATH=$PYTHONPATH:$(pwd) !pip install -r requirements.txt

The cd command in colab notebook needs to start with %, so you can either try

!git clone https://github.com/01-ai/Yi.git
%cd Yi/VL
!export PYTHONPATH=$PYTHONPATH:$(pwd)
!pip install -r requirements.txt

or

!git clone https://github.com/01-ai/Yi.git
!pip install -r ./Yi/VL/requirements.txt

Hope this solves the problem!

markli404 avatar Jan 25 '24 19:01 markli404

Thank you. Still getting this error. OSError: Incorrect path_or_model_id: './Yi-VL-6B'. Please provide either the path to a local folder or the repo_id of a model on the Hub. My directory structure is still different from yours. Sharing my notebook. https://colab.research.google.com/drive/1jBT5BM10boMaEW5no1qfugc-_nfmmatG?usp=sharing

sudhir2016 avatar Jan 26 '24 09:01 sudhir2016

Thank you. Still getting this error. OSError: Incorrect path_or_model_id: './Yi-VL-6B'. Please provide either the path to a local folder or the repo_id of a model on the Hub. My directory structure is still different from yours. Sharing my notebook. https://colab.research.google.com/drive/1jBT5BM10boMaEW5no1qfugc-_nfmmatG?usp=sharing

It seems like the model has not been downloaded in your notebook. Please add a new code cell at the beginning, and run the following code:

!git lfs install
!git clone https://huggingface.co/01-ai/Yi-VL-6B

This will download the weight of the Yi-VL-6B model to your Colab working directory (It takes about 10-15 minutes to download). Then, run the remaining cells

!git clone https://github.com/01-ai/Yi.git
%cd Yi/VL
!export PYTHONPATH=$PYTHONPATH:$(pwd)
!pip install -r requirements.txt

Notice that since you have changed your working directory by %cd Yi/VL, therefore the code in the last cell might need to be modified to accommodate that:

!CUDA_VISIBLE_DEVICES=0 python /content/Yi/VL/single_inference.py --model-path /content/Yi-VL-6B --image-file /content/Yi/VL/images/cats.jpg --question "Describe the cats and what they are doing in detail."

Here I changed all related paths to absolute paths.

markli404 avatar Jan 26 '24 15:01 markli404

Thank you so much @markli404 !!. It works now.

sudhir2016 avatar Jan 26 '24 18:01 sudhir2016