Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +38 -53
Dockerfile
CHANGED
|
@@ -1,53 +1,38 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
# Draw bounding box + text
|
| 40 |
-
cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
|
| 41 |
-
cv2.putText(image, text, (x1, y1 - 10),
|
| 42 |
-
cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 0), 2)
|
| 43 |
-
|
| 44 |
-
return image
|
| 45 |
-
|
| 46 |
-
demo = gr.Interface(
|
| 47 |
-
fn=detect_and_read_plate,
|
| 48 |
-
inputs="image",
|
| 49 |
-
outputs="image",
|
| 50 |
-
title="Automatic Number Plate Recognition (ANPR)",
|
| 51 |
-
description="Upload an image of a car to detect and read its license plate."
|
| 52 |
-
)
|
| 53 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
# Avoid interactive prompts
|
| 4 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
+
|
| 6 |
+
# Set environment variables for EasyOCR and Ultralytics
|
| 7 |
+
ENV EASYOCR_MODULE_PATH=/app/.EasyOCR
|
| 8 |
+
ENV YOLO_CONFIG_DIR=/app/.config/Ultralytics
|
| 9 |
+
|
| 10 |
+
# Install system dependencies
|
| 11 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 12 |
+
git curl build-essential ffmpeg libsm6 libxext6 \
|
| 13 |
+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 14 |
+
|
| 15 |
+
# Set work directory
|
| 16 |
+
WORKDIR /app
|
| 17 |
+
|
| 18 |
+
# Create directories for EasyOCR and Ultralytics with appropriate permissions
|
| 19 |
+
RUN mkdir -p /app/.EasyOCR /app/.config/Ultralytics \
|
| 20 |
+
&& chmod -R 777 /app/.EasyOCR /app/.config/Ultralytics
|
| 21 |
+
|
| 22 |
+
# Copy requirements
|
| 23 |
+
COPY requirements.txt .
|
| 24 |
+
|
| 25 |
+
# Install Python packages
|
| 26 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 27 |
+
|
| 28 |
+
# Download YOLOv8 ANPR model weights
|
| 29 |
+
RUN curl -L -o /app/anpr_yolov8.pt "https://github.com/madalinabuzatu/yolov8-license-plate-detection/releases/download/v1.0/best.pt"
|
| 30 |
+
|
| 31 |
+
# Copy app code
|
| 32 |
+
COPY app.py .
|
| 33 |
+
|
| 34 |
+
# Expose port for Gradio interface
|
| 35 |
+
EXPOSE 7860
|
| 36 |
+
|
| 37 |
+
# Run app
|
| 38 |
+
CMD ["python", "app.py"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|