Open Assamita76 opened 6 months ago
It is possible, but not a part of the current Lumina program. I will add this to the roadmap for future iterations.
Great! Thank you!
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
I will add this functionality soon.
The ability to save generated images by voice command has been added. Please see the README file.
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.
MtDev12oz The filename line of my code
dallefile = 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:
dallefile = "image/" + prompt2 + "" + now + ".png"
Else you could make a fully qualified path from the root Linux folder like
dallefile = "/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
Hi!
It's possible to download/save the created images?