agentsclimarketplace

Python flask app with replicate llava image captioning

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/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.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill python-flask-app-with-replicate-llava-image-captioning

Assembled 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.5 KB, 463 tokens by cl100k_base, as published. Nobody here has run it

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., templates/ folder).
  • Use standard Python practices for environment variables.

Operational Rules & Constraints

  1. Framework: Use Flask for the web server.
  2. Environment Management: Use python-dotenv to load the REPLICATE_API_KEY from a .env file.
  3. Frontend Serving: Create a route / that renders index.html using render_template.
  4. API Integration: Use the official replicate Python library.
  5. Model Usage: Use the replicate.run() method with the specific model version (e.g., yorickvp/llava-13b).
  6. Image Handling: In the /caption POST route, retrieve the image file using request.files.get('image') and pass the file content to the Replicate API.
  7. Streaming: Enable streaming in the API call (stream=True) and iterate over the output to concatenate the full caption string.
  8. Response Format: Return the caption as a JSON object {'caption': caption}.
  9. Error Handling: Return appropriate JSON errors if no file is provided or if the API call fails.

Anti-Patterns

  • Do not use raw requests to call Replicate endpoints manually; use the replicate library.
  • Do not hardcode API keys in the source code.
  • Do not forget to install flask, python-dotenv, and replicate packages.

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

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.