Skip to content

Instantly share code, notes, and snippets.

@Ksen17
Last active August 26, 2018 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ksen17/1d483b04e5d7f1f63bc52666eff9c308 to your computer and use it in GitHub Desktop.
Save Ksen17/1d483b04e5d7f1f63bc52666eff9c308 to your computer and use it in GitHub Desktop.
Code for training style transfer model and converting it to Core ML format
import turicreate as tc
#Here you should put path to images which already contains styles
style = tc.load_images('style/')
#Here you should put path to images which is used for train
content = tc.load_images('content/')
#Main function which train model| max_itearation should be find experimentaly
model = tc.style_transfer.create(style, content, max_iterations=50)
#Here you should put path to images which is used for test
test_images = tc.load_images('test/')
#Testing
stylized_images = model.stylize(test_images)
#Open explorer to see if everything works correctly
stylized_images.explore()
#export Core Ml model
model.export_coreml("styles.mlmodel")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment