Skip to content
This repository has been archived by the owner on Oct 15, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ArsenChick committed Oct 14, 2023
2 parents 4b7d783 + 4189789 commit 70febcb
Show file tree
Hide file tree
Showing 22 changed files with 921 additions and 50 deletions.
46 changes: 46 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: '3'

volumes:
pb_volume:

services:
pocketbase:
build:
context: ./pocketbase

ports:
- 8090:8090

command: ["/pocketbase/pocketbase", "serve", "--http", "0.0.0.0:8090"]

volumes:
- pb_volume:/pocketbase

frontend-dev:
build:
context: ./frontend/MASSter-frontend

ports:
- 8080:8080

command: ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "8080"]

preprocessor:
build:
context: model/preprocessor/docker

environment:
- PB_LINK=http://pocketbase:8090/
- [email protected]
- PB_PWD=1234567890
- COL_NAME=text_generation_mvp

generator:
build:
context: model/generator/docker

environment:
- PB_LINK=http://pocketbase:8090/
- [email protected]
- PB_PWD=1234567890
- COL_NAME=text_generation_mvp
2 changes: 2 additions & 0 deletions frontend/MASSter-frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
1 change: 1 addition & 0 deletions frontend/MASSter-frontend/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_PB_HOST="http://pocketbase:8090"
12 changes: 12 additions & 0 deletions frontend/MASSter-frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:18

COPY .env.production .
COPY package.json .
COPY package-lock.json .

RUN npm install

COPY . .

RUN npm run build

19 changes: 6 additions & 13 deletions frontend/MASSter-frontend/src/components/avatar-prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,13 @@ export function AvatarAdvancedPromptForm({
negativePrompt: z.string().max(500).optional(),
style: z.string().default("Нет"),
inputImage: z
.custom<FileList>((v) => v instanceof FileList, {
.custom<File>((v) => v instanceof File, {
message: "Нужно загрузить картинки для референса"
})
.refine((files) => {
for (let file of files) {
if (!ACCEPTED_IMAGE_TYPES.includes(file.type)) {
return false;
}
}
return true;
}, "Пока мы поддерживаем только .png и .jpg изображения")
.refine(
(v) => ACCEPTED_IMAGE_TYPES.includes(v.type),
"Пока мы поддерживаем только .png и .jpg изображения"
)
.optional(),
// video: z
// .custom<File>((v) => v instanceof File, {
Expand Down Expand Up @@ -213,9 +209,7 @@ export function AvatarAdvancedPromptForm({
formData.append("num_images", `${data.numImages}`);

if (data.inputImage) {
for (let file of data.inputImage) {
formData.append("input_image", file);
}
formData.append("input_image", data.inputImage);
}
// if (data.video) {
// formData.append("video", data.video);
Expand Down Expand Up @@ -347,7 +341,6 @@ export function AvatarAdvancedPromptForm({
<FormControl>
<Input
type="file"
multiple={true}
onBlur={field.onBlur}
onChange={(e) =>
field.onChange(
Expand Down
19 changes: 6 additions & 13 deletions frontend/MASSter-frontend/src/components/banner-prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,13 @@ export function BannerAdvancedPromptForm({
negativePrompt: z.string().max(500).optional(),
style: z.string().default("Нет"),
inputImage: z
.custom<FileList>((v) => v instanceof FileList, {
.custom<File>((v) => v instanceof File, {
message: "Нужно загрузить картинки для референса"
})
.refine((files) => {
for (let file of files) {
if (!ACCEPTED_IMAGE_TYPES.includes(file.type)) {
return false;
}
}
return true;
}, "Пока мы поддерживаем только .png и .jpg изображения")
.refine(
(v) => ACCEPTED_IMAGE_TYPES.includes(v.type),
"Пока мы поддерживаем только .png и .jpg изображения"
)
.optional(),
// video: z
// .custom<File>((v) => v instanceof File, {
Expand Down Expand Up @@ -213,9 +209,7 @@ export function BannerAdvancedPromptForm({
formData.append("num_images", `${data.numImages}`);

if (data.inputImage) {
for (let file of data.inputImage) {
formData.append("input_image", file);
}
formData.append("input_image", data.inputImage);
}
// if (data.video) {
// formData.append("video", data.video);
Expand Down Expand Up @@ -347,7 +341,6 @@ export function BannerAdvancedPromptForm({
<FormControl>
<Input
type="file"
multiple={true}
onBlur={field.onBlur}
onChange={(e) =>
field.onChange(
Expand Down
19 changes: 6 additions & 13 deletions frontend/MASSter-frontend/src/components/video-cover-prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,13 @@ export function VideoCoverAdvancedPromptForm({
negativePrompt: z.string().max(500).optional(),
style: z.string().default("Нет"),
inputImage: z
.custom<FileList>((v) => v instanceof FileList, {
.custom<File>((v) => v instanceof File, {
message: "Нужно загрузить картинки для референса"
})
.refine((files) => {
for (let file of files) {
if (!ACCEPTED_IMAGE_TYPES.includes(file.type)) {
return false;
}
}
return true;
}, "Пока мы поддерживаем только .png и .jpg изображения")
.refine(
(v) => ACCEPTED_IMAGE_TYPES.includes(v.type),
"Пока мы поддерживаем только .png и .jpg изображения"
)
.optional(),
video: z
.custom<File>((v) => v instanceof File, {
Expand Down Expand Up @@ -204,9 +200,7 @@ export function VideoCoverAdvancedPromptForm({
formData.append("num_images", `${data.numImages}`);

if (data.inputImage) {
for (let file of data.inputImage) {
formData.append("input_image", file);
}
formData.append("input_image", data.inputImage);
}
if (data.video) {
formData.append("video", data.video);
Expand Down Expand Up @@ -338,7 +332,6 @@ export function VideoCoverAdvancedPromptForm({
<FormControl>
<Input
type="file"
multiple={true}
onBlur={field.onBlur}
onChange={(e) =>
field.onChange(
Expand Down
2 changes: 1 addition & 1 deletion frontend/MASSter-frontend/src/lib/pb-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PocketBase from "pocketbase";

export const pb = new PocketBase("https://pb.apps.npod.space");
export const pb = new PocketBase(import.meta.env.VITE_PB_HOST);
// pb.autoCancellation(false);


9 changes: 3 additions & 6 deletions model/generator/libs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def remove_models(self):
except:
try:
del self.pipe
del self.pipe_prior
del self.depth_estimator
except:
...

Expand Down Expand Up @@ -157,11 +159,7 @@ def generate_based_on_image(
+'low quality, jpeg artifacts, ugly, duplicate, '
+ 'morbid, mutilated, out of frame, extra fingers, '
+ 'mutated hands, poorly drawn hands, poorly drawn face, '
+ 'mutation, deformed, blurry, dehydrated, bad anatomy, '
+ 'bad proportions, extra limbs, cloned face, disfigured, '
+ 'gross proportions, malformed limbs, missing arms, '
+ 'missing legs, extra arms, extra legs, fused fingers, '
+ 'too many fingers, long neck, username, watermark, signature'
+ 'mutation, deformed, blurry, dehydrated, bad anatomy'
)

if num_steps < 1: num_steps = 1
Expand All @@ -184,7 +182,6 @@ def generate_based_on_image(

images = self.pipe(
image_embeds=image_emb,
guidance_scale=guidance_scale,
negative_image_embeds=zero_image_emb,
hint=hint,
num_inference_steps=num_steps,
Expand Down
20 changes: 16 additions & 4 deletions model/generator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,37 @@ def run(self):
def process_generation(self, data, width, height) -> list[Image.Image]:
# self.pb.get_file_url(data, filename=f'tmp/{data.record.image}')

if data.input_image != '':
if data.input_image != '' and data.type == 'avatar':
try:
image_url = self.pb.collection('text_generation_mvp').get_file_url(data, filename=data.input_image)
urllib.request.urlretrieve(image_url, data.input_image)

reference_image = Image.open(data.input_image, mode='r')
reference_image = reference_image.resize(size=(768, 768))
reference_image.save(data.input_image)

self.model.remove_models()
self.model.load_depth_model()
images = self.model.generate_based_on_image(
image_path=image_url,
image_path=data.input_image,
num_steps=50,
guidance_scale=4.0,
height=height,
width=width,
height=768,
width=768,
prompt=data.prompt,
style=data.style,
negative_prompt=data.negative_prompt,
num_images=data.num_images
)
self.model.remove_depth_model()
self.model.load_kandinsky()

for image in images:
image = image.resize(size=(800, 800))

return images
except:
raise
logger.error('Ошибка при скачивании референса, генерирую без референса')

images = self.model.generate(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 127 additions & 0 deletions model/generator/research/kandinsky.ipynb

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions pocketbase/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM debian:11

WORKDIR /pocketbase

RUN apt update -y
RUN apt install -y unzip wget

RUN wget https://github.com/pocketbase/pocketbase/releases/download/v0.18.10/pocketbase_0.18.10_linux_amd64.zip
RUN unzip pocketbase_0.18.10_linux_amd64.zip

COPY ./pb_migrations ./pb_migrations

WORKDIR /

Loading

0 comments on commit 70febcb

Please sign in to comment.