Spaces:
Sleeping
Sleeping
Commit
·
00a618c
1
Parent(s):
c1c6de7
cicd for hf
Browse files- .github/workflows/push_to_hf.yaml +37 -0
- .gitignore +2 -1
- Dockerfile +39 -0
- README.md +8 -0
- api/routers/looks_analyzer.py +1 -1
- api/routers/pickup_line_generator.py +1 -1
- app.py +19 -0
.github/workflows/push_to_hf.yaml
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync to Hugging Face hub
|
| 2 |
+
on:
|
| 3 |
+
push:
|
| 4 |
+
branches: [main]
|
| 5 |
+
|
| 6 |
+
# to run this workflow manually from the Actions tab
|
| 7 |
+
workflow_dispatch:
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
sync-to-hub:
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
steps:
|
| 13 |
+
- uses: actions/checkout@v3
|
| 14 |
+
with:
|
| 15 |
+
fetch-depth: 0
|
| 16 |
+
lfs: true
|
| 17 |
+
|
| 18 |
+
- name: Clean cache files
|
| 19 |
+
run: |
|
| 20 |
+
find . -type d -name "__pycache__" -exec rm -rf {} +
|
| 21 |
+
find . -type f -name "*.pyc" -delete
|
| 22 |
+
|
| 23 |
+
- name: Install Git LFS
|
| 24 |
+
run: |
|
| 25 |
+
git lfs install
|
| 26 |
+
git lfs track "*.png"
|
| 27 |
+
git lfs track "*.jpg"
|
| 28 |
+
git lfs track "*.mp4"
|
| 29 |
+
git lfs track "*.pt"
|
| 30 |
+
git add .gitattributes
|
| 31 |
+
git commit -m "Track binaries with LFS" || echo "No changes"
|
| 32 |
+
|
| 33 |
+
- name: Push to hub
|
| 34 |
+
env:
|
| 35 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 36 |
+
run: git push --force https://DvorakInnovationAI:$HF_TOKEN@huggingface.co/spaces/DvorakInnovationAI/REVEL-RIZZ-API main
|
| 37 |
+
|
.gitignore
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
.env
|
| 2 |
myenv
|
| 3 |
*.pyc
|
| 4 |
-
__pycache__/
|
|
|
|
|
|
| 1 |
.env
|
| 2 |
myenv
|
| 3 |
*.pyc
|
| 4 |
+
__pycache__/
|
| 5 |
+
delete_pycache.py
|
Dockerfile
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Python image
|
| 2 |
+
FROM python:3.12-slim
|
| 3 |
+
|
| 4 |
+
# Create a non-root user with UID 1000
|
| 5 |
+
RUN useradd -m -u 1000 user
|
| 6 |
+
|
| 7 |
+
# Create a data/cache directory with open permissions
|
| 8 |
+
RUN mkdir -p /data/.cache/huggingface && \
|
| 9 |
+
chown -R user:user /data && \
|
| 10 |
+
chmod -R 777 /data
|
| 11 |
+
|
| 12 |
+
# Set environment variables for Hugging Face cache
|
| 13 |
+
ENV HF_HOME=/data/.cache/huggingface \
|
| 14 |
+
TRANSFORMERS_CACHE=/data/.cache/huggingface/transformers \
|
| 15 |
+
HF_DATASETS_CACHE=/data/.cache/huggingface/datasets
|
| 16 |
+
|
| 17 |
+
# Switch to the non-root user
|
| 18 |
+
USER user
|
| 19 |
+
|
| 20 |
+
# Set working directory for the user
|
| 21 |
+
WORKDIR /home/user/app
|
| 22 |
+
|
| 23 |
+
# Ensure pip packages go to user space
|
| 24 |
+
ENV PATH=/home/user/.local/bin:$PATH
|
| 25 |
+
|
| 26 |
+
# Upgrade pip (runs as user)
|
| 27 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 28 |
+
|
| 29 |
+
# Copy code into the container, set ownership
|
| 30 |
+
COPY --chown=user . .
|
| 31 |
+
|
| 32 |
+
# Install dependencies (will go to ~/.local)
|
| 33 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 34 |
+
|
| 35 |
+
# Expose port
|
| 36 |
+
EXPOSE 7860
|
| 37 |
+
|
| 38 |
+
# Run the FastAPI app
|
| 39 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: revel_rizz
|
| 3 |
+
sdk: docker
|
| 4 |
+
emoji: 🚀
|
| 5 |
+
colorFrom: blue
|
| 6 |
+
app_file: app.py
|
| 7 |
+
pinned: false
|
| 8 |
+
---
|
api/routers/looks_analyzer.py
CHANGED
|
@@ -13,7 +13,7 @@ class UserRequest(BaseModel):
|
|
| 13 |
|
| 14 |
|
| 15 |
@router.post("/looks-analyzer")
|
| 16 |
-
async def
|
| 17 |
"""
|
| 18 |
Endpoint to analyze looks
|
| 19 |
"""
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
@router.post("/looks-analyzer")
|
| 16 |
+
async def analyze_looks(request: UserRequest):
|
| 17 |
"""
|
| 18 |
Endpoint to analyze looks
|
| 19 |
"""
|
api/routers/pickup_line_generator.py
CHANGED
|
@@ -16,7 +16,7 @@ class UserRequest(BaseModel):
|
|
| 16 |
|
| 17 |
|
| 18 |
@router.post("/pickup-line-generator")
|
| 19 |
-
async def
|
| 20 |
"""
|
| 21 |
Endpoint to extract conversation from a base64-encoded image
|
| 22 |
"""
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
@router.post("/pickup-line-generator")
|
| 19 |
+
async def generate_pickup_line(request: UserRequest):
|
| 20 |
"""
|
| 21 |
Endpoint to extract conversation from a base64-encoded image
|
| 22 |
"""
|
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Request
|
| 2 |
+
from api.routers import reply_generator
|
| 3 |
+
from api.routers import pickup_line_generator
|
| 4 |
+
from api.routers import looks_analyzer
|
| 5 |
+
|
| 6 |
+
app = FastAPI()
|
| 7 |
+
|
| 8 |
+
@app.middleware("http")
|
| 9 |
+
async def log_requests(request: Request, call_next):
|
| 10 |
+
response = await call_next(request)
|
| 11 |
+
return response
|
| 12 |
+
|
| 13 |
+
@app.get("/")
|
| 14 |
+
async def root():
|
| 15 |
+
return {'response':'Hello'}
|
| 16 |
+
|
| 17 |
+
app.include_router(reply_generator.router, prefix="/api")
|
| 18 |
+
app.include_router(pickup_line_generator.router, prefix="/api")
|
| 19 |
+
app.include_router(looks_analyzer.router, prefix="/api")
|