Skip to content

Instantly share code, notes, and snippets.

@psychelzh
Last active October 5, 2022 02:03
Show Gist options
  • Save psychelzh/5184f5f9719e6d754d51f9acd9b39a8d to your computer and use it in GitHub Desktop.
Save psychelzh/5184f5f9719e6d754d51f9acd9b39a8d to your computer and use it in GitHub Desktop.
Simple http response from R

Use API of facemorph

StyleGAN2 is very powerful. The project facemorph is based on it, and there is an API for the website. Here I show an example how to use the API from R, which is basically based on {httr} pacakge.

library(httr)
api_url <- "https://api.facemorph.me/api/encodeimage/"
resp <- POST(
  api_url, 
  body = list(
    tryalign = TRUE, 
    usrimg = upload_file("path/")
  ),
  encode = "multipart"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment