Skip to content

Commit

Permalink
Test (#83)
Browse files Browse the repository at this point in the history
* fix deletion bug

* autoImport

* buildscript

* m time instead of c time!

* Gitignore

* animation

* zoomable, better animation

* zoom fixes, better scrolling to picture

* Open in album feature

* fix

* Fix scroll resize

* Fix scrollbar, font

* Patch face download (#79)

* Update requirements.txt

* Update Dockerfile

* newest pic in album as default?

* Show newest picture as album cover

* properly select album picture

Co-authored-by: Your Name <you@example.com>
  • Loading branch information
gregordr and Your Name authored Apr 15, 2022
1 parent 4a6f774 commit 536bf42
Show file tree
Hide file tree
Showing 17 changed files with 28,541 additions and 351 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ faceFeatures/*
imageFeatures/*
autoImport/node_modules/*
import/*
analysis/*
media/*
5,336 changes: 5,328 additions & 8 deletions backend/package-lock.json

Large diffs are not rendered by default.

48 changes: 44 additions & 4 deletions backend/src/database/albumDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,28 @@ CONSTRAINT photo_Exists FOREIGN KEY(Photo) REFERENCES ${await media}(OID) ON DEL

export async function getAlbums(searchTerm: string): Promise<unknown[]> {
return transaction(async (client) => {
const result = await client.query(`SELECT oid AS id, ${album} AS name, picture AS cover, (
const result = await client.query(`
SELECT
oid AS id,
${album} AS name,
COALESCE(
picture, (
SELECT ${await album_photo}.${photo} FROM ${await album_photo}
JOIN ${await media} ON ${await media}.oid=${await album_photo}.${photo}
WHERE ${await albums}.oid=album
ORDER BY date DESC
LIMIT 1
)
) AS cover,
(
SELECT COUNT(*)
FROM ${await album_photo}
WHERE ${await albums}.oid = ${await album_photo}.${album}
)::integer AS imageCount FROM ${await albums} WHERE ${album} like $1::text
ORDER BY name;`, [searchTerm]);
)::integer AS imageCount
FROM ${await albums}
WHERE ${album} like $1::text
ORDER BY name;`,
[searchTerm]);
return result.rows;
});
}
Expand All @@ -40,8 +56,32 @@ export async function deleteAlbum(name: string): Promise<string> {
});
}

export function getAlbumsWithMedia(photoID: string): Promise<unknown[]> {
return transaction(async (client) => {
const result = await client.query(`SELECT ${await albums}.OID as id, ${await albums}.${album} as name,
COALESCE(
picture, (
SELECT ${await album_photo}.${photo} FROM ${await album_photo}
JOIN ${await media} ON ${await media}.oid=${await album_photo}.${photo}
WHERE ${await albums}.oid=album
ORDER BY date DESC
LIMIT 1
)
) AS cover
, (
SELECT COUNT(*)
FROM ${await album_photo}
WHERE ${album} = ${await albums}.OID
) as imagecount
FROM ${await album_photo}
JOIN ${await albums} ON ${await albums}.OID = ${await album_photo}.${album}
WHERE ${photo} = $1::OID
;`, [photoID]);
return result.rows;
});
}

export async function getMediaInAlbum(album: string, searchTerm: string, label: string): Promise<unknown[]> {
export function getMediaInAlbum(album: string, searchTerm: string, label: string): Promise<unknown[]> {
return transaction(async (client) => {
const result = await client.query(`SELECT OID::text as id, ${photo} as name, h as height, w as width, date as date, type as type, coordX as coordX, coordY as coordY FROM ${await media} WHERE
(
Expand Down
9 changes: 8 additions & 1 deletion backend/src/routers/albumRouter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import express from 'express';
import { getAlbums, addAlbum, addPhotosToAlbums, removePhotosFromAlbum, deleteAlbum, getMediaInAlbum, setCover, rename } from '../database/albumDatabase';
import { getAlbums, addAlbum, addPhotosToAlbums, removePhotosFromAlbum, deleteAlbum, getMediaInAlbum, setCover, rename, getAlbumsWithMedia } from '../database/albumDatabase';
import { registeredServices } from './servicesRouter';

export const router = express.Router();
Expand Down Expand Up @@ -31,6 +31,13 @@ router.get('/all', async (req, res) => {
}
});

router.get("/getAlbumsWithMedia/:photoID", async (req, res) => {
try {
res.status(200).send(await getAlbumsWithMedia(req.params.photoID));
} catch (err) {
res.status(500).send(err.toString());
}
});

router.get('/:name/all', async (req, res) => {
try {
Expand Down
4 changes: 3 additions & 1 deletion face/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ WORKDIR /code
COPY requirements.txt .
RUN pip install Cython
RUN pip install -r requirements.txt
RUN pip install torch==1.7.1+cpu torchvision==0.8.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
RUN pip install torch==1.7.1+cpu torchvision==0.8.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
RUN gdown 18wEUfMNohBJ4K3Ly5wpTejPfDzp-8fI8 -O ~/.insightface/models/
RUN unzip ~/.insightface/models/antelopev2.zip -d ~/.insightface/models/
RUN apt-get update
RUN apt-get install ffmpeg -y
COPY face.py .
Expand Down
1 change: 1 addition & 0 deletions face/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ waitress
flask
onnxruntime
insightface==0.5
gdown
Loading

0 comments on commit 536bf42

Please sign in to comment.