diff --git a/morpheus-client/pages/imagine/img2img.tsx b/morpheus-client/pages/imagine/img2img.tsx
index da5f90de..f8a8bc24 100644
--- a/morpheus-client/pages/imagine/img2img.tsx
+++ b/morpheus-client/pages/imagine/img2img.tsx
@@ -1,19 +1,29 @@
import { NextPage } from "next";
+
+import { CookiesStatus } from "@/utils/cookies";
import ImageDraggable from "@/components/ImageDraggable/ImageDraggable";
import ImageGallery from "@/components/ImageGallery/ImageGallery";
import PrivateRoute from "@/components/Auth/PrivateRoute/PrivateRoute";
import ImagineInput from "@/components/ImagineInput/ImagineInput";
import { useDiffusion } from "@/context/SDContext";
import { useImagine } from "@/context/ImagineContext";
+import { useAnalytics } from "@/context/GoogleAnalyticsContext";
import styles from "@/styles/pages/StableDiffusion.module.scss";
const Img2Img: NextPage = () => {
const { prompt } = useDiffusion();
+ const { cookiesStatus, sendAnalyticsRecord } = useAnalytics();
const { img2imgFile, setImg2imgFile, generateImages } = useImagine();
const isFormValid = prompt.value.length > 0 && img2imgFile !== null;
const handleGenerate = () => {
generateImages("img2img");
+ if (cookiesStatus === CookiesStatus.Accepted) {
+ sendAnalyticsRecord("generate_images", {
+ prompt: prompt.value,
+ model: "img2img",
+ });
+ }
};
return (
diff --git a/morpheus-client/pages/imagine/inpainting.tsx b/morpheus-client/pages/imagine/inpainting.tsx
index bd02e7c3..29f1d2bb 100644
--- a/morpheus-client/pages/imagine/inpainting.tsx
+++ b/morpheus-client/pages/imagine/inpainting.tsx
@@ -1,4 +1,6 @@
import { NextPage } from "next";
+
+import { CookiesStatus } from "@/utils/cookies";
import ImageDraggable from "@/components/ImageDraggable/ImageDraggable";
import ImageGallery from "@/components/ImageGallery/ImageGallery";
import { UploadMaskIcon } from "@/components/icons/uploadMask";
@@ -6,17 +8,25 @@ import ImagineInput from "@/components/ImagineInput/ImagineInput";
import PrivateRoute from "@/components/Auth/PrivateRoute/PrivateRoute";
import { useDiffusion } from "@/context/SDContext";
import { useImagine } from "@/context/ImagineContext";
+import { useAnalytics } from "@/context/GoogleAnalyticsContext";
import styles from "../../styles/pages/StableDiffusion.module.scss";
const Inpainting: NextPage = () => {
const { prompt } = useDiffusion();
const { img2imgFile, setImg2imgFile, maskFile, setMaskFile, generateImages } =
useImagine();
+ const { cookiesStatus, sendAnalyticsRecord } = useAnalytics();
const isFormValid =
prompt.value.length > 0 && img2imgFile !== null && maskFile !== null;
const handleGenerate = async () => {
generateImages("inpainting");
+ if (cookiesStatus === CookiesStatus.Accepted) {
+ sendAnalyticsRecord("generate_images", {
+ prompt: prompt.value,
+ model: "inpainting",
+ });
+ }
};
return (
diff --git a/morpheus-client/pages/imagine/pix2pix.tsx b/morpheus-client/pages/imagine/pix2pix.tsx
index f7a7d0ee..fc183102 100644
--- a/morpheus-client/pages/imagine/pix2pix.tsx
+++ b/morpheus-client/pages/imagine/pix2pix.tsx
@@ -1,19 +1,29 @@
import { NextPage } from "next";
+
+import { CookiesStatus } from "../../utils/cookies";
import ImageGallery from "../../components/ImageGallery/ImageGallery";
import ImageDraggable from "../../components/ImageDraggable/ImageDraggable";
import ImagineInput from "../../components/ImagineInput/ImagineInput";
import PrivateRoute from "../../components/Auth/PrivateRoute/PrivateRoute";
import { useDiffusion } from "../../context/SDContext";
import { useImagine } from "../../context/ImagineContext";
+import { useAnalytics } from "../../context/GoogleAnalyticsContext";
import styles from "../../styles/pages/StableDiffusion.module.scss";
const Img2Img: NextPage = () => {
const { prompt } = useDiffusion();
+ const { cookiesStatus, sendAnalyticsRecord } = useAnalytics();
const { img2imgFile, setImg2imgFile, generateImages } = useImagine();
const isFormValid = prompt.value.length > 0 && img2imgFile !== null;
const handleGenerate = async () => {
generateImages("pix2pix");
+ if (cookiesStatus === CookiesStatus.Accepted) {
+ sendAnalyticsRecord("generate_images", {
+ prompt: prompt.value,
+ model: "pix2pix",
+ });
+ }
};
return (
diff --git a/morpheus-client/pages/imagine/text2img.tsx b/morpheus-client/pages/imagine/text2img.tsx
index a7db4587..3e329b10 100644
--- a/morpheus-client/pages/imagine/text2img.tsx
+++ b/morpheus-client/pages/imagine/text2img.tsx
@@ -1,18 +1,28 @@
import { NextPage } from "next";
+
+import { CookiesStatus } from "../../utils/cookies";
import ImageGallery from "../../components/ImageGallery/ImageGallery";
import PrivateRoute from "../../components/Auth/PrivateRoute/PrivateRoute";
import ImagineInput from "../../components/ImagineInput/ImagineInput";
import { useDiffusion } from "../../context/SDContext";
import { useImagine } from "../../context/ImagineContext";
+import { useAnalytics } from "../../context/GoogleAnalyticsContext";
import styles from "../../styles/pages/StableDiffusion.module.scss";
const Text2img: NextPage = () => {
const { prompt } = useDiffusion();
+ const { cookiesStatus, sendAnalyticsRecord } = useAnalytics();
const { generateImages } = useImagine();
const isFormValid = prompt.value.length > 0;
const handleGenerate = () => {
generateImages("text2img");
+ if (cookiesStatus === CookiesStatus.Accepted) {
+ sendAnalyticsRecord("generate_images", {
+ prompt: prompt.value,
+ model: "text2img",
+ });
+ }
};
return (
diff --git a/morpheus-client/pages/imagine/training.tsx b/morpheus-client/pages/imagine/training.tsx
index da117e9f..0edbc48f 100644
--- a/morpheus-client/pages/imagine/training.tsx
+++ b/morpheus-client/pages/imagine/training.tsx
@@ -1,9 +1,25 @@
+import { useEffect } from "react";
import { NextPage } from "next";
+
+import { CookiesStatus } from "../../utils/cookies";
+import { useAnalytics } from "../../context/GoogleAnalyticsContext";
import UnderConstruction from "../../components/UnderConstruction/UnderConstruction";
import PrivateRoute from "../../components/Auth/PrivateRoute/PrivateRoute";
import styles from "../../styles/pages/Training.module.scss";
const Training: NextPage = () => {
+ const { cookiesStatus, sendAnalyticsRecord } = useAnalytics();
+
+ useEffect(() => {
+ if (cookiesStatus === CookiesStatus.Accepted) {
+ sendAnalyticsRecord("page_view", {
+ page_location: window.location.href,
+ page_title: document?.title,
+ page_name: "Training",
+ });
+ }
+ }, [cookiesStatus, sendAnalyticsRecord]);
+
return (
diff --git a/morpheus-client/pages/index.tsx b/morpheus-client/pages/index.tsx
index 21a4a64f..1552039b 100644
--- a/morpheus-client/pages/index.tsx
+++ b/morpheus-client/pages/index.tsx
@@ -1,15 +1,18 @@
import { useEffect } from "react";
import { useRouter } from "next/router";
+import { CookiesStatus } from "@/utils/cookies";
import FullScreenLoader from "../components/Loaders/FullScreenLoader/Loader";
import { Auth } from "@/components/Auth/Auth";
import { isEmptyObject } from "@/utils/object";
import { useAuth } from "@/context/AuthContext";
+import { useAnalytics } from "@/context/GoogleAnalyticsContext";
import styles from "../styles/pages/Home.module.scss";
const Home = () => {
const router = useRouter();
const { authLoading, user } = useAuth();
+ const { cookiesStatus, sendAnalyticsRecord } = useAnalytics();
useEffect(() => {
if (!isEmptyObject(user)) {
@@ -17,6 +20,16 @@ const Home = () => {
}
}, [router, user]);
+ useEffect(() => {
+ if (cookiesStatus === CookiesStatus.Accepted) {
+ sendAnalyticsRecord("page_view", {
+ page_location: window.location.href,
+ page_title: document?.title,
+ page_name: "Home",
+ });
+ }
+ }, [cookiesStatus, sendAnalyticsRecord]);
+
return authLoading ? (
) : (
diff --git a/morpheus-client/pages/paint.tsx b/morpheus-client/pages/paint.tsx
index 51995781..a200c1a4 100644
--- a/morpheus-client/pages/paint.tsx
+++ b/morpheus-client/pages/paint.tsx
@@ -1,8 +1,24 @@
+import { useEffect } from "react";
+
+import { CookiesStatus } from "../utils/cookies";
import MainContainer from "../layout/MainContainer/MainContainer";
import Excalidraw from "../components/Excalidraw/Excalidraw";
+import { useAnalytics } from "../context/GoogleAnalyticsContext";
import styles from "../styles/pages/Paint.module.scss";
const Paint = () => {
+ const { cookiesStatus, sendAnalyticsRecord } = useAnalytics();
+
+ useEffect(() => {
+ if (cookiesStatus === CookiesStatus.Accepted) {
+ sendAnalyticsRecord("page_view", {
+ page_location: window.location.href,
+ page_title: document?.title,
+ page_name: "Paint",
+ });
+ }
+ }, [cookiesStatus, sendAnalyticsRecord]);
+
return (
diff --git a/morpheus-client/utils/cookies.ts b/morpheus-client/utils/cookies.ts
new file mode 100644
index 00000000..f0d7c95b
--- /dev/null
+++ b/morpheus-client/utils/cookies.ts
@@ -0,0 +1,17 @@
+export enum CookiesStatus {
+ Accepted = "accepted",
+ Declined = "declined",
+}
+
+const deleteAllCookies = () => {
+ const cookies = document.cookie.split(";");
+
+ for (let i = 0; i < cookies.length; i++) {
+ const cookie = cookies[i];
+ const eqPos = cookie.indexOf("=");
+ const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
+ document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
+ }
+};
+
+export { deleteAllCookies };
diff --git a/morpheus-server/app/repository/files/s3_files_repository.py b/morpheus-server/app/repository/files/s3_files_repository.py
index 49947f06..bb3c9239 100644
--- a/morpheus-server/app/repository/files/s3_files_repository.py
+++ b/morpheus-server/app/repository/files/s3_files_repository.py
@@ -85,7 +85,7 @@ def get_files(self, folder_name: str = settings.images_temp_bucket, max_keys: in
try:
params = {"Bucket": IMAGES_BUCKET, "Prefix": folder_name}
if max_keys:
- params.update(max_keys=max_keys)
+ params.update(MaxKeys=max_keys)
response = self.s3.list_objects_v2(**params)
images = []
diff --git a/morpheus-server/scripts/models/Dockerfile b/morpheus-server/scripts/models/Dockerfile
index 69a2f72e..8d0f0e86 100644
--- a/morpheus-server/scripts/models/Dockerfile
+++ b/morpheus-server/scripts/models/Dockerfile
@@ -24,7 +24,6 @@ RUN dir -s
# Install & use pipenv
RUN pip install --upgrade pip pipenv
-COPY Pipfile.lock .
COPY requirements.txt .
RUN pip install torch==1.13.1 && pip install -r requirements.txt
COPY . .