mrhan1993 / Fooocus-API

FastAPI powered API for Fooocus
GNU General Public License v3.0
512 stars 137 forks source link

Image Facespaw #81

Closed lherrman closed 6 months ago

lherrman commented 7 months ago

Hello,

Super nice project. Thanks for the great work. Is there any way to use the faceswap feature from Fooocus? Having some option to have consistent facial features accross images would be great for my project.

Best regards

konieshadow commented 7 months ago

@lherrman Sure. You can do it with Fooocus-API by Image Prompt. Just upload a image for cn_img1 and set cn_type1 to "FaceSwap".

An example request:

curl -X 'POST' \
  'http://127.0.0.1:8888/v1/generation/image-prompt' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F 'sharpness=2' \
  -F 'loras=[{"model_name":"sd_xl_offset_example-lora_1.0.safetensors","weight":0.1}]' \
  -F 'cn_img1=@1.jpg;type=image/jpeg' \
  -F 'cn_img2=' \
  -F 'advanced_params=' \
  -F 'guidance_scale=4' \
  -F 'cn_type1=FaceSwap' \
  -F 'cn_img3=' \
  -F 'prompt=a girl sitting next to coffee' \
  -F 'cn_type2=ImagePrompt' \
  -F 'cn_img4=' \
  -F 'cn_weight1=' \
  -F 'cn_type3=ImagePrompt' \
  -F 'cn_weight2=' \
  -F 'cn_type4=ImagePrompt' \
  -F 'cn_weight3=' \
  -F 'cn_weight4=' \
  -F 'require_base64=false' \
  -F 'async_process=false' \
  -F 'image_number=1' \
  -F 'negative_prompt=' \
  -F 'refiner_switch=0.5' \
  -F 'base_model_name=juggernautXL_version6Rundiffusion.safetensors' \
  -F 'image_seed=-1' \
  -F 'style_selections=Fooocus V2,Fooocus Enhance,Fooocus Sharp' \
  -F 'refiner_model_name=None' \
  -F 'cn_stop1=' \
  -F 'aspect_ratios_selection=1152×896' \
  -F 'cn_stop2=' \
  -F 'performance_selection=Speed' \
  -F 'cn_stop3=' \
  -F 'cn_stop4='
lherrman commented 7 months ago

Ah perfect. Thank you!