Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
8d09288
1
Parent(s):
8f054ed
update
Browse files- Dockerfile +0 -24
- README.md +0 -0
- categories.json +0 -0
- config.py +0 -0
- docker-compose.yml +0 -19
- requirement.txt +0 -0
- utils.py +0 -41
Dockerfile
DELETED
|
@@ -1,24 +0,0 @@
|
|
| 1 |
-
FROM python:3.10-slim
|
| 2 |
-
|
| 3 |
-
RUN apt-get update && \
|
| 4 |
-
apt-get install -y \
|
| 5 |
-
curl \
|
| 6 |
-
ca-certificates \
|
| 7 |
-
procps \
|
| 8 |
-
git \
|
| 9 |
-
&& apt-get clean \
|
| 10 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
-
|
| 12 |
-
RUN curl -fsSL https://ollama.com/install.sh | sh
|
| 13 |
-
|
| 14 |
-
RUN pip install ollama langchain langchain-ollama pillow
|
| 15 |
-
|
| 16 |
-
RUN ollama serve & \
|
| 17 |
-
sleep 10 && \
|
| 18 |
-
ollama pull gemma3n:e2b && \
|
| 19 |
-
pkill ollama
|
| 20 |
-
|
| 21 |
-
WORKDIR /workspace
|
| 22 |
-
|
| 23 |
-
RUN python3 -c "import sys; print(f'Python version: {sys.version}'); import langchain; from langchain_ollama import OllamaLLM; print('Setup verified successfully!')"
|
| 24 |
-
CMD ["ollama" , "serve"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
ADDED
|
File without changes
|
categories.json
ADDED
|
File without changes
|
config.py
ADDED
|
File without changes
|
docker-compose.yml
DELETED
|
@@ -1,19 +0,0 @@
|
|
| 1 |
-
services:
|
| 2 |
-
ollama:
|
| 3 |
-
build: .
|
| 4 |
-
container_name: gemma3n-challenge
|
| 5 |
-
ports:
|
| 6 |
-
- "11434:11434"
|
| 7 |
-
- "8000:8000"
|
| 8 |
-
volumes:
|
| 9 |
-
- ollama:/root/.ollama
|
| 10 |
-
- .:/workspace
|
| 11 |
-
environment:
|
| 12 |
-
- OLLAMA_HOST=0.0.0.0
|
| 13 |
-
- OLLAMA_ORIGINS=*
|
| 14 |
-
- PYTHONPATH=/workspace
|
| 15 |
-
working_dir: /workspace
|
| 16 |
-
restart: unless-stopped
|
| 17 |
-
|
| 18 |
-
volumes:
|
| 19 |
-
ollama:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirement.txt
ADDED
|
File without changes
|
utils.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
import base64
|
| 2 |
-
from PIL import Image
|
| 3 |
-
import os
|
| 4 |
-
import tempfile
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
def encode_image_to_base64(image_path):
|
| 8 |
-
"""
|
| 9 |
-
Encodes an image file to a base64 string.
|
| 10 |
-
Args:
|
| 11 |
-
image_path (str): The path to the image file.
|
| 12 |
-
Returns:
|
| 13 |
-
str: Base64 encoded string of the image.
|
| 14 |
-
"""
|
| 15 |
-
with open(image_path, "rb") as image_file:
|
| 16 |
-
return base64.b64encode(image_file.read()).decode("utf-8")
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
def save_uploaded_file(uploaded_file):
|
| 20 |
-
"""
|
| 21 |
-
Saves an uploaded file to a temporary location.
|
| 22 |
-
"""
|
| 23 |
-
if not os.path.exists("temp"):
|
| 24 |
-
os.makedirs("temp")
|
| 25 |
-
|
| 26 |
-
temp_path = os.path.join("temp", uploaded_file.filename)
|
| 27 |
-
with open(temp_path, "wb") as f:
|
| 28 |
-
f.write(uploaded_file.getvalue())
|
| 29 |
-
return temp_path
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
def resize_image(image_path, max_size=(1024, 1024)):
|
| 33 |
-
"""
|
| 34 |
-
Resizes an image to fit within the specified maximum size while maintaining aspect ratio.
|
| 35 |
-
Args:
|
| 36 |
-
image_path (str): The path to the image file.
|
| 37 |
-
max_size (tuple): The maximum width and height (width, height) for the resized image.
|
| 38 |
-
"""
|
| 39 |
-
with Image.open(image_path) as img:
|
| 40 |
-
img.thumbnail(max_size, Image.Resampling.LANCZOS)
|
| 41 |
-
img.save(image_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|