Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM phusion/baseimage:0.10.1
FROM phusion/baseimage:latest

CMD ["/sbin/my_init"]

Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
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`
4 changes: 3 additions & 1 deletion default.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"twitterConsumerSecret": "",
"twitterAccessToken": "",
"twitterAccessSecret": "",
"myTwitter": ""
"myTwitter": "",
"unsplashID":"",
"callbackURL":""
}
11 changes: 6 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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')

Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions py3reqs.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
tweepy==3.6.0

tweepy==3.7.0
unsplash==1.0.0a2
4 changes: 2 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down