Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
inthree3 committed Jun 2, 2024
2 parents 8095865 + f05faa3 commit 5eaf0b8
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
ECR_REPOSITORY: check-out-ai
IMAGE_TAG: dev${{ github.run_number }}
with:
platforms: linux/arm64
context: .
push: true
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
Expand Down
70 changes: 68 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pandas = "^2.2.2"
openpyxl = "^3.1.3"
fastapi = {extras = ["all"], version = "^0.111.0"}
pillow = "^10.3.0"
boto3 = "^1.34.117"


[build-system]
Expand Down
22 changes: 22 additions & 0 deletions src/image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import boto3
import requests
import uuid
from dotenv import load_dotenv
import os

load_dotenv()
s3_url = os.getenv("S3_URL")

def image_service(url):
s3_client = boto3.client('s3',
endpoint_url=s3_url,
config=boto3.session.Config(signature_version='s3v4'))

bucket = "lookbook"
image_uuid = uuid.uuid4()
response = requests.get(url)

s3_client.put_object(Bucket=bucket, Key=str(image_uuid), Body=response.content)
return image_uuid


15 changes: 12 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from enum import Enum
from pydantic import BaseModel

from fastapi import FastAPI
from fastapi import FastAPI, HTTPException
from lookbook import get_lookbook
from image import image_service

app = FastAPI()

Expand Down Expand Up @@ -32,8 +33,16 @@ class Area(BaseModel):
async def root():
return {"message": "Hello World"}

@app.post("/lookbook/")
@app.post("/lookbook")
async def get_lookbook_endpoint(gender: Gender, ageRange: AgeRange, area: Area, TPO: list[str]):
# return {"gender": f"{gender.value}", "ageRange": f"{ageRange.value}", "area": f"{area.model_dump()}", "TPO": f"{type(TPO)}"}
prompt, url= get_lookbook(gender.value, ageRange.value, area.model_dump(), TPO.copy())
return {"prompt": prompt, "url": url}
# print("prompt done")
#
# try:
# image_uuid = image_service(url="https://via.placeholder.com/150x150")
# image_uuid = image_service(url=url)
return {"prompt": prompt, "url": url}
# except Exception as e:
# print(e)
# raise HTTPException(status_code=422, detail="Image upload error\n" + str(e))

0 comments on commit 5eaf0b8

Please sign in to comment.