commit 2712a026abf3ae2d989ea073e8659fe455c80ac4 Author: kar Date: Mon Apr 21 16:22:57 2025 +0530 init diff --git a/.env-sample b/.env-sample new file mode 100644 index 0000000..da93f82 --- /dev/null +++ b/.env-sample @@ -0,0 +1 @@ +MOON_DREAM_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXlfaWQ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..30bd623 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ac64d62 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.10-slim + +# Environment setup +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 + +WORKDIR /app + +# System dependencies +RUN apt-get update && apt-get install -y \ + build-essential \ + libjpeg-dev \ + && rm -rf /var/lib/apt/lists/* + +# Install Python dependencies +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the app code and image +COPY . . + +# Set the entrypoint +CMD ["python", "start_moondream.py"] diff --git a/nat.jpg b/nat.jpg new file mode 100644 index 0000000..f93ac4c Binary files /dev/null and b/nat.jpg differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..faa2c2a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +moondream +Pillow +python-dotenv + diff --git a/start_moondream.py b/start_moondream.py new file mode 100644 index 0000000..2147248 --- /dev/null +++ b/start_moondream.py @@ -0,0 +1,20 @@ +import os +from dotenv import load_dotenv +import moondream as md +from PIL import Image + +# Load .env +load_dotenv() + +# Get key from env +api_key = os.getenv("MOON_DREAM_KEY") + +# Use Moondream cloud model +model = md.vl(api_key=api_key) + +# Load image +image = Image.open("nat.jpg") + +# Generate caption +caption_response = model.caption(image, length="short") +print(caption_response["caption"])