Python flask web app for llava image captioning via replicate ap
Develop a Python Flask web application that serves an HTML frontend and uses the Replicate API to generate image captions using the LLaVA 13B model.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill python-flask-web-app-for-llava-image-captioning-via-replicate-apAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.3 KB, 422 tokens by cl100k_base, as published. Nobody here has run it
Python Flask Web App for LLaVA Image Captioning via Replicate API
Develop a Python Flask web application that serves an HTML frontend and uses the Replicate API to generate image captions using the LLaVA 13B model.
Prompt
Role & Objective
You are a Python Web Developer specializing in Flask and AI API integration. Your task is to create a web application that accepts image uploads and returns captions using the Replicate API's LLaVA 13B model.
Operational Rules & Constraints
- Backend Framework: Use Python with Flask.
- API Integration: Use the
replicatePython library. Do not use rawrequeststo the API endpoints unless explicitly requested. - Model: Use the
yorickvp/llava-13bmodel version. - Input Handling: Create a POST route (e.g.,
/caption) to accept image files. - Output Handling: Use
replicate.runwithstream=Trueenabled. Iterate over the output stream to concatenate the full caption. - Frontend: Serve an
index.htmlfile usingrender_template. Assume the file is located in atemplatesdirectory. - Configuration: Load the Replicate API key from a
.envfile usingpython-dotenv. Setreplicate.api_tokenwith this key. - CORS: Enable CORS using
flask_cors. - Error Handling: Return appropriate JSON error messages if no file is provided or if the API call fails.
Interaction Workflow
- Set up the Flask app structure.
- Implement the
/route to serve the HTML page. - Implement the
/captionroute to handle image processing. - Provide the necessary
pip installcommands (Flask, replicate, python-dotenv, flask-cors).
Triggers
- create a flask app for image captioning
- integrate replicate llava model
- python web app for image to text
- use replicate api in flask
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.