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

Save/download images #6

Open
Assamita76 opened this issue Feb 13, 2024 · 7 comments
Open

Save/download images #6

Assamita76 opened this issue Feb 13, 2024 · 7 comments

Comments

@Assamita76
Copy link

Hi!

It's possible to download/save the created images?

@DevMiser
Copy link
Owner

It is possible, but not a part of the current Lumina program. I will add this to the roadmap for future iterations.

@Assamita76
Copy link
Author

Great! Thank you!

@azwirko
Copy link

azwirko commented Feb 15, 2024

I crudely added the following snippets of code to Lumina.py to add image saving to the local directory. See and copy code between "# AZ" comments and place after an existing quoted line of the original code. You may have to also run a "pip install requests" and "pip install shutil" at your command prompt as well if the imports aren't found.

After Line 20

import urllib.request

# AZ
import requests
import shutil
# AZ end

from openai import OpenAI

then after Line 179

    update_image(image_url) 

    # AZ
    prompt2 = prompt.replace(" ", "-")
    
    now = datetime.datetime.now().strftime('%Y-%m-%d_%H:%M')

    dalle_file = prompt2 + "_" + now + ".png"
    
    response = requests.get(image_url, stream=True)
    with open(dalle_file, 'wb') as out_file:
        shutil.copyfileobj(response.raw, out_file)
    del response
    # AZ end
    
def listen():

For me this produces a filename of the format using the prompt (converting spaces to "-") and appending the yyyy-mm-dd_hh:mm.png

Hack away!

andyz

@DevMiser
Copy link
Owner

I will add this functionality soon.

@DevMiser
Copy link
Owner

The ability to save generated images by voice command has been added. Please see the README file.

@MtDew12oz
Copy link

I like the ability to save on demand but perfer the idea of saving each image as generated. I added azwirko's code to autosave image upon create, seems to be working. I was trying to find a way to save to /home/pi/Lumina/image but I'm going to leave it as is, which is just droping it in /home/

Note: After I put in the code in and rebooted, Lumina would start then crash, displaying nothing but the desktop. Because I don't have a keyboard on it I ssh'd to it, that's when it said there was an issue with line 484 in Lumina.py. This was my orginal key I used when I first set up my account before I funded it. Once I recreated the key, updated the .py file it worked fine. May have nothing to do with this, but if it helps someone else out, this is what worked for me.

@azwirko
Copy link

azwirko commented Mar 1, 2024

MtDev12oz
The filename line of my code

dalle_file = prompt2 + "_" + now + ".png"

is where you could crudely hack in some other directory if you wished. IF a directory "image" existed in the Lumina directory it then would be possible to write something like this instead:

dalle_file = "image/" + prompt2 + "_" + now + ".png"

Else you could make a fully qualified path from the root Linux folder like

dalle_file = "/tmp/" + prompt2 + "_" + now + ".png"

Obviously it would be best to have some config variable at the top of the code rather than hard coding, but this should give u some ideas.

Good luck

andyz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants