File size: 1,315 Bytes
c41cba9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
This module provides a command-line interface to interact with the SoM server.

The server URL is printed during deployment via `python deploy.py run`.

Usage:
    python client.py "http://<server_ip>:6092"
"""

import fire
from gradio_client import Client
from loguru import logger

def predict(server_url: str):
    """
    Makes a prediction using the Gradio client with the provided IP address.

    Args:
        server_url (str): The URL of the SoM Gradio server.
    """
    client = Client(server_url)
    result = client.predict(
        {
            "background": "https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png",
        },           # filepath in 'parameter_1' Image component
        2.5,         # float (numeric value between 1 and 3) in 'Granularity' Slider component
        "Automatic", # Literal['Automatic', 'Interactive'] in 'Segmentation Mode' Radio component
        0.5,         # float (numeric value between 0 and 1) in 'Mask Alpha' Slider component
        "Number",    # Literal['Number', 'Alphabet'] in 'Mark Mode' Radio component
        ["Mark"],    # List[Literal['Mask', 'Box', 'Mark']] in 'Annotation Mode' Checkboxgroup component
        api_name="/inference"
    )
    logger.info(result)

if __name__ == "__main__":
    fire.Fire(predict)