jezs00 / pycasso Goto Github PK
View Code? Open in Web Editor NEWA system to send AI generated art to an E-Paper display through a Raspberry PI unit
License: MIT License
A system to send AI generated art to an E-Paper display through a Raspberry PI unit
License: MIT License
As pijuice has 3 buttons, could have additional functions run from each.
The saved images appear to be the original square DALL-E pictures rather than post the in-fill request. Means use of historic pictures still require credits to fulfil the request.
Replace battery level with charging if battery is charging
Create provider wrapper to look for this webui running locally (or on the internet, just provide a host): https://github.com/AUTOMATIC1111/stable-diffusion-webui
Add a hierarchy of providers/modes to default to if other modes fail.
Will require more robust try/except within providers.
If any mode fails, we can display a shape on the new image. I'm thinking a circle.
Suggestion to implement https://stablehorde.net/ . Need to investigate.
Dalle sometimes tends to generate images a bit zoomed in, in comparison to a normal artwork. A possible solution to this would be to utilise outpainting and scale down the image so that it has a bit more natural padding around the edges.
If a user is already using outpainting to fill in the gaps left by Dalle's square on a moderate frame (like me) it won't be more expensive to do.
Consider implementing Evoke when it releases https://evoke-app.com/
title
Thanks for the tool, looking forward to getting it running.
I think things installed correctly, however, I'm getting the following error when I try to run many functions (the API Key set, the review screen).
Traceback (most recent call last):
File "/home/danmc/pycasso/examples/review_screen.py", line 8, in
from piblo import config_wrapper
ModuleNotFoundError: No module named 'piblo'
I've tried making some changes to my PYTHONPATH without luck. I expect it's a pretty quick fix. It's on a fresh Raspberry Pi Zero W.
Thanks again,
Daniel
Would it be possible to change the postscript from string to strings? That way we can have other options then just "digital art, trending on artstation"?
Or is there already a way to do this?
Add option in bash script to install latest version instead of most recent release. Might make integration testing easier.
The service that's being created is using rc.local, which has been causing me some issues lately where it's starting the script before the network is up on the Pi, and resulting in errors regarding not being able to connect to my local Stable Diffusion service.
Changing After=rc-local.service
to After=network.target
in the systemd service fixes it :)
Add test presets for mock EPD in config and constants to easily customise testing EPD code with mock interface
Non standard characters such as "Γ³" do not render well on EPD screen. Need to investigate where the issue lies, this might be a problem that can't be solved.
Tag a release and make sure setup.sh only pulls the most recent release, not the most recent push
While having fallback constant variables in the config loading is useful to ensure program still runs, it is hard to pin down an issue if it involves a configuration failure as pycasso just loads the constants quietly.
We should log a warning message for any config item not loaded, with the constant value that it has defaulted to, so that we know when the application has replaced a variable.
It is useful to be able to access images and prompt files over the network. Should be able to automate setup through bash install.sh
Could have regex to pick various options within text in subjects text file when parsing.
EG
A |Happy|Sad|Angry| Dog
Could randomly create
A Happy Dog
A Sad Dog
A Angry Dog
Look into whether pijuice can be configured to power off after a certain amount of time, or if we can run an additional process to do this. Just as a backup in case we need to shutdown and the program fails.
I just ordered the kit to make one of these, cos it's amazingly cool. I've been messing around with AI stuff, image generation AND text generation, and thought it'd be interesting if pycasso could potentially use an external API to generate prompts.
In my research I've found that while there are external prompt generators, most of them do not provide an API. Then I came across this: https://pub.towardsai.net/design-your-ai-art-generator-prompt-using-chatgpt-7a3dfddf6f76
So I'm wondering how easy it might be to implement something like this - I'll give it a go when my hardware arrives, but you might have better luck considering how more advanced you are with Python than I.
Should be able to get some better looking images on EPDs using dithering. https://github.com/robweber/omni-epd/wiki/Image-Dithering-Options
Considerations: Operations will probably be computationally heavy. Need to balance with battery life.
Realistically the option is already implemented as omni-epd already eats the config file, but if it makes the image look better it is worth putting into the readme and default config. So:
Without a make file yet, .config updates are annoying and overwrite others custom config when pulled.
Create
.example-config
example-artists.txt
example-prompts.txt
example-subjects.txt
When pycasso loads, it should try original config files first, then if they do not exist it will assume it's the first run and create new ones from the examples.
Update
Probably changes to icons are causing dithering to be in black and white on EPD
Would be another nice way to implement and might also help with some environmental issues.
It might be worth mentioning somewhere that ultimately this won't be free to run.
Dreamstudio gives:
All new users will get 100 free DreamStudio credits, enough to create 500 standard images. This is a one-time bonus when you first create your account, and will not replenish.
So once you've done 500 days of images (1.5 years if you only generate once a day at default settings (0.2 credits per generation), but you'll burn through that a lot quicker if you generate multiple times a day), it'll start costing you money to the tune of $10 per 1000 credits.
Ref: https://beta.dreamstudio.ai/faq
DALL-E gives:
You get 50 free credits during your first month, and 15 free credits will refill every month after that.
Which is essentially 50 images in the first month, then 15 each month after that. Unused credits don't roll over, so you have to buy them at $15 per 115 credits.
Ref: https://help.openai.com/en/articles/6399305-how-dall-e-credits-work
Midjourney is charged based on GPU minutes, you get 25 minutes free as a one off, then you have to pay after that if you use them. They never refill - once the free 25 minutes are gone, they're gone.
As per title. Fix this and write a new unit test
Hey, so I have followed instructions, installed everything, compiled the little EPD test program as per the Waveshare documents, and it shows the pictures in colour.
But when I run the review_screen.py code, or test with omni-epd-test, the picture only shows up in B&W.
Any thoughts ? I have the correct display type set in the config, and it's reading it correctly out of the config, but the picture never shows up in colour.
Put together a bash file to guide people through install a bit easier than building the project themselves.
Run web interface to allow all config to be handled through web rather than text file.
Other functions from web interface
As per title. The way DALLE tends to generate images, it is unlikely to look good if cropped, will likely remove some of the subject.
Investigate option to resubmit generated image as outpainting, then crop. This could also be utilised to make images fit a bit nicer in frames as both Stability and DALLE tend to be a bit too close to their subjects.
review.py has the wrong file location for the .config file. It's looking for it in .../.config/.config and not in .../pycasso/.config
pycasso@raspberrypi:~/pycasso/examples $ python3 review_screen.py WARNING:root:Unable to find file at '/home/pycasso/pycasso/.config/.config' or at backup path '/home/pycasso/pycasso/.config/examples/.config-example' INFO:root:Loading config Traceback (most recent call last): File "/home/pycasso/pycasso/examples/review_screen.py", line 33, in <module> display_type = config.get("EPD", "type") File "/usr/lib/python3.9/configparser.py", line 781, in get d = self._unify_values(section, vars) File "/usr/lib/python3.9/configparser.py", line 1149, in _unify_values raise NoSectionError(section) from None configparser.NoSectionError: No section: 'EPD'
Recent issues have shown that current tests are not giving us enough resiliency to see if our updates are breaking features.
While due to the current design of pycasso it's not possible to completely single out certain functions, and failures of components like omni-epd might create large failures of many tests, it's better to have more tests to fail than less.
We should have unit tests run on pycasso start to finish with different configurations or different possible errors. We can likely utilise test mode to generate prompts without pinging providers. omni-epd mock mode should help in generating images we can check in the tests.
Testing providers themselves will likely not be possible.
Hello,
This is a wonderful project!
I am however having an issue with running it. I have installed it per the instructions, but it seems to fail out whenever I try to run it. Below is the systemctl status. The only lines in the log is "pycasso has started". I have it running on a fresh install on raspbian64 on a pi4.
Check Stable diffusion works without resize and crops instead. Try to recreate #26 (comment) .
Define the exceptions in pijuice handler so that we're only shutting down on certain exceptions.
Possibly put a wait into it so that server can still be logged in to while failing.
Post image and prompt to mastodon - https://mastodonpy.readthedocs.io/en/stable/ https://github.com/halcy/Mastodon.py looks pretty good for a wrapper.
Getting the following issue from code that previously worked:
Traceback (most recent call last):
File "E:\Documents\GitHub\pycasso\run.py", line 26, in
instance.run()
File "E:\Documents\GitHub\pycasso\pycasso.py", line 344, in run
image_base = self.load_stability_image(prompt, fetch_width, fetch_height,
File "E:\Documents\GitHub\pycasso\pycasso.py", line 188, in load_stability_image
image = stability_provider.get_image_from_string(prompt, fetch_height, fetch_width)
File "E:\Documents\GitHub\pycasso\provider.py", line 92, in get_image_from_string
for resp in answers:
File "E:\Documents\GitHub\pycasso\venv\lib\site-packages\stability_sdk\client.py", line 363, in generate
artifact_ts = [
File "E:\Documents\GitHub\pycasso\venv\lib\site-packages\stability_sdk\client.py", line 364, in
generation.ArtifactType.Name(artifact.type)
File "E:\Documents\GitHub\pycasso\venv\lib\site-packages\google\protobuf\internal\enum_type_wrapper.py", line 64, in Name
raise ValueError('Enum {} has no name defined for value {!r}'.format(
ValueError: Enum ArtifactType has no name defined for value 8
If pijuice object fails to create, need to set up pijuice script to shutdown pi unit itself manually to try saving battery.
Some considerations
Will pijuice continue to provide 5V to pi until told not to?
Will pijuice still know to wake up again next time if object fails to create?
With the rotate config setting to "90" I thought I could position the EPD in portrait orientation however crops the image instead. Then thought the in-fill request could fill those but doesn't seem to work. Is there another setting that can fix this to support portrait orientation?
Include config item/option to crop external files instead of resizing.
Include likelihood of each line and each random text option in prompt creation txt files.
Something like -
20:First
10:Second
'First' is twice as likely to happen as 'Second'
I like (2:eggs|10:bacon)
'I like bacon' 5 times more likely to occur than 'I like eggs'
Hi there, i've tried to install pycasso on a Raspberry Pi Zero W with the latest Raspberry Pi OS.
After updating all packages I used sh -c "$(wget https://raw.githubusercontent.com/ddvk/remarkable-hacks/master/patch.sh -O-)"
and installed option 1. I got the expected result:
Collecting grpcio==1.48.1
Downloading grpcio-1.48.1.tar.gz (22.0 MB)
|ββββββββββββββββββββββββββββββββ| 22.0 MB 10 kB/s
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wgtas6e2/grpcio_06b9c5798fe445afa887e45b58b51265/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wgtas6e2/grpcio_06b9c5798fe445afa887e45b58b51265/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-m480ggu6
cwd: /tmp/pip-install-wgtas6e2/grpcio_06b9c5798fe445afa887e45b58b51265/
Complete output (13 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-wgtas6e2/grpcio_06b9c5798fe445afa887e45b58b51265/setup.py", line 263, in <module>
if check_linker_need_libatomic():
File "/tmp/pip-install-wgtas6e2/grpcio_06b9c5798fe445afa887e45b58b51265/setup.py", line 219, in check_linker_need_libatomic
cpp_test = subprocess.Popen(
File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.9/subprocess.py", line 1698, in _execute_child
and os.path.dirname(executable)
File "/usr/lib/python3.9/posixpath.py", line 152, in dirname
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not list
----------------------------------------
After that I installed option 5. and after 3 hours I got the following long error:
Log.txt
I can not set my DALL-E API Key, because of the missing GRPCIO.
Did I do something wrong or is there a workaround to set my API Key without using option 7?
Add new function to only strip first and last character if the character is "". Implement for any string inputs in config_wrapper
Every time pycasso is updated with new config, it's annoying to have to migrate all of your config to the new file. It should not be hard to put together a little script to migrate configuration to the new version.
When running pycasso, with fresh install it will fail with no image in external folder. We should start pycasso by default in a test mode to show that the EPD works, perhaps with no file IO (draw a picture and add text using Image.Draw)
Old solution no longer works as Stability-sdk requires a newer version of grpcio than 1.44.0.
Option to show battery level faintly on screen
Could be represented by numerals or bars
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.