Merge branch 'feature/mvp' into fixes/mvp1_improvements

This commit is contained in:
wil committed 2024-02-13 12:15:17 -05:00
commit 96ded2642d
21 files changed
+427 -225

No files matched your search

@@ -2,7 +2,7 @@ import { ApiConfig } from "../ApiConfig";
export interface EnqueueImageGenRequest {
uuid_idempotency_token: string;
maybe_sd_model_token: string | undefined;
maybe_sd_model_token: string | null;
maybe_lora_model_token: string | null;
maybe_prompt: string;
maybe_n_prompt: string;
@@ -0,0 +1,19 @@
import MakeRequest from "../MakeRequest";
import { Weight } from "./GetWeight";
export interface SearchWeightRequest {
search_term: string;
weight_type?: string;
weight_category?: string;
ietf_language_tag?: string;
}
export interface SearchWeightResponse {
success: boolean;
weights?: Weight[];
}
export const SearchWeight = MakeRequest<string, SearchWeightRequest, SearchWeightResponse, {}>({
method: "POST",
routingFunction: () => `/v1/weights/search`,
});
@@ -43,7 +43,7 @@ export default function AudioCard({
const linkUrl = getCardUrl(data, source, type);
const history = useHistory();
console.log("🟩",data);
console.log("🟩", data);
const handleSelectModalResultSelect = () => {
if (inSelectModal) {
@@ -180,7 +180,8 @@ export default function AudioCard({
</div>
<CardFooter
{...{
creator: data?.creator,
creator:
data?.creator || data.details.maybe_weight_data?.maybe_creator,
entityToken: data.weight_token,
entityType: "model_weight",
makeBookmarksProps: bookmarks?.makeProps,
@@ -66,7 +66,7 @@
right: 0;
padding: 1rem;
color: $white;
text-shadow: 0 0 10px black;
text-shadow: 0 0 4px rgba(#000, .75);
}
&.card-clickable {
@@ -181,7 +181,9 @@ export default function ImageCard({
</div>
<CardFooter
{...{
creator: data.creator,
creator:
data.creator ||
data.details.maybe_weight_data?.maybe_creator,
entityToken: data.weight_token,
entityType: "model_weight",
makeBookmarksProps: bookmarks?.makeProps,
@@ -46,8 +46,6 @@ const SelectModal = memo(
activeTab: tabs[0].tabKey,
valueType: tabs[0].typeFilter || "all",
});
console.log("🔫", tabs, activeTab, valueType);
// Update mediaType when activeTab changes
useEffect(() => {
const currentTab = tabs.find(tab => tab.tabKey === activeTab);
@@ -1,3 +1,27 @@
.fy-temp-select { // NO !IMPORTANT
.fy-temp-select {
margin-bottom: 1rem;
}
&:only-child,
&:last-child {
margin-bottom: 0;
}
}
.d-flex:not(.flex-column) > .fy-temp-select {
margin-bottom: 0;
margin-right: 0.5rem;
&:only-child,
&:last-child {
margin-bottom: 0;
}
}
.gap-1 > .fy-temp-select,
.gap-2 > .fy-temp-select,
.gap-3 > .fy-temp-select,
.gap-4 > .fy-temp-select,
.gap-5 > .fy-temp-select {
margin-bottom: 0;
margin-right: 0 !important;
}
@@ -20,7 +20,7 @@ export default function CardWrapper({ canHover, card: Card, data, onClick, paddi
const className = `card ${ padding ? "p-3" : "" }${ onClick || canHover ? " card-clickable" : "" }`;
return onClick ?
<div {...{ className, onClick }}>
<div {...{ className, onClick: () => onClick(data) }}>
<Card { ...cardProps }/>
</div> :
<Link {...{ className, to: linkUrl }}>
@@ -14,13 +14,20 @@ import { UploadMedia, UploadMediaResponse } from "@storyteller/components/src/ap
import { v4 as uuidv4 } from "uuid";
import "./EntityInput.scss";
// enum EntityInputMode {
// Bookmarks = "bookmarks",
// Media = "media",
// Weights = "weights",
// SearchWeights = "searchWeights",
// }
interface Props {
aspectRatio?: "square" | "landscape" | "portrait",
mediaType?: MediaFilterProp,
label?: string,
onChange?: any,
owner?: string,
mediaType?: MediaFilterProp,
aspectRatio?: "square" | "landscape" | "portrait",
weightType?: WeightFilterProp,
type: string,
weightType?: WeightFilterProp
}
interface SlideProps {
@@ -31,9 +38,7 @@ interface EmptySlideProps extends SlideProps {
entityType: EntityType,
filterType: MediaFilterProp | WeightFilterProp,
inputProps?: any,
onSelect: any,
open: any,
owner: string,
user: any
};
@@ -66,10 +71,10 @@ const MocapInputFull = ({ media }: SlideProps) => {
</>;
};
const MediaPickerEmpty = ({ entityType, filterType, media, onSelect, open, owner, inputProps, user }: EmptySlideProps) => {
const MediaPickerEmpty = ({ entityType, filterType, open, inputProps, user, ...rest }: EmptySlideProps) => {
const browserClick = () => open({
component: MediaBrowser,
props: { entityType, filterType, onSelect, owner, username: user?.username || "" }
props: { entityType, filterType, username: user?.username || "", ...rest }
});
const mediaIcons = () => {
@@ -109,7 +114,7 @@ const AniMod = ({ animating, className, isLeaving, render: Render, style, ...res
<Render {...{ ...rest, animating }} />
</a.div>;
export default function EntityInput({ aspectRatio = "square", label, onChange, owner, mediaType, weightType }: Props) {
export default function EntityInput({ aspectRatio = "square", label, onChange, mediaType, weightType, ...rest }: Props) {
const entityType = mediaType ? EntityType.media : weightType ? EntityType.weights : EntityType.unknown;
const filterType = mediaType || weightType || "all";
const { search } = useLocation();
@@ -136,6 +141,7 @@ export default function EntityInput({ aspectRatio = "square", label, onChange, o
});
const onSelect = (data: MediaFile) => {
mediaSet(data)
console.log("🔅",data);
onChange({ target: { name: "temp", value: data.token } });
}
const busy = false;
@@ -164,7 +170,7 @@ export default function EntityInput({ aspectRatio = "square", label, onChange, o
return [
<AniMod {...{ render: MediaBusy, className: "fy-entity-input-busy", ...sharedProps }}/>,
<AniMod {...{ render: MocapInputFull, className: "fy-entity-input-full", ...sharedProps }}/>,
<AniMod {...{ render: MediaPickerEmpty, className: "fy-entity-input-empty", entityType, filterType, inputProps, onSelect, open, owner, user, ...sharedProps }}/>
<AniMod {...{ render: MediaPickerEmpty, className: "fy-entity-input-empty", entityType, filterType, inputProps, onSelect, open, user, ...sharedProps, ...rest }}/>
][i];
})
@@ -23,6 +23,7 @@ interface JobsListProps {
}
const resultPaths = {
EngineComposition: "/media",
FaceAnimation: "/media",
TextToSpeech: "/media",
VoiceConversion: "/media",
@@ -15,7 +15,7 @@ import React, { useEffect, useState } from "react";
import { Link, useHistory } from "react-router-dom";
import { SessionWrapper } from "@storyteller/components/src/session/SessionWrapper";
import { Logout } from "@storyteller/components/src/api/session/Logout";
import { useModal } from "hooks";
import { useModal, useSession } from "hooks";
import { InferenceJobsModal } from "components/modals";
import { useDomainConfig } from "context/DomainConfigContext";
import NavItem from "../../common/NavItem/NavItem";
@@ -112,12 +112,14 @@ export default function TopNav({
let profileDropdown = <></>;
const { user } = useSession();
if (sessionWrapper.isLoggedIn()) {
let displayName = sessionWrapper.getDisplayName();
let username = sessionWrapper.getUsername();
let emailHash = sessionWrapper.getEmailGravatarHash();
let avatarIndex = 0; //temporary
let backgroundColorIndex = 0; //temporary
let displayName = user.display_name;
let username = user.username;
let emailHash = user.email_gravatar_hash;
let avatarIndex = user.core_info.default_avatar.image_index;
let backgroundColorIndex = user.core_info.default_avatar.color_index;
profileDropdown = (
<ProfileDropdown
@@ -1,53 +1,82 @@
import React, { useState } from "react";
import { MediaList } from "components/entities";
import { EntityType, EntityFilterOptions, MediaFilterProp, WeightFilterProp } from "components/entities/EntityTypes";
import {
EntityType,
EntityFilterOptions,
MediaFilterProp,
WeightFilterProp,
} from "components/entities/EntityTypes";
import { TempSelect } from "components/common";
import AudioPlayerProvider from "components/common/AudioPlayer/AudioPlayerContext";
import SkeletonCard from "components/common/Card/SkeletonCard";
import Pagination from "components/common/Pagination";
import { GetMediaByUser } from "@storyteller/components/src/api/media_files/GetMediaByUser";
import { GetWeightsByUser } from "@storyteller/components/src/api/weights/GetWeightsByUser";
import { SearchWeights } from "@storyteller/components/src/api/weights/SearchWeights";
import { MediaFile } from "@storyteller/components/src/api/media_files/GetMedia";
import { Weight } from "@storyteller/components/src/api/weights/GetWeight";
import { useListContent, useRatings } from "hooks";
import { faArrowDownWideShort, faFilter } from "@fortawesome/pro-solid-svg-icons";
import {
faArrowDownWideShort,
faFilter,
} from "@fortawesome/pro-solid-svg-icons";
import prepFilter from "resources/prepFilter";
import ModalHeader from "../ModalHeader";
import "./MediaBrowser.scss";
interface Props {
entityType: EntityType,
handleClose: any,
mediaToken: string,
onSelect?: any,
owner?: string,
filterType?: MediaFilterProp | WeightFilterProp,
username: string,
entityType: EntityType;
filterType?: MediaFilterProp | WeightFilterProp;
handleClose: any;
mediaToken: string;
onSelect?: any;
owner?: string;
search?: string;
username: string;
}
export default function MediaBrowser({ entityType, filterType: inputFilter, mediaToken, handleClose = () => {}, onSelect, owner, username }: Props) {
export default function MediaBrowser({
entityType,
filterType: inputFilter,
mediaToken,
handleClose = () => {},
onSelect,
owner,
search,
username,
}: Props) {
const ratings = useRatings();
const [showMasonryGrid, setShowMasonryGrid] = useState(true);
const [filterType, filterTypeSet] = useState(inputFilter || "all");
const [filterType, filterTypeSet] = useState(inputFilter || "all");
const [list, listSet] = useState<MediaFile | Weight[]>([]);
const fetcher = search
? SearchWeights
: [() => {}, GetMediaByUser, GetWeightsByUser][entityType] ||
GetMediaByUser;
const entities = useListContent({
debug: "media browser",
addQueries: {
page_size: 24,
...prepFilter(filterType, ["","filter_media_type","maybe_scoped_weight_type"][entityType]),
...(search ? {} : { page_size: 24 }),
...prepFilter(
filterType,
["", "filter_media_type", "maybe_scoped_weight_type"][entityType]
),
},
addSetters: { filterTypeSet },
fetcher: [() => {},GetMediaByUser,GetWeightsByUser][entityType] || GetMediaByUser,
fetcher,
list,
listSet,
onInputChange: () => setShowMasonryGrid(false),
onSuccess: (res) => {
onSuccess: res => {
// bookmarks.gather({ res, key: "token" });
ratings.gather({ res, key: "token" });
setShowMasonryGrid(true);
},
...(search ? { request: { search_term: search } } : {}),
requestList: true,
...(search ? { resultsKey: "weights" } : {}),
urlParam: owner || username,
urlUpdate: false
urlUpdate: false,
});
const handlePageClick = (selectedItem: { selected: number }) => {
@@ -66,53 +95,71 @@ export default function MediaBrowser({ entityType, filterType: inputFilter, medi
// { value: "mostliked", label: "Most Liked" },
];
const title = ["",`${ owner ? owner + "'s " : "" }Media`,"Weights"][entityType];
const title = ["", `${owner ? owner + "'s " : ""}Media`, "Weights"][
entityType
];
const onClick = (data: any) => {
console.log("🩵", data);
onSelect(data);
handleClose();
};
return <>
<ModalHeader {...{ handleClose, title}}>
<TempSelect
{...{
icon: faArrowDownWideShort,
options: sortOptions,
name: "sort",
onChange: entities.onChange,
value: entities.sort,
}}
/>
{ (!inputFilter || inputFilter === "all") && <TempSelect {...{
icon: faFilter,
options: EntityFilterOptions(entityType),
name: "filterType",
return (
<>
<ModalHeader {...{ handleClose, title }}>
<TempSelect
{...{
icon: faArrowDownWideShort,
options: sortOptions,
name: "sort",
onChange: entities.onChange,
value: filterType,
}}/> }
<Pagination {...paginationProps} />
</ModalHeader>
<AudioPlayerProvider>
{ entities.isLoading ? (
<div {...{ className: "row gx-3 gy-3" }}>
{Array.from({ length: 12 }).map((_, index) => (
<SkeletonCard key={index} />
))}
</div>
) : (
<>
{ showMasonryGrid && (
<div {...{ className: "fy-media-browser-list" }}>
<MediaList {...{ entityType, list: entities.list, success: entities.status === 3, onClick }}/>
</div>
) }
</>
)}
</AudioPlayerProvider>
value: entities.sort,
}}
/>
{(!inputFilter || inputFilter === "all") && (
<TempSelect
{...{
icon: faFilter,
options: EntityFilterOptions(entityType),
name: "filterType",
onChange: entities.onChange,
value: filterType,
}}
/>
)}
<Pagination {...paginationProps} />
</ModalHeader>
<AudioPlayerProvider>
{entities.isLoading ? (
<div {...{ className: "row gx-3 gy-3" }}>
{Array.from({ length: 12 }).map((_, index) => (
<SkeletonCard key={index} />
))}
</div>
) : (
<>
{showMasonryGrid && (
<div {...{ className: "fy-media-browser-list" }}>
<MediaList
{...{
entityType,
list: entities.list,
success: entities.status === 3,
onClick,
}}
/>
</div>
)}
</>
)}
</AudioPlayerProvider>
<footer {...{ className: "fy-media-browser-footer fy-media-browser-tools" }}>
<Pagination {...paginationProps} />
</footer>
</>;
};
<footer
{...{ className: "fy-media-browser-footer fy-media-browser-tools" }}
>
<Pagination {...paginationProps} />
</footer>
</>
);
}
@@ -12,7 +12,9 @@ interface Props {
onInputChange?: (x?: any) => any;
onSuccess?: (x?: any) => any;
pagePreset?: number;
request?: any;
requestList?: boolean;
resultsKey?: string;
urlParam: string;
urlUpdate?: boolean;
}
@@ -29,7 +31,9 @@ export default function useListContent({
onInputChange = n,
onSuccess = n,
pagePreset = 0,
request,
requestList = false,
resultsKey = "results",
urlParam = "",
urlUpdate = true,
}: Props) {
@@ -71,7 +75,7 @@ export default function useListContent({
useEffect(() => {
const queries = {
page_index: page,
...page ? { page_index: page } : {},
...addQueries, // eventually we should provide a way to type this ... or not. It works
...(sort ? { sort_ascending: true } : {}),
};
@@ -83,15 +87,13 @@ export default function useListContent({
if (urlUpdate) { history.replace({ pathname, search }); }
statusSet(FetchStatus.in_progress);
fetcher(urlParam, {}, queries).then((res: any) => {
fetcher(urlParam, request, queries).then((res: any) => {
if (debug)
console.log(`🪲 useListContent success debug at: ${debug}`, res);
console.log(`🪲 useListContent success debug at: ${debug}`, res, resultsKey);
statusSet(FetchStatus.success);
onSuccess(res);
if (res.results && res.pagination) {
pageCountSet(res.pagination.total_page_count);
listSet(res.results);
}
if (res[resultsKey]) { listSet(res[resultsKey]); }
if (res.pagination) { pageCountSet(res.pagination.total_page_count); }
});
}
}
@@ -105,6 +107,8 @@ export default function useListContent({
pathname,
page,
sort,
request,
resultsKey,
status,
urlParam,
urlUpdate
@@ -63,6 +63,7 @@ export default function EngineCompositor({ value, sessionWrapper }: Props) {
aspectRatio: "landscape",
label: "Choose 3D data",
onChange,
type: "media",
mediaType: "bvh",
}}
/>
@@ -31,13 +31,14 @@ export default function DevMediaInput({ value }: Props) {
<SegmentButtons {...{ onChange: ({ target }: { target: any }) => entityTypeSet(target.value), options, value: entityType }}/>
<TempInput {...{ value: owner, onChange: ({ target }: { target: any }) => ownerSet(target.value), placeholder: "User" }}/>
<TempSelect {...{ options: EntityFilterOptions(entityType), value: ["",mediaType,weightType][entityType], onChange: changeFilter }}/>
<Button {...{ label: "Enqueue", variant: "primary" }}/>
</header>
<EntityInput {...{
aspectRatio: "landscape",
label: `Choose ${ ["","media file","weight"][entityType] }`,
onChange,
owner,
search: "Dream",
type: "Media",
...([{},{ mediaType },{ weightType }][entityType])
}}/>
<Button {...{ className: "mt-3", label: "Open modal", onClick: openModal, variant: "primary" }}/>
@@ -21,7 +21,7 @@ export default function MediaTab() {
const bookmarks = useBookmarks();
const ratings = useRatings();
const toTopBtnRef = useRef<HTMLDivElement | null>(null);
const onScreen = useOnScreen(toTopBtnRef,"0px");
const onScreen = useOnScreen(toTopBtnRef, "0px");
const gridContainerRef = useRef<HTMLDivElement | null>(null);
const [mediaType, mediaTypeSet] = useState(
@@ -86,20 +86,30 @@ export default function MediaTab() {
}}
/>
</div>
{ media.urlCursor ?
<Button {...{
className: `to-top-button`,
buttonRef: toTopBtnRef,
{media.urlCursor ? (
<div>
<Button
{...{
className: `to-top-button`,
buttonRef: toTopBtnRef,
label: "Back to top",
onClick: () => media.reset(),
small: true,
}}
/>
</div>
) : null}
</div>
{media.urlCursor && !onScreen ? (
<Button
{...{
className: `to-top-button-off-screen`,
label: "Back to top",
onClick: () => media.reset(),
}}/> : null }
</div>
{ media.urlCursor && !onScreen ?
<Button {...{
className: `to-top-button-off-screen`,
label: "Back to top",
onClick: () => media.reset(),
}}/> : null }
small: true,
}}
/>
) : null}
<AudioPlayerProvider>
{media.isLoading && !media.list.length ? (
<div className="row gx-3 gy-3">
@@ -108,7 +118,6 @@ export default function MediaTab() {
))}
</div>
) : (
<InfiniteScroll
dataLength={media.list.length}
next={media.getMore}
@@ -21,12 +21,16 @@ export default function WeightsTab() {
const bookmarks = useBookmarks();
const ratings = useRatings();
const gridContainerRef = useRef<HTMLDivElement | null>(null);
const [weightType, weightTypeSet] = useState(urlQueries.get("maybe_scoped_weight_type") || "all");
const [weightCategory, weightCategorySet] = useState(urlQueries.get("maybe_scoped_weight_category") || "all");
const [weightType, weightTypeSet] = useState(
urlQueries.get("maybe_scoped_weight_type") || "all"
);
const [weightCategory, weightCategorySet] = useState(
urlQueries.get("maybe_scoped_weight_category") || "all"
);
const [showMasonryGrid, setShowMasonryGrid] = useState(true);
const [list, listSet] = useState<Weight[]>([]);
const toTopBtnRef = useRef<HTMLDivElement | null>(null);
const onScreen = useOnScreen(toTopBtnRef,"0px");
const onScreen = useOnScreen(toTopBtnRef, "0px");
const weights = useLazyLists({
addQueries: {
page_size: 24,
@@ -39,8 +43,8 @@ export default function WeightsTab() {
list,
listSet,
onInputChange: () => setShowMasonryGrid(false),
onSuccess: (res) => {
bookmarks.gather({ res, expand: true, key: "weight_token" }); // expand rather than replace for lazy loading
onSuccess: res => {
bookmarks.gather({ res, expand: true, key: "weight_token" }); // expand rather than replace for lazy loading
ratings.gather({ res, expand: true, key: "weight_token" });
setShowMasonryGrid(true);
},
@@ -54,7 +58,8 @@ export default function WeightsTab() {
// { value: "sd", label: "Image Generation" },
// ];
const weightTypeOpts = [ // these probably need beter labels
const weightTypeOpts = [
// these probably need beter labels
{ value: "all", label: "All weight types" },
{ value: "hifigan_tt2", label: "hifigan_tt2" },
{ value: "sd_1.5", label: "sd_1.5" },
@@ -111,20 +116,24 @@ export default function WeightsTab() {
value: weights.sort,
}}
/>
<TempSelect {...{
icon: faFilter,
options: weightCategoryOpts,
name: "weightCategory",
onChange: weights.onChange,
value: weightCategory,
}} />
<TempSelect {...{
icon: faFilter,
options: weightTypeOpts,
name: "weightType",
onChange: weights.onChange,
value: weightType,
}} />
<TempSelect
{...{
icon: faFilter,
options: weightCategoryOpts,
name: "weightCategory",
onChange: weights.onChange,
value: weightCategory,
}}
/>
<TempSelect
{...{
icon: faFilter,
options: weightTypeOpts,
name: "weightType",
onChange: weights.onChange,
value: weightType,
}}
/>
{/* {selectedFilter === "tts" && (
<TempSelect
options={modelTtsOptions}
@@ -147,20 +156,31 @@ export default function WeightsTab() {
/>
)} */}
</div>
{ weights.urlCursor ?
<Button {...{
className: `to-top-button`,
buttonRef: toTopBtnRef,
{weights.urlCursor ? (
<div>
<Button
{...{
className: `to-top-button`,
buttonRef: toTopBtnRef,
label: "Back to top",
onClick: () => weights.reset(),
small: true,
}}
/>
</div>
) : null}
</div>
{weights.urlCursor && !onScreen ? (
<Button
{...{
className: `to-top-button-off-screen`,
label: "Back to top",
onClick: () => weights.reset(),
}}/> : null }
</div>
{ weights.urlCursor && !onScreen ?
<Button {...{
className: `to-top-button-off-screen`,
label: "Back to top",
onClick: () => weights.reset(),
}}/> : null }
small: true,
}}
/>
) : null}
<AudioPlayerProvider>
{weights.isLoading && !weights.list.length ? (
<div className="row gx-3 gy-3">
@@ -1,7 +1,10 @@
import {
faFileArrowUp,
faFlask,
faImage,
faMessageDots,
faSparkles,
faWaveform,
faWaveformLines,
} from "@fortawesome/pro-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { SessionWrapper } from "@storyteller/components/src/session/SessionWrapper";
@@ -24,25 +27,37 @@ export default function Dashboard(props: DashboardProps) {
if (isLoggedIn) {
uploadModelSection = (
<>
<h2 className="fw-bold mb-4 mt-5 pt-4">Upload Models</h2>
<h2 className="fw-bold mb-4 mt-5 pt-4">Upload Weights</h2>
<div className="panel p-4 rounded">
<div className="row gy-3 zi-2">
<div className="col-12 col-lg-4">
<Link to="/upload/tts" className="btn btn-secondary">
<FontAwesomeIcon icon={faFileArrowUp} className="me-2" />
<FontAwesomeIcon icon={faMessageDots} className="me-2" />
Upload TTS Model
</Link>
</div>
<div className="col-12 col-lg-4">
<Link to="/upload/voice_conversion" className="btn btn-secondary">
<FontAwesomeIcon icon={faFileArrowUp} className="me-2" />
<FontAwesomeIcon icon={faWaveformLines} className="me-2" />
Upload V2V Model
</Link>
</div>
<div className="col-12 col-lg-4">
<Link to="/upload/w2l_photo" className="btn btn-secondary">
<FontAwesomeIcon icon={faFileArrowUp} className="me-2" />
Upload W2L Model
<Link to="/upload/vocoder" className="btn btn-secondary">
<FontAwesomeIcon icon={faWaveform} className="me-2" />
Upload Vocoder
</Link>
</div>
<div className="col-12 col-lg-4">
<Link to="/upload/sd" className="btn btn-secondary">
<FontAwesomeIcon icon={faImage} className="me-2" />
Upload Stable Diffusion Weight
</Link>
</div>
<div className="col-12 col-lg-4">
<Link to="/upload/lora" className="btn btn-secondary">
<FontAwesomeIcon icon={faImage} className="me-2" />
Upload LoRA weight
</Link>
</div>
</div>
@@ -17,7 +17,7 @@ import {
faLink,
faFileCircleXmark,
faArrowRightArrowLeft,
faVideoPlus
faVideoPlus,
} from "@fortawesome/pro-solid-svg-icons";
import Accordion from "components/common/Accordion";
import DataTable from "components/common/DataTable";
@@ -39,7 +39,11 @@ export default function MediaPage() {
const { canEditTtsModel, user } = useSession();
const { token } = useParams<{ token: string }>();
const ratings = useRatings();
const { media: mediaFile, remove, status } = useMedia({
const {
media: mediaFile,
remove,
status,
} = useMedia({
mediaToken: token,
onSuccess: (res: any) => {
ratings.gather({ res, key: "token" });
@@ -50,8 +54,6 @@ export default function MediaPage() {
const dateCreated = moment(mediaFile?.created_at || "").format("LLL");
const [buttonLabel, setButtonLabel] = useState("Copy");
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
const closeDeleteModal = () => setIsDeleteModalOpen(false);
@@ -294,7 +296,7 @@ export default function MediaPage() {
break;
default:
mediaDetails = defaultDetails;
break
break;
}
let modMediaDetails = undefined;
@@ -368,7 +370,14 @@ export default function MediaPage() {
<div className="d-flex gap-3 flex-wrap align-items-center">
<div className="d-flex gap-2 align-items-center flex-wrap">
<div>
<Badge {...{ className: `fy-entity-type-${ mediaFile?.media_type || "" }`, label: mediaType, }}/>
<Badge
{...{
className: `fy-entity-type-${
mediaFile?.media_type || ""
}`,
label: mediaType,
}}
/>
</div>
{subtitleDivider}
@@ -421,7 +430,7 @@ export default function MediaPage() {
<div className="col-12 col-xl-4">
<div className="panel panel-clear d-flex flex-column gap-3">
<div className="d-flex gap-2 flex-wrap">
{ mediaFile?.media_type === MediaFileType.Audio ? (
{mediaFile?.media_type === MediaFileType.Audio ? (
<Button
{...{
icon: faFaceViewfinder,
@@ -431,8 +440,8 @@ export default function MediaPage() {
className: "flex-grow-1",
}}
/>
) : null }
{ mediaFile?.media_type === MediaFileType.BVH ? (
) : null}
{mediaFile?.media_type === MediaFileType.BVH ? (
<Button
{...{
icon: faVideoPlus,
@@ -442,7 +451,7 @@ export default function MediaPage() {
className: "flex-grow-1",
}}
/>
) : null }
) : null}
{mediaFile?.media_type !== MediaFileType.Audio && (
<Button
@@ -452,6 +461,7 @@ export default function MediaPage() {
href={audioLink}
download={audioLink}
variant="secondary"
target="_blank"
/>
)}
{mediaFile?.media_type === MediaFileType.Audio && (
@@ -463,6 +473,7 @@ export default function MediaPage() {
href={audioLink}
download={audioLink}
tooltip="Download"
target="_blank"
/>
</div>
)}
@@ -636,7 +647,7 @@ export default function MediaPage() {
handleClose={closeDeleteModal}
title="Delete Media"
content={() => (
<>{`Are you sure you want to delete this media file? This action cannot be undone.`}</> // replace w/ dynamic later -V
<>{`Are you sure you want to delete this media file? This action cannot be undone.`}</> // replace w/ dynamic later -V
// <>{`Are you sure you want to delete "${title}"? This action cannot be undone.`}</>
)}
onConfirm={deleteMedia}
@@ -110,6 +110,7 @@ export default function WeightPage({
const deleteWeight = () => remove(!!user?.can_ban_users);
//Studio Access feature flag
switch (weight?.weight_type) {
case WeightType.SD_15:
case WeightType.SDXL:
@@ -119,6 +120,34 @@ export default function WeightPage({
}
}
//Image generation panel if it's a lora weight or sd weight
let imageGenPanel = <></>;
switch (weight?.weight_type) {
case WeightType.SD_15:
case WeightType.SDXL:
imageGenPanel = (
<SdInferencePanel
inferenceJobs={inferenceJobs}
sessionSubscriptionsWrapper={sessionSubscriptionsWrapper}
weight_token={weight?.weight_token}
enqueueInferenceJob={enqueueInferenceJob}
weightPageType="sd"
/>
);
break;
case WeightType.LORA:
imageGenPanel = (
<SdInferencePanel
inferenceJobs={inferenceJobs}
sessionSubscriptionsWrapper={sessionSubscriptionsWrapper}
weight_token={weight?.weight_token}
enqueueInferenceJob={enqueueInferenceJob}
weightPageType="lora"
/>
);
break;
}
function renderWeightComponent(weight: Weight) {
switch (weight.weight_category) {
case WeightCategory.TTS:
@@ -168,12 +197,7 @@ export default function WeightPage({
return (
<div className="d-flex flex-column gap-3">
<SdCoverImagePanel src={sdCoverImage} />
<SdInferencePanel
inferenceJobs={inferenceJobs}
sessionSubscriptionsWrapper={sessionSubscriptionsWrapper}
sd_model_token={weight.weight_token}
enqueueInferenceJob={enqueueInferenceJob}
/>
{imageGenPanel}
</div>
);
default:
@@ -1,4 +1,4 @@
import React, { useRef, useState, memo } from "react";
import React, { useRef, useState, memo, useEffect } from "react";
import {
Accordion,
Button,
@@ -18,7 +18,6 @@ import {
faRectangleLandscape,
faRectanglePortrait,
faSquare,
faUpload,
} from "@fortawesome/pro-solid-svg-icons";
import { v4 as uuidv4 } from "uuid";
import {
@@ -34,30 +33,43 @@ import { SessionSubscriptionsWrapper } from "@storyteller/components/src/session
import PremiumLock from "components/PremiumLock";
import InferenceJobsList from "components/layout/InferenceJobsList";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link } from "react-router-dom";
interface SdInferencePanelProps {
inferenceJobs: Array<InferenceJob>;
sessionSubscriptionsWrapper: SessionSubscriptionsWrapper;
sd_model_token?: string;
weight_token?: string;
enqueueInferenceJob: (
jobToken: string,
frontendInferenceJobType: FrontendInferenceJobType
) => void;
isStandalone?: boolean;
weightPageType?: "lora" | "sd";
}
function SdInferencePanel({
enqueueInferenceJob,
sd_model_token,
weight_token,
sessionSubscriptionsWrapper,
isStandalone = false,
inferenceJobs,
weightPageType = "sd",
}: SdInferencePanelProps) {
const [loraToken, setLoraToken] = useState<string | null>(null);
const [weightToken, setWeightToken] = useState(sd_model_token);
const [sdToken, setSdToken] = useState<string | null>(null);
useEffect(() => {
if (weightPageType === "sd") {
setSdToken(weight_token || null);
setLoraToken(null);
} else if (weightPageType === "lora") {
setLoraToken(weight_token || null);
setSdToken(null);
}
}, [weightPageType, weight_token]);
const handleOnWeightSelect = (data: { token: string; title: string }) => {
setWeightToken(data.token);
setSdToken(data.token);
};
const handleOnSelect = (data: { token: string; title: string }) => {
setLoraToken(data.token);
@@ -243,7 +255,7 @@ function SdInferencePanel({
) => {
ev.preventDefault();
if (!prompt || weightToken === undefined) {
if (!prompt || sdToken === undefined) {
return false;
}
@@ -258,10 +270,12 @@ function SdInferencePanel({
internalSeed.current = generateRandomSeed();
}
console.log(sdToken);
const request = {
uuid_idempotency_token: uuidv4(),
maybe_sd_model_token: isStandalone ? weightToken : sd_model_token,
maybe_lora_model_token: loraToken,
maybe_sd_model_token: sdToken || null,
maybe_lora_model_token: loraToken || null,
maybe_prompt: prompt,
maybe_n_prompt: negativePrompt,
maybe_seed: internalSeed.current,
@@ -305,29 +319,16 @@ function SdInferencePanel({
<div>
<SplitPanel dividerHeader={true}>
<SplitPanel.Header padding={true}>
<div className="d-flex flex-wrap gap-2 align-items-center">
<h4 className="fw-semibold mb-0 flex-grow-1">Generate an Image</h4>
{isStandalone && (
<div>
<Button
icon={faUpload}
label="Upload Weight"
variant="secondary"
small={true}
to="/upload/sd"
/>
</div>
)}
</div>
<h4 className="fw-semibold mb-0 flex-grow-1">Generate an Image</h4>
</SplitPanel.Header>
<SplitPanel.Body padding={true}>
<div className="d-flex flex-column gap-3 mb-4">
{isStandalone && (
{(isStandalone || weightPageType === "lora") && (
<SelectModal
required={true}
modalTitle="Select a Weight"
label="Select a Weight"
modalTitle="Select Stable Diffusion Weight"
label="Select a Stable Diffusion Weight"
onSelect={handleOnWeightSelect}
tabs={[
{
@@ -433,27 +434,30 @@ function SdInferencePanel({
value: samples,
}}
/>
<SelectModal
label="Additional LoRA Weight"
onSelect={handleOnSelect}
tabs={[
{
label: "All LoRA Weights",
tabKey: "allLoraWeights",
typeFilter: "loRA",
searcher: true,
type: "weights",
},
{
label: "Bookmarked",
tabKey: "bookmarkedLoraWeights",
typeFilter: "loRA",
searcher: false,
type: "weights",
onlyBookmarked: true,
},
]}
/>
{weightPageType === "sd" && (
<SelectModal
modalTitle="Select LoRA Weight"
label="Additional LoRA Weight"
onSelect={handleOnSelect}
tabs={[
{
label: "All LoRA Weights",
tabKey: "allLoraWeights",
typeFilter: "loRA",
searcher: true,
type: "weights",
},
{
label: "Bookmarked",
tabKey: "bookmarkedLoraWeights",
typeFilter: "loRA",
searcher: false,
type: "weights",
onlyBookmarked: true,
},
]}
/>
)}
<div>
<Label label="Number of Generations" />
<PremiumLock
@@ -473,22 +477,35 @@ function SdInferencePanel({
</div>
</Accordion.Item>
</Accordion>
<div className="d-flex gap-2 justify-content-end mt-4 mb-3">
<Button
{...{
label: "Clear All",
variant: "secondary",
onClick: resetToInitialState,
}}
/>
<Button
{...{
label: "Generate Image",
disabled: prompt === "" || weightToken === "",
onClick: handleEnqueueImageGen,
isLoading: isEnqueuing,
}}
/>
<div className="d-flex mt-4 align-items-center flex-wrap gap-4">
{isStandalone && (
<div className="flex-grow-1">
<p className="fs-7">
<span className="opacity-75">
Can't find the model weights you're looking for?
</span>{" "}
<Link to="/upload/sd">Upload your own!</Link>
</p>
</div>
)}
<div className="d-flex gap-2 justify-content-end flex-grow-1">
<Button
{...{
label: "Clear/Reset ",
variant: "secondary",
onClick: resetToInitialState,
}}
/>
<Button
{...{
label: "Generate Image",
disabled: prompt === "" || sdToken === "",
onClick: handleEnqueueImageGen,
isLoading: isEnqueuing,
}}
/>
</div>
</div>
</SplitPanel.Body>