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

model already load,but the error is model is not loaded #2

Closed
C4712 opened this issue Oct 31, 2022 · 44 comments
Closed

model already load,but the error is model is not loaded #2

C4712 opened this issue Oct 31, 2022 · 44 comments
Assignees
Labels
bug Something isn't working

Comments

@C4712
Copy link

C4712 commented Oct 31, 2022

image

image

image

@kadirnar
Copy link
Owner

kadirnar commented Nov 1, 2022

Hi @C4712

Are you working locally? Are you using a custom model? Can you check the yolov7_model_path variable?

@kadirnar kadirnar self-assigned this Nov 1, 2022
@kadirnar kadirnar added the bug Something isn't working label Nov 1, 2022
@IdrissSinapan974
Copy link

IdrissSinapan974 commented Dec 8, 2022

Hi !
I have same error, I work locally, I use a custom model and my yolov7_model_path variable is correct (path to the weight I obtained after training).
It worked the last time and now I don't know why It is not the case.
Thank you :)

@kadirnar
Copy link
Owner

kadirnar commented Dec 8, 2022

Can you share the error message? Are you using the colab file?

@IdrissSinapan974
Copy link

IdrissSinapan974 commented Dec 8, 2022

load2
load

I clone the repo in my computer, because I have to much data to import on colab...

@kadirnar
Copy link
Owner

kadirnar commented Dec 8, 2022

@IdrissSinapan974
Copy link

IdrissSinapan974 commented Dec 8, 2022

script

Yes, I use the .ipynb file, I copy and past what I need and adapt the lines for my case. (yolov.pt is the weight I obtained after training )

@beratersari
Copy link

Same Issue

@IdrissSinapan974
Copy link

Resolved !
In model.py file, in "class Yolov7DetectionModel(DetectionModel):" they used torch.hub.load(...) and for this you need internet connection.... For my case, I tested the code, but after that I use it in a computer without internet connection. And this error appear.
Hope it will help.

@beratersari
Copy link

I have an internet connection already. Do you use custom model? The original yolov7.pt works for me. But my custom model doesnt work

@IdrissSinapan974
Copy link

IdrissSinapan974 commented Dec 9, 2022

I did yolov7 training on my custom dataset, so I obtain best.pt. Then I used the obtain weight (best.pt renamed yolov7.pt) in SAHI. Do you have the exact same error (Model is not loaded ) ?

@kadirnar
Copy link
Owner

kadirnar commented Dec 9, 2022

@IdrissSinapan974

Does the error go away when I type the filename yolov7.pt?

@IdrissSinapan974
Copy link

@kadirnar no, the filename have no effect on this issue (for my case). I changed the filename to something different to "yolov7.pt" and it works too.

@pythoncodeAshisH
Copy link

In model.py file, in "class Yolov7DetectionModel(DetectionModel):" they used torch.hub.load(...)

but In my case i have good internet connection still i got error

@IdrissSinapan974
Copy link

IdrissSinapan974 commented Dec 14, 2022

@pythoncodeAshisH, can you share the code section which gives you this error please ?

@pythoncodeAshisH
Copy link

@IdrissSinapan974 Sure....!

how to solve this error
Untitled

@kadirnar
Copy link
Owner

@pythoncodeAshisH
Can you share your model? I will update the yolov7-pip package this week. I'll add it to the SAHI algorithm.

Can you try to load your custom model using Yolov7_hubconf?
https://github.com/WongKinYiu/yolov7/blob/main/hubconf.py

This bug is related to the yolov7 repo. To fix this, we can open a Pull Request.

@beratersari
Copy link

@pythoncodeAshisH Hey, I am also getting error from the predictor which is on the beginning of the notebook. Use the prediction function which is at the end of the notebook. I shared a screenshot below. Use that

image

@IdrissSinapan974
Copy link

@pythoncodeAshisH Try to do like @beratersari suggested it should work. There is different way to use SAHI (for only one picture, or a folder containing a lot of pictures).
If you absolutely need the structure like you are trying to use I will try to post a screenshot of this case of use.

@pythoncodeAshisH
Copy link

I am trying to use the instant segment model yolov7-seg.pt in sahi

@kadirnar
Copy link
Owner

kadirnar commented Dec 16, 2022

@pythoncodeAshisH
You should write the instance segmentation results in the bool_mask variable.
https://github.com/kadirnar/Yolov7-SAHI/blob/main/sahi/model.py#L1154

@kadirnar
Copy link
Owner

@msdiki
Copy link

msdiki commented Dec 28, 2022

Hi, getting the same error using the older version of this repo. When I use updated version with yolov7hub or yolov7pip, it automatically downloads a traced.pt and does not load my custom model. Earlier, it was working fine. Not sure what to try next.

result = get_sliced_prediction(
File "/home/sdki/.conda/envs/SAHI/lib/python3.10/site-packages/sahi-0.10.7-py3.10.egg/sahi/predict.py", line 239, in get_sliced_prediction
File "/home/sdki/.conda/envs/SAHI/lib/python3.10/site-packages/sahi-0.10.7-py3.10.egg/sahi/predict.py", line 91, in get_prediction
File "/home/sdki/.conda/envs/SAHI/lib/python3.10/site-packages/sahi-0.10.7-py3.10.egg/sahi/model.py", line 1114, in perform_inference
ValueError: Model is not loaded, load it by calling .load_model()

@danial880
Copy link

I am getting the same error with the new version. It is unable to load a custom model.

@kadirnar
Copy link
Owner

@danial880 , @msdiki

Can you share the sahi and yolov7 versions?

@danial880
Copy link

danial880 commented Dec 29, 2022

sahi: 0.11.6
yolov7detect: 0.3.1
@kadirnar, please let me know if you need something else

@kadirnar
Copy link
Owner

kadirnar commented Dec 29, 2022

Where are you running the demo.py file? You have to run it in the yolov7-sahi/ directory. It may throw an error in the demo folder.

sahi: 0.11.6 yolov7detect: 0.3.1 @kadirnar, please let me know if you need something else

@kadirnar kadirnar reopened this Dec 29, 2022
@danial880
Copy link

I am not using it inside sahi/directory. I have installed your repo using "python setup.py install", and used it in a script.

@kadirnar
Copy link
Owner

Orijinal Repo: https://github.com/obss/sahi
I just added yolov7 and tensorflowhub model support. To use this repo, you must:

git clone https://github.com/kadirnar/Yolov7-SAHI
cd Yolov7-SAHI

Open a new python file and run the following codes:

Yolov7: https://github.com/kadirnar/Yolov7-SAHI/blob/main/demo/yolov7_demo.py
TensorFlowHub: https://github.com/kadirnar/Yolov7-SAHI/blob/main/demo/tensorflowhub_demo.py

You have to run these files in the yolov7-sahi folder.

@CesareDavidePace
Copy link

how resolve this problem?

@kadirnar kadirnar reopened this Jan 4, 2023
@kadirnar
Copy link
Owner

kadirnar commented Jan 4, 2023

How did you install? What is the error message? @CesareDavidePace

@CesareDavidePace
Copy link

I just clone the repository.
And this is the error
Cattura

@kadirnar
Copy link
Owner

kadirnar commented Jan 5, 2023

Did you run the example yolov7-demo.py file inside the Yolov7-SAHİ folder?

@danial880
Copy link

danial880 commented Jan 5, 2023

I was facing a similar problem. In my scenario, I had to use yolov7-sahi in my project. Therefore I cannot use yolov7-demo.py from inside the yolov7-sahi folder. But the previous version of this repository works fine with custom models and runs from outside the yolov7-sahi folder after installation. Old Version

@kadirnar
Copy link
Owner

kadirnar commented Jan 5, 2023

@danial880 @CesareDavidePace ,
The yolov7_hub module is running slow. You have to use the pip version. Can you download the repo and run the yolo7_demo.py file? I tested it now and it works.

git clone https://github.com/kadirnar/Yolov7-SAHI
cd Yolov7-SAHI

Env:

yolov7detect==0.3.1

Run

python yolov7_demo.py

Result:

prediction_visual

@kadirnar
Copy link
Owner

kadirnar commented Jan 5, 2023

This week I will add the SAHI algorithm to this library. You will use it more easily.
kadirnar/torchyolo#9

@CesareDavidePace
Copy link

Cattura2

@kadirnar
Copy link
Owner

kadirnar commented Jan 5, 2023

Cattura2

pip uninstall sahi

@CesareDavidePace
Copy link

Cattura3

@kadirnar
Copy link
Owner

kadirnar commented Jan 5, 2023

@CesareDavidePace
Copy link

Cattura4

@kadirnar
Copy link
Owner

kadirnar commented Jan 5, 2023

Did the yolov7.pt file download while running this file? Can you print for the self.model_path variable on line 20 of the Yolov7pip.py file?

@CesareDavidePace
Copy link

Yes, the file has been downloaded.
After install yolov7detect the script work.

But in my file i have the same problem

@CesareDavidePace
Copy link

Okay I restarted the kernel and everything works fine now. Thanks for your huge help!

@kadirnar
Copy link
Owner

kadirnar commented Jan 5, 2023

This is great. This week I will release the pip package for the yolov7-sahi repository. Good luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants