Start a shell inside the container:
cog run bash
This will mount your working directory into /src
inside the container.
When the shell has started, install ipython:
pip install ipython
Start ipython:
ipython
Inside ipython, enable autoreload:
%load_ext autoreload
%autoreload 2
Files you edit inside your working directory will now be changed inside the ipython environment.
Load the predictor:
from predict import Predictor
p = Predictor()
p.setup()
Make a prediction (note that all predict inputs need to be specified, even if they have defaults):
out = p.predict(prompt="a cat", guidance_scale=7.5, seed=0)
To pass in files, use pathlib.Path
:
from pathlib import Path
out = p.predict(init_image=Path("my-image.png"), prompt="a cat", guidance_scale=7.5, seed=0)
You can now edit the predict function and see the changes when you run p.predict()
, without having to reload the model.