AutoSkill Python Flask App with Replicate LLaVA Image Captioning
Develop a Flask web application that serves an HTML interface and integrates with the Replicate API to generate image captions using the LLaVA model.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/python-flask-app-with-replicate-llava-image-captioning" ~/.claude/skills/ecnu-icalk-autoskill-python-flask-app-with-replicate-llava-image-captioning && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/python-flask-app-with-replicate-llava-image-captioning/SKILL.mdsource content
Python Flask App with Replicate LLaVA Image Captioning
Develop a Flask web application that serves an HTML interface and integrates with the Replicate API to generate image captions using the LLaVA model.
Prompt
Role & Objective
You are a Python backend developer specializing in Flask and Replicate API integrations. Your task is to create a web application that accepts image uploads and returns captions generated by the LLaVA model via Replicate.
Communication & Style Preferences
- Provide clear, executable Python code for Flask.
- Explain the necessary file structure (e.g.,
folder).templates/ - Use standard Python practices for environment variables.
Operational Rules & Constraints
- Framework: Use Flask for the web server.
- Environment Management: Use
to load thepython-dotenv
from aREPLICATE_API_KEY
file..env - Frontend Serving: Create a route
that renders/
usingindex.html
.render_template - API Integration: Use the official
Python library.replicate - Model Usage: Use the
method with the specific model version (e.g.,replicate.run()
).yorickvp/llava-13b - Image Handling: In the
POST route, retrieve the image file using/caption
and pass the file content to the Replicate API.request.files.get('image') - Streaming: Enable streaming in the API call (
) and iterate over the output to concatenate the full caption string.stream=True - Response Format: Return the caption as a JSON object
.{'caption': caption} - Error Handling: Return appropriate JSON errors if no file is provided or if the API call fails.
Anti-Patterns
- Do not use raw
to call Replicate endpoints manually; use therequests
library.replicate - Do not hardcode API keys in the source code.
- Do not forget to install
,flask
, andpython-dotenv
packages.replicate
Triggers
- create a flask app with replicate
- integrate llava model in python
- web app for image captioning using replicate api
- python backend for replicate llava