|
|
|
@ -1,8 +1,9 @@
|
|
|
|
import { Button, Skeleton } from "@mui/material";
|
|
|
|
import { Button, CircularProgress, Divider, Skeleton } from "@mui/material";
|
|
|
|
import { PRESET_TOKENS } from "prompts/presets";
|
|
|
|
import { PRESET_TOKENS } from "prompts/presets";
|
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
|
import { generatePicture } from "service/service";
|
|
|
|
import { generatePicture } from "service/service";
|
|
|
|
import { GAME_SCENES, SceneProps } from "types";
|
|
|
|
import { GAME_SCENES, SceneProps } from "types";
|
|
|
|
|
|
|
|
import { Message } from "./ui";
|
|
|
|
|
|
|
|
|
|
|
|
type GenerateSceneProps = {
|
|
|
|
type GenerateSceneProps = {
|
|
|
|
prompts: string[];
|
|
|
|
prompts: string[];
|
|
|
|
@ -27,24 +28,28 @@ export const GenerateScene = ({ setScene, prompts }: GenerateSceneProps) => {
|
|
|
|
uc: "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",
|
|
|
|
uc: "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",
|
|
|
|
ucPreset: 0,
|
|
|
|
ucPreset: 0,
|
|
|
|
width: 256,
|
|
|
|
width: 256,
|
|
|
|
}).then((result) => {
|
|
|
|
})
|
|
|
|
setLoading(false);
|
|
|
|
.then((result) => {
|
|
|
|
console.log(result);
|
|
|
|
setLoading(false);
|
|
|
|
const source = result.data.split("\n");
|
|
|
|
console.log(result);
|
|
|
|
const fields = {} as any;
|
|
|
|
const source = result.data.split("\n");
|
|
|
|
source?.forEach((d: string) => {
|
|
|
|
const fields = {} as any;
|
|
|
|
const [name, s] = d.split(":");
|
|
|
|
source?.forEach((d: string) => {
|
|
|
|
fields[name] = s;
|
|
|
|
const [name, s] = d.split(":");
|
|
|
|
|
|
|
|
fields[name] = s;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
console.timeEnd();
|
|
|
|
|
|
|
|
setCode(fields.data);
|
|
|
|
|
|
|
|
// const data = new Uint8ClampedArray(buffer);
|
|
|
|
|
|
|
|
// console.log(data);
|
|
|
|
|
|
|
|
// const imageData = new ImageData(data, 256, 384);
|
|
|
|
|
|
|
|
// const canvas = document.getElementById("picture");
|
|
|
|
|
|
|
|
// const context = canvas.getContext("2d");
|
|
|
|
|
|
|
|
// context.putImageData(imageData);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
|
|
|
Message.error(e.message);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
console.timeEnd();
|
|
|
|
|
|
|
|
setCode(fields.data);
|
|
|
|
|
|
|
|
// const data = new Uint8ClampedArray(buffer);
|
|
|
|
|
|
|
|
// console.log(data);
|
|
|
|
|
|
|
|
// const imageData = new ImageData(data, 256, 384);
|
|
|
|
|
|
|
|
// const canvas = document.getElementById("picture");
|
|
|
|
|
|
|
|
// const context = canvas.getContext("2d");
|
|
|
|
|
|
|
|
// context.putImageData(imageData);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
generate();
|
|
|
|
generate();
|
|
|
|
@ -52,17 +57,11 @@ export const GenerateScene = ({ setScene, prompts }: GenerateSceneProps) => {
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
{loading && (
|
|
|
|
{loading && <CircularProgress />}
|
|
|
|
<Skeleton
|
|
|
|
|
|
|
|
sx={{ bgcolor: "grey.900" }}
|
|
|
|
|
|
|
|
variant="rectangular"
|
|
|
|
|
|
|
|
width={256}
|
|
|
|
|
|
|
|
height={384}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
{!loading && !!code && (
|
|
|
|
{!loading && !!code && (
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<img src={`data:image/jpeg;base64,${code}`}></img>
|
|
|
|
<img src={`data:image/jpeg;base64,${code}`}></img>
|
|
|
|
|
|
|
|
<Divider />
|
|
|
|
<Button
|
|
|
|
<Button
|
|
|
|
variant={"outlined"}
|
|
|
|
variant={"outlined"}
|
|
|
|
onClick={() => {
|
|
|
|
onClick={() => {
|
|
|
|
|