Spaces:
Build error
Build error
Download inference_api.py from Ngene787/Faice_text2face: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/spaces/Ngene787/Faice_text2face/resolve/main/inference_api.py
- Command line
-
hf download hf://spaces/Ngene787/Faice_text2face/inference_api.py
-
curl -L -o inference_api.py https://huggingface.co/spaces/Ngene787/Faice_text2face/resolve/main/inference_api.py
1.52 kB
| # -*- coding: UTF-8 -*- | |
| """ | |
| @Time : 30/05/2025 10:45 | |
| @Author : xiaoguangliang | |
| @File : inference_api.py | |
| @Project : Faice_text2face | |
| """ | |
| from gradio_client import Client | |
| inference_url = "https://29f185caa56dd00128.gradio.live" | |
| def api_unconditional(seed, | |
| randomize_seed=False, | |
| num_inference_steps=20): | |
| client = Client(inference_url) | |
| result = client.predict( | |
| seed=seed, | |
| randomize_seed=randomize_seed, | |
| num_inference_steps=num_inference_steps, | |
| api_name="/inference_unconditional" | |
| ) | |
| return result | |
| def api_class_guidance(label_name, | |
| seed=0, | |
| randomize_seed=False, | |
| num_inference_steps=20): | |
| client = Client(inference_url) | |
| result = client.predict( | |
| label_name=label_name, | |
| seed=seed, | |
| randomize_seed=randomize_seed, | |
| num_inference_steps=num_inference_steps, | |
| api_name="/inference_class_guidance" | |
| ) | |
| return result | |
| def api_sd(prompt, | |
| negative_prompt="", | |
| seed=0, | |
| randomize_seed=False, | |
| guidance_scale=7.5, | |
| num_inference_steps=20): | |
| client = Client(inference_url) | |
| result = client.predict( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| seed=seed, | |
| randomize_seed=randomize_seed, | |
| guidance_scale=guidance_scale, | |
| num_inference_steps=num_inference_steps, | |
| api_name="/inference_sd" | |
| ) | |
| return result | |