ai-service-hf / .github /README.md
MingDoan's picture
feat: Vision Question Answer
44e12ff
logo

Google Developer Student Clubs - FPT University Da Nang

AI Services

version release

✨ Available Services

  • Remove Background /api/rembg/
curl --location 'https://{server-domain}/api/rembg/' --form 'image=/image/path' --form 'stream=false' --form 'exprire=3600' --request 'POST'
  • Face Detection /api/fd/
curl --location 'https://{server-domain}/api/fd/' --form 'image=/image/path' --request 'POST'
  • Chats AI /api/chats/
curl --location 'https://{server-domain}/api/chats/' --data='{"prompt": ""}' --request 'POST'
  • Image to Text /api/img2text/ (Forwarding Server)
curl --location 'https://{server-domain}/api/img2text/' --form 'image=/image/path' --request 'POST'
  • Vision Question Answering /api/vqa/ (Forwarding Server)
curl --location 'https://{server-domain}/api/vqa/' --form 'image=/image/path' --form 'question=Question for image' --request 'POST'

🖥️ Root Server

⏩ Forwarding Server

The forwarding server help adding children server for processing. The parent server acts as a controller for load balancing.

# Specifying forwarding server by query params `fw`
curl --location 'https://{api-endpoint}/?fw=0' --request 'POST'

# Auto forwarding server. The parent server will controll loading balance among registered servers.
curl --location 'https://{api-endpoint}/?fw=auto' --request 'POST'
  • Get all registered forwarding servers.
curl --location 'https://{domain}/service/fw/' --request 'GET'
  • Register forwarding server.
curl --location 'https://{domain}/service/fw/' --request 'POST' --data '{"url":"{children-base-domain}"}'
  • Delete forwarding server.
curl --location 'https://{domain}/service/fw/' --request 'DELETE' --data '{"index":0}'

Server Health Checker

curl --location '{children-base-domain}/health'

This route checks the health status of children server. The children is considered as good health when it return anything with status 200.

Children Server Endpoint Request & Response

  • /api/rembg/
// Request. Form-data
{
    "image": "<image-data>"
}

// Response. JSON
{
    "data": {
        "image": "<static-access-url>"
    }
}
  • /api/fd/
// Request. Form-data
{
    "image": "<image-data>"
}

// Response. JSON
{
    "data": {
        "faces": FaceObject[]
    }
}

// FaceObject
{
    "bbox": {
        "x": 0,
        "y": 0,
        "width": 100,
        "height": 100
    }
}
  • /api/chats/
// Request. JSON
{
    "prompt": "A Prompt from user"
}

// Response. JSON
{
    "data": {
        "message": "A Message from AI"
    }
}
  • /api/chats/:id
// Request. JSON
{
    "prompt": "A Prompt from user",
    "conversation": [
        {
            "role": "user",
            "content": "Message A"
        },
        {
            "role": "assistant",
            "content": "Message B"
        }
    ]
}

// Response. JSON
{
    "data": {
        "message": "A Message from AI"
    }
}
  • /api/img2text/
// Request. Form-data
{
    "image": <image-data>
}

// Response. JSON
{
    "data": {
        "caption": "Caption of image"
    }
}
  • /api/vqa/
// Request. Form-data
{
    "image": <image-data>,
    "question": "Question for image"
}

// Response. JSON
{
    "data": {
        "answer": "Answer of image"
    }
}

😊 Contributors