Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create initial HDR image upload process and store uploaded images and information in local directory #126

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ OAUTH2_REDIRECT_PATH=docs
## Hugging Face
HF_TOKEN=your_access_token
HF_HDR_DATASET_NAME=openmodelinitiative/hdr-submissions

## Docker compose variables
NODE_ENV=development
UPLOAD_DIR=./uploads
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ models_cache/

# Embedding models
**/models--**

# Local uploads
uploads/
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ services:
- ./modules/odr_frontend/docker/entrypoint.sh:/app/docker/entrypoint.sh
- odr_frontend_node_modules:/app/node_modules
- odr_frontend_pnpm_store:/app/.pnpm-store
- ${UPLOAD_DIR:-./uploads}:/app/uploads
ports:
- "5173:5173"
environment:
NODE_ENV: development
NODE_ENV: ${NODE_ENV:-development}
API_SERVICE_URL: http://odr-api:31100/api/v1
UPLOAD_DIR: /app/uploads
env_file:
- ./modules/odr_frontend/.env
networks:
Expand Down
12 changes: 1 addition & 11 deletions modules/odr_api/odr_api/api/endpoints/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async def create_jpg_preview(file: UploadFile = File(...)):
raise HTTPException(status_code=400, detail=str(e))


# Endpoint for metadata retrieval
# TODO: Needs updated to use exiftool as well
@router.post("/image/metadata")
async def get_image_metadata(file: UploadFile = File(...)):
try:
Expand All @@ -178,13 +178,6 @@ async def get_image_metadata(file: UploadFile = File(...)):
raise HTTPException(status_code=500, detail=str(e))


# For debugging
# docker cp $(docker ps --filter name=omi-postgres-odr-api -q):./app/cleaned_image_exiftool.dng ./cleaned_image_exiftool.dng
# def save_image_locally(image_bytes: bytes, filename: str):
# with open(filename, 'wb') as f:
# f.write(image_bytes)


def remove_metadata_with_exiftool(input_bytes):
# Create a temporary file to hold the input DNG
with tempfile.NamedTemporaryFile(delete=False, suffix='.dng') as temp_input_file:
Expand Down Expand Up @@ -252,9 +245,6 @@ async def clean_image_metadata(file: UploadFile = File(...)):
contents = await file.read()

cleaned_image_bytes = remove_metadata_with_exiftool(contents)
# For debugging
# save_image_locally(cleaned_image_bytes, 'cleaned_image_exiftool.dng')

encoded_image = base64.b64encode(cleaned_image_bytes).decode('utf-8')

return {
Expand Down
5 changes: 4 additions & 1 deletion modules/odr_frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@
"@auth/core": "^0.35.0",
"@auth/pg-adapter": "^1.5.0",
"@auth/sveltekit": "^1.5.0",
"@aws-sdk/client-s3": "^3.701.0",
"@floating-ui/dom": "1.6.10",
"axios": "^1.7.8",
"highlight.js": "11.10.0",
"next-auth": "^4.24.7",
"pg": "^8.13.0"
"pg": "^8.13.0",
"pnpm": "^9.14.4"
}
}
Loading
Loading