Skip to content

Konfuzian/Google-VertexAI-FastAPI-Captionize

 
 

Repository files navigation

tl;dr

Set up:

git clone https://github.com/Konfuzian/Google-VertexAI-FastAPI.git
cd Google-VertexAI-FastAPI
python -m venv env
env/Scripts/activate
cd app
pip install -r requirements.txt

Then copy the service_account.json file into the app directory.

Attention for pytube: it currently has a bug, see https://stackoverflow.com/a/76611298 You have to go to env/Lib/site-packages/pytube/cipher.py and in get_throttling_function_name change function_patterns (around line 264):

function_patterns = [
    r'a\.[a-zA-Z]\s*&&\s*\([a-z]\s*=\s*a\.get\("n"\)\)\s*&&.*?\|\|\s*([a-z]+)',
    r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])?\([a-z]\)', ]

Run it:

In the command line, start the server (in the app directory):

uvicorn main:app --reload --port 8080

Then open in your browser:

http://localhost:8080/static/index.html

Screenshot of the running Captionize application


Here is the original README from lablab.ai:

Getting started with Vertex AI Generative AI

Before you begin

This is a simple starter boilerplate that gives you a basic FastAPI setup with a few endpoints. It is meant to be used as a starting point for your own projects.

Clone and install dependencies

In your terminal, run the following commands:

git clone git@github.com:lablab-ai/Google-VertexAI-FastAPI.git
cd Google-VertexAI-FastAPI
cd app
pip install -r requirements.txt

Update the project auth

In order to use the Vertex AI SDK, you will need to update the project auth using a serviceaccount

In app, folder create the file service_account.json and paste the content of your service account json file. Create the file if you don't have it by runnung the following command in your terminal:

touch service_account.json

In the file service_account.json paste the content of your service account json file. It should look like this:

{
    "type": "service_account",
    "project_id": "YOUR_PROJECT_ID",
    "private_key_id": "YOUR_PRIVATE_KEY_ID",
    "private_key": "YOUR_PRIVATE_KEY",
    "client_email": "YOUR_CLIENT_EMAIL",
    "client_id": "YOUR_CLIENT_ID",
    "auth_uri": "YOUR_AUTH_URI",
    "token_uri": "YOUR_TOKEN_URI",
    "auth_provider_x509_cert_url": "YOUR_AUTH_PROVIDER_X509_CERT_URL",
    "client_x509_cert_url": "YOUR_CLIENT_X509_CERT_URL",
    "universe_domain": "YOUR_UNIVERSE_DOMAIN"
}

You can find your service account json file in the Vertex AI console under Settings > Service account or you got it provided by lablab.ai (If you are part of the Google Vertex AI hackathon )

Start the server and test

Once you have installed the dependencies, you can start the server by running: uvicorn main:app --reload --port 8080 in the app directory. When the server is running, you can test it by going to http://localhost:8080/docs in your browser. You should see the Swagger UI where you can test the endpoints.

image image

Good luck! and don't forget to star this repo if you like it!

Thank you for reading! If you enjoyed this tutorial you can find more and continue reading on our tutorial page


Artificial Intelligence Hackathons, tutorials and Boilerplates

Join the LabLab Discord

Discord Banner 1
On lablab discord, we discuss this repo and many other topics related to artificial intelligence! Checkout upcoming Artificial Intelligence Hackathons Event

Acclerating innovation through acceleration

About

Captionize was built for the lablab.ai Google Vertex AI Hackathon and submitted here: https://lablab.ai/event/google-vertex-ai-hackathon/the-vertex-titans/captionize

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 56.3%
  • HTML 39.0%
  • Dockerfile 4.2%
  • Shell 0.5%