[Python] Gradio REST API calls not working outside of Gradio?

Discussão em 'Python' iniciado por Stack, Março 4, 2025.

  1. Stack

    Stack Membro Participativo

    I set up a VTON model in Gradio that takes 2 images as input, and returns an image of the person wearing the clothes submitted in the previous 2 images. When running the API recorder within Gradio, it gives me a script which will mimic the call just made:

    from gradio_client import Client, file

    client = Client("https://5c47fedb2c3a49c2e8.gradio.live/")

    client.predict(
    dict={"background":handle_file('https://5c47fedb2c3a49c2e8.gradio.live/gradio_api/file=/tmp/gradio/b85624d24ac163fd1e2f6e603372d24ea223825f1eb1a72a60a9d30d44b39d85/background.png'),"layers":[handle_file('https://5c47fedb2c3a49c2e8.gradio.live/gradio_api/file=/tmp/gradio/3b5a9ef2815439980a0f8b5725869b157a4bea163aa3c9a628614c26bfac1141/layer_0.png')],"composite":handle_file('https://5c47fedb2c3a49c2e8.gradio.live/gradio_api/file=/tmp/gradio/b85624d24ac163fd1e2f6e603372d24ea223825f1eb1a72a60a9d30d44b39d85/composite.png')},
    garm_img=handle_file('https://5c47fedb2c3a49c2e8.gradio.live/gradio_api/file=/tmp/gradio/db8f2f2d169bf74efb38a963ef0b8cc2a6f23f4ebe574026df737ec5ca10c3d0/guccimane.jpg'),
    garment_des="",
    category="upper_body",
    is_checked=True,
    is_checked_crop=True,
    denoise_steps=20,
    is_randomize_seed=True,
    seed=1,
    number_of_images=1,
    api_name="/tryon"
    )


    This apparently hits XXX.gradio.live/tryon and is able to perform inference on the two images. The API reference also denotes /tryon as an endpoint, seemingly for the exact use case I want to use it for (external API usage).

    Unfortunately, every response I get from any external source (cURL in bash, Postman, Python from my desktop) is just a 404 error. For some reason, it cannot see this endpoint, and I have no idea why.

    Any suggestions as to why this endpoint isn't exposed? Am I just hitting the wrong URL, and if so how could I find the correct one?

    Continue reading...

Compartilhe esta Página