LAION-AI / ldm-finetune

Home of `erlich` and `ongo`. Finetune latent-diffusion/glid-3-xl text2image on your own data.
MIT License
182 stars 19 forks source link

Artistic prompts missing #1

Closed Tymski closed 2 years ago

Tymski commented 2 years ago

Hello, what should be the contents of artistic_prompts.json? It is used in sample.py, but it is missing. Running the sample returns an error.

 File "C:\Projects\clones\ldm-finetune\sample.py", line 749, in <module>
    prompts = json.load(open(prompt_file))
FileNotFoundError: [Errno 2] No such file or directory: 'artistic_prompts.json'
Kreevoz commented 2 years ago

Looking at the code, the file would likely just contain several text prompts for testing purposes? Maybe? How it would be generated I'm not sure. I have a horrible, hacky workaround to offer! 😁

You could try doing something like this:

Comment out the lines for prompt_file and prompts as well as the existing try: block and replace them with:

prompt=args.text

try:
    print(f"Starting run for\t{prompt}")
    clean_prompt = prompt.replace(" ", "_").replace(".", "")[:80]
    do_run(prompt, prefix=clean_prompt)
    gc.collect()
except KeyboardInterrupt:
    print(f"Canceled, uploading partial results.")

That seems to work for me!

Though I had to git clone https://github.com/LAION-AI/aesthetic-predictor into the ldm-finetune folder first because it was looking for that dependency.

KnoBuddy commented 2 years ago

I tried editing the file as you indicated above but now I receive a different error:

Traceback (most recent call last): File "/home/kyle/ldm-finetune/sample.py", line 752, in <module> do_run(prompt, prefix=clean_prompt) File "/home/kyle/ldm-finetune/sample.py", line 716, in do_run init = Image.open(args.init_image).convert("RGB") File "/home/kyle/.venv/lib/python3.10/site-packages/PIL/Image.py", line 3068, in open fp = builtins.open(filename, "rb") FileNotFoundError: [Errno 2] No such file or directory: 'picture.jpg'

I did try creating an "args.text" file if that alleviated the issue but I got no change.

Tymski commented 2 years ago

Thanks, @Kreevoz that works for me.

Kreevoz commented 2 years ago

I tried editing the file as you indicated above but now I receive a different error:

Traceback (most recent call last): File "/home/kyle/ldm-finetune/sample.py", line 752, in <module> do_run(prompt, prefix=clean_prompt) File "/home/kyle/ldm-finetune/sample.py", line 716, in do_run init = Image.open(args.init_image).convert("RGB") File "/home/kyle/.venv/lib/python3.10/site-packages/PIL/Image.py", line 3068, in open fp = builtins.open(filename, "rb") FileNotFoundError: [Errno 2] No such file or directory: 'picture.jpg'

I did try creating an "args.text" file if that alleviated the issue but I got no change.

You're using the "# sample with an init image" prompt from the readme, right? So it expects you to provide it with an init_image.

If it can't find picture.jpg then maybe you should make and copy one into the folder (of course it can be named anything you like)! Square, 256x256px or whatever size you want to run inference at.

KnoBuddy commented 2 years ago

Thanks I did get it working, however it seems my 2070 Super with 8GB of memory is just barely enough to get a simple result. Well I guess I'll be doing this in the cloud then.