add prompt in image alt text

main
gabe 2 years ago
parent 123a010c0f
commit 870a7a3d91

109
.gitignore vendored

@ -1,3 +1,10 @@
#secrets
.env
#logs etc
tweets.txt
tweets.log
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/
*.py[cod] *.py[cod]
@ -20,110 +27,8 @@ parts/
sdist/ sdist/
var/ var/
wheels/ wheels/
pip-wheel-metadata/
share/python-wheels/ share/python-wheels/
*.egg-info/ *.egg-info/
.installed.cfg .installed.cfg
*.egg *.egg
MANIFEST MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/

@ -4,7 +4,12 @@ import tweepy
from dotenv import load_dotenv from dotenv import load_dotenv
import os import os
import sys import sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--filename", type=str)
parser.add_argument("--prompt", type=str)
args = parser.parse_args()
load_dotenv() load_dotenv()
# Authenticate to Twitter # Authenticate to Twitter
@ -15,8 +20,8 @@ auth.set_access_token(os.getenv("TOKEN"), os.getenv("TOKENSECRET"))
api = tweepy.API(auth) api = tweepy.API(auth)
# Create a tweet # Create a tweet
media = api.media_upload(sys.argv[1]) media = api.media_upload(args.filename)
alt_text = api.create_media_metadata(media.media_id, args.prompt)
tweet = "" tweet = ""
api.update_status(status=tweet, media_ids=[media.media_id]) api.update_status(status=tweet, media_ids=[media.media_id])

@ -3,5 +3,6 @@
CONTAINER=$(/snap/bin/docker ps | grep miniconda | awk '{print $1}') CONTAINER=$(/snap/bin/docker ps | grep miniconda | awk '{print $1}')
/snap/bin/docker exec -i $CONTAINER /sd/run.sh /snap/bin/docker exec -i $CONTAINER /sd/run.sh
IMAGE="$(ls /home/gabe/stable-diffusion/outputs/*.png -t | head -n1)" IMAGE="$(ls /home/gabe/stable-diffusion/outputs/*.png -t | head -n1)"
PROMPT="$(echo $IMAGE | awk -F/ '{ print $6 }' | sed 's/.\{4\}$//')"
/home/gabe/realesrgan/realesrgan-ncnn-vulkan -i "$IMAGE" -o /tmp/upscaled.png /home/gabe/realesrgan/realesrgan-ncnn-vulkan -i "$IMAGE" -o /tmp/upscaled.png
python3 /home/gabe/lofi-imgen/tweet.py /tmp/upscaled.png python3 /home/gabe/lofi-imgen/tweet.py --filename /tmp/upscaled.png --prompt "$PROMPT"

Loading…
Cancel
Save