master
Kar 2025-04-21 16:22:57 +05:30
commit 2712a026ab
6 changed files with 50 additions and 0 deletions

1
.env-sample Normal file
View File

@ -0,0 +1 @@
MOON_DREAM_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXlfaWQ

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.env

23
Dockerfile Normal file
View File

@ -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"]

BIN
nat.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

4
requirements.txt Normal file
View File

@ -0,0 +1,4 @@
moondream
Pillow
python-dotenv

20
start_moondream.py Normal file
View File

@ -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"])