diff --git a/Dockerfile b/Dockerfile index d411dea..4b5d8dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM phusion/baseimage:0.10.1 +FROM phusion/baseimage:latest CMD ["/sbin/my_init"] diff --git a/README.md b/README.md index 448f5be..fb82891 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,15 @@ Tweets are available at [@AI_Artify](https://twitter.com/ai_artify). -Image style transfer is done with [Logan Enstrom's](https://github.com/lengstrom) [Fast Style Transfer](https://github.com/lengstrom/fast-style-transfer). \ No newline at end of file +Image style transfer is done with [Logan Enstrom's](https://github.com/lengstrom) [Fast Style Transfer](https://github.com/lengstrom/fast-style-transfer). + +## Quickstart + +Just to quickly test that everything is working locally: + +* Make an Unsplash developer account +* Make a Twitter developer account +* Make credentials.json -> `cp default.json credentials.json` +* Enter your Twitter and Unsplash credentials into `credentials.json` +* Install dependencies (example: `pip3 install -r py3reqs.txt` ) +* `python3 main.py` \ No newline at end of file diff --git a/default.json b/default.json index fc97aa7..dc908ae 100644 --- a/default.json +++ b/default.json @@ -5,5 +5,7 @@ "twitterConsumerSecret": "", "twitterAccessToken": "", "twitterAccessSecret": "", - "myTwitter": "" + "myTwitter": "", + "unsplashID":"", + "callbackURL":"" } \ No newline at end of file diff --git a/main.py b/main.py index 4069cb5..ea47b94 100644 --- a/main.py +++ b/main.py @@ -11,7 +11,7 @@ def getQueryTerm(): return "&query=" + random.choice(['mountains', 'nature', 'forest', 'jungle', 'beach', 'autumn', 'winter', 'summer', 'spring', 'waterfall', 'rain']) def getImage(): - random_url = 'https://api.unsplash.com/photos/random?featured=true' + getQueryTerm() + random_url = 'https://api.unsplash.com/photos/random?featured=true' headers = {'Authorization': 'Client-ID ' + credentials['unsplashAccessId']} img = requests.get(random_url, headers=headers).json() @@ -26,8 +26,9 @@ def getImage(): } def downloadImage(imgURL): + print(imgURL) try: - savePath = '/app/images/input/' + str(random.randint(1,1000)) + '.jpg' + savePath = './images/input/' + str(random.randint(1,1000)) + '.jpg' urllib.request.urlretrieve(imgURL, savePath) time.sleep(5) return savePath @@ -41,7 +42,7 @@ def getArtStyle(): def styleImage(imgPath, stylePath): try: - script = str('python evaluate.py --checkpoint ' + stylePath + ' --in-path ' + '/app/images/input/' + ' --out-path ' + '/app/images/output/' + ' --allow-different-dimensions') + script = str('python evaluate.py --checkpoint ' + stylePath + ' --in-path ' + './images/input/' + ' --out-path ' + './images/output/' + ' --allow-different-dimensions') os.system(script) return imgPath.replace('input','output') @@ -66,11 +67,11 @@ def tweetArt(imgPath, post): def removeImages(): - outputs = glob.glob('/app/images/output/*') + outputs = glob.glob('./images/output/*') for f in outputs: os.remove(f) - inputs = glob.glob('/app/images/input/*') + inputs = glob.glob('./images/input/*') for f in inputs: os.remove(f) diff --git a/py3reqs.txt b/py3reqs.txt index 6c12661..264bf81 100644 --- a/py3reqs.txt +++ b/py3reqs.txt @@ -1,2 +1,2 @@ -tweepy==3.6.0 - +tweepy==3.7.0 +unsplash==1.0.0a2 diff --git a/test.py b/test.py index 6c2d02e..a7e3093 100644 --- a/test.py +++ b/test.py @@ -5,8 +5,8 @@ credentials = json.loads(open("credentials.json").read()) -unsplashAuth = Auth(credentials['unsplashID'], - credentials['unsplashSecret'], +unsplashAuth = Auth(credentials['unsplashAccessId'], + credentials['unsplashSecretId'], credentials['callbackURL']) unsplashApi = Api(unsplashAuth)