init
This commit is contained in:
1
.env-sample
Normal file
1
.env-sample
Normal file
@@ -0,0 +1 @@
|
||||
MOON_DREAM_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXlfaWQ
|
||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.env
|
||||
|
||||
23
Dockerfile
Normal file
23
Dockerfile
Normal 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"]
|
||||
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
moondream
|
||||
Pillow
|
||||
python-dotenv
|
||||
|
||||
20
start_moondream.py
Normal file
20
start_moondream.py
Normal 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"])
|
||||
Reference in New Issue
Block a user