INNER CODE UNIT · Python

classify_image

roboflow/awesome-openai-vision-api-experiments · experiments/hot-dog-not-hot-dog/app.py:88

def classify_image(api_key: str, image: np.ndarray) -> str:
    if not api_key:
        raise ValueError(
            "API_KEY is not set. "
            "Please follow the instructions in the README to set it up.")
    image = preprocess_image(image=image)
    prompt = compose_classification_prompt(classes=CLASSES)
    response = prompt_image(api_key=api_key, image=image, prompt=prompt)
    return response


with gr.Blocks() as demo:
    gr.Markdown(MARKDOWN)
    api_key_textbox = gr.Textbox(
        label="🔑 OpenAI API", type="password")

    with gr.TabItem("Basic"):
        with gr.Column():

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…