generative-models icon indicating copy to clipboard operation
generative-models copied to clipboard

No module named 'scripts' when trying to do Inference

Open anda-ren opened this issue 2 years ago • 7 comments

I am doing the inference part as the README step by step. But I suffered No module named 'scripts' when running

streamlit run scripts/demo/sampling.py --server.port <your_port>

Did anyone meet this issue and solve it?

The environment I choosed is pt2

anda-ren avatar Jul 30 '23 06:07 anda-ren

I encountered the same problem, I don’t know how to solve

qiyueliuhuo avatar Jul 30 '23 08:07 qiyueliuhuo

I have the same problem and don't know how to solve it

huang31743 avatar Jul 30 '23 08:07 huang31743

I had the same problem. It is due to python imports logic and the absence of the generative-models/ folder from the system path. I solved adding the following just before the problematic import in sampling.py:

import os, sys sys.path.append(os.path.abspath(os.path.join(os.path.dirname( __file__ ), '../..')))

It manually adds the main repo folder at the beginning of the sys path. There's probably a better way to solve this issue though

NicoDR95 avatar Jul 30 '23 09:07 NicoDR95

On most of my projects I've used this method to add an import path (execute when you are at the project's root folder):

echo $PWD > ~/anaconda3/envs/stability_py310/lib/python3.10/site-packages/stability_ai.pth

nikonyrh avatar Jul 30 '23 15:07 nikonyrh

It's easier to just copy the demo script into the root folder of the repo and run it there.

putnam avatar Jul 31 '23 05:07 putnam

The python system path might not have the current directory. Adding PYTHONPATH=. will resolve this:

PYTHONPATH=. streamlit run scripts/demo/sampling.py --server.port <your_port>

aceysmith avatar Aug 19 '23 23:08 aceysmith

The python system path might not have the current directory. Adding PYTHONPATH=. will resolve this:

PYTHONPATH=. streamlit run scripts/demo/sampling.py --server.port <your_port>

it works!!!

zamlahani avatar Dec 07 '23 14:12 zamlahani