Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small API sample #663

Open
joaquingrech opened this issue May 6, 2024 · 2 comments
Open

Small API sample #663

joaquingrech opened this issue May 6, 2024 · 2 comments
Labels
enhancement New feature or request Stale

Comments

@joaquingrech
Copy link

We are missing a small API sample. I used the recorder to figure out what it is sending out and expecting, but it seems to be something else hidden. I checked all files in this API requests and they are fully alpha transparent images. None make sense and no idea what they are used for since they are none of the images (source and target) I placed.

An example on how to do a basic face swap using the API would be great appreciated.

Here is the API that the recorder returned. They contain an imagemask with 3 files, but those files are transparent and who knows what they are...

client.predict(
enhancer="GFPGAN",
detection="First found",
keep_frames=True,
wait_after_extraction=False,
skip_audio=True,
face_distance=1,
blend_ratio=1,
selected_mask_engine="None",
clip_text="cup,hands,hair,banana",
processing_method="In-Memory processing",
no_face_action="Use untouched original frame",
vr_mode=False,
autorotate=True,
num_swap_steps=1,
imagemask={"background":file('http://127.0.0.1:7862/file=D:\\roop-unleashed\\roop-unleashed\\installer\\roop-unleashed\\temp\\d0b0e0d125e4fdaed3846375fae0b0c75b354b6b\\background.png'),"layers":[file('http://127.0.0.1:7862/file=D:\\roop-unleashed\\roop-unleashed\\installer\\roop-unleashed\\temp\\d0b0e0d125e4fdaed3846375fae0b0c75b354b6b\\layer_0.png')],"composite":file('http://127.0.0.1:7862/file=D:\\roop-unleashed\\roop-unleashed\\installer\\roop-unleashed\\temp\\d0b0e0d125e4fdaed3846375fae0b0c75b354b6b\\composite.png')},
api_name="/start_swap"
)

client.predict(
files=[file('http://127.0.0.1:7862/file=D:\roop-unleashed\roop-unleashed\installer\roop-unleashed\temp\714acf6b840fb080b0843c04cec3662112836674\65e2163827107599e688_bf2c2889db294ac6ad0c1a07bfab0b20_23-28-20.webp')],
api_name="/on_resultfiles_finished"
)

@C0untFloyd
Copy link
Owner

It sounds like you want to integrate this into something bigger, you know that this can't be used for commercial stuff?
Anyway, to remotely control this you'd need to do the same steps as the user, meaning you don't have just 1 API call but several.
Never used this myself but roughly (for a minimal example without selecting faces whatsoever) it should be calling:

# select source image
result = client.predict(
		srcfiles=[file('https://someimage.jpg')],
		api_name="/on_srcfile_changed"
)
# select target file
result = client.predict(
		destfiles=[file('https://somemovieorimage.jpg')],
		api_name="/on_destfiles_changed"
)
# go,go,go!
result = client.predict(
		enhancer="None",
		detection="First found",
		keep_frames=False,
		wait_after_extraction=False,
		skip_audio=False,
		face_distance=0.65,
		blend_ratio=0.65,
		selected_mask_engine="None",
		clip_text="cup,hands,hair,banana",
		processing_method="In-Memory processing",
		no_face_action="Use untouched original frame",
		vr_mode=False,
		autorotate=True,
		num_swap_steps=1,
		imagemask={"background":file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'),"layers":[],"composite":None},
		api_name="/start_swap"
)

Imagemask can be set to None, it's the manual mask.

@C0untFloyd C0untFloyd added the enhancement New feature or request label May 7, 2024
Copy link

github-actions bot commented Jun 7, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Stale
Projects
None yet
Development

No branches or pull requests

2 participants