Spaces:
Running
Running
init project + starting page
Browse files- README.md +1 -1
- app/api/bulk-create/data.json +50 -0
- app/api/bulk-create/route.ts +41 -0
- app/api/start/route.ts +22 -20
- app/layout.tsx +5 -2
- app/page.tsx +24 -5
- assets/css/fonts.css +48 -0
- assets/css/globals.css +21 -0
- assets/fonts/trap/Trap-Black.otf +0 -0
- assets/fonts/trap/Trap-Bold.otf +0 -0
- assets/fonts/trap/Trap-ExtraBold.otf +0 -0
- assets/fonts/trap/Trap-Light.otf +0 -0
- assets/fonts/trap/Trap-Medium.otf +0 -0
- assets/fonts/trap/Trap-Regular.otf +0 -0
- assets/fonts/trap/Trap-SemiBold.otf +0 -0
- assets/globals.css +0 -27
- components/button/button.tsx +42 -0
- components/quizz/hooks/useQuizz.ts +5 -3
- components/quizz/index.tsx +13 -9
- data/dev.db +0 -0
- next.config.js +3 -1
- prisma/schema.prisma +3 -12
- public/background_noisy.webp +0 -0
- public/next.svg +0 -1
- public/vercel.svg +0 -1
- tailwind.config.ts +8 -0
- utils/generation/images.ts +8 -18
- utils/type.ts +2 -2
- utils/uploader.ts +3 -4
README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
title: Guess The Image
|
3 |
emoji: 🔎
|
4 |
colorFrom: green
|
5 |
-
colorTo:
|
6 |
sdk: docker
|
7 |
pinned: false
|
8 |
app_port: 3000
|
|
|
2 |
title: Guess The Image
|
3 |
emoji: 🔎
|
4 |
colorFrom: green
|
5 |
+
colorTo: cyan
|
6 |
sdk: docker
|
7 |
pinned: false
|
8 |
app_port: 3000
|
app/api/bulk-create/data.json
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
"Design a space exploration concept with futuristic spacecraft, alien planets, and breathtaking cosmic landscapes.",
|
3 |
+
"2d animation, Show a medium shot of the wolf, with a mischievous glint in his eyes. His mouth is slightly open, revealing his sharp teeth. He is standing among the tall grass, scanning the area for potential prey.]unreal engine, hyper real --q 2 --v 5.2 --ar 16:9",
|
4 |
+
"Design an otherworldly alien creature with bioluminescent features, multiple appendages, and intricate patterns that evoke a sense of wonder and curiosity.",
|
5 |
+
"Design a futuristic cityscape with towering skyscrapers, flying cars, and advanced technology integrated into the urban environment.",
|
6 |
+
"Design a steampunk-inspired setting with intricate machinery, Victorian architecture, and airships soaring through the sky.",
|
7 |
+
"a mecha robot, pixel pfp, random collor, cyberpunk, synthwave, ornate, intricate, digital painting, concept art, smooth, sharp focus, illustration, black background, art by artgerm and greg rutkowski and alphonse mucha, 8 k",
|
8 |
+
"a cyberpunk ice cream truck, black velvet painting, artwork by Greg Rutkowski, John Berkey, Alexander Jansson, Kuvshinov, WLOP, Artgerm, trending on ArtStationHD. octane render, greg rutkowski, hyper realism, high detail, octane render, vervia, 8k",
|
9 |
+
"a beautiful painting of in the silent, starlit nights, beautiful flower, girl, by greg rutkowski, trending on artstation",
|
10 |
+
"a masterpiece ultrarealistic ultradetailed portrait of a incredibly beautiful 0 0 s blonde bimbo in pink clothes. baroque renaissance. medium shot, intricate, elegant, highly detailed. trending on artstation, digital art, by stanley artgerm lau, wlop, rossdraws, james jean, andrei riabovitchev, marc simonetti, yoshitaka amano. background by james jean and gustav klimt, light by julie bell, 4 k, porcelain skin.",
|
11 |
+
"Masculine face made of multicolored bubbles, motion blur, blur, bokeh, Affinity Photo, trending on Artstation, award-winning, art by Studio Ghibli, by Lisa Frank",
|
12 |
+
"rubik's cube transformer, tristan eaton, victo ngai, artgerm, rhads, ross draws",
|
13 |
+
"a fat ugly man, in the style of artgerm, gerald brom, atey ghailan and mike mignola, vibrant colors and hard shadows and strong rim light, plain background, comic cover art, trending on artstation",
|
14 |
+
"half joe biden half reptiloid, ultra realistic, concept art, intricate details, eerie, highly detailed, photorealistic, octane render, 8 k, unreal engine. art by artgerm and greg rutkowski and alphonse mucha",
|
15 |
+
"an illustration of a house with large barn with many cute flower pots and beautiful blue sky scenery. earth golem standing in yard, cinematic view, epic sky, detailed, concept art, low angle, high detail, warm lighting, volumetric, godrays, vivid, beautiful, trending on artstation, by jordan grimmer, huge scene, grass, art greg rutkowski",
|
16 |
+
"A beautiful digital painting of a sexy female anubis, holding a sword, the moon behind her, intricate, cinematic lighting, highly detailed, digital painting, Artstation, concept art, smooth, sharp focus, illustration, art by Tom Bagshaw, Artgerm and Greg Rutkowski",
|
17 |
+
"worm's eye view of overwatch headquarters carved inside a mountain surrounding a lush well kept garden, magical, natural light, fantasy, sharp focus, concept art, by greg rutkowski and craig mullins, cozy atmospheric",
|
18 |
+
"a portrait of a beautiful willa holland as a 1 9 5 0 s rockabilly greaser, art by lois van baarle and loish and ross tran and rossdraws and sam yang and samdoesarts and artgerm, digital art, highly detailed, intricate, sharp focus, trending on artstation hq, deviantart, unreal engine 5, 4 k uhd image",
|
19 |
+
"mariano rajoy with cyberpunk implants, deep focus, d & d, fantasy, intricate, elegant, highly detailed, digital painting, artstation, concept art, matte, sharp focus, illustration, hearthstone, art by artgerm and greg rutkowski and alphonse mucha",
|
20 |
+
"dwayne johnson holding a purple lightsaber wearing brown jedi robes, concept art, ultra realistic",
|
21 |
+
"panoramic view, a pilot girl, soldier clothing, battlefield in background, anime style, hair down, symmetrical facial features, realistic hands, from arknights, hyper realistic, 4 k, extreme detail, 1 0 1 st airborne, trending artstation, safebooru, realistic lighting, by alphonse mucha, greg rutkowski, sharp focus",
|
22 |
+
"danny devito riding a large harley davidson, hyperrealism, lens glare, trending on artstation, intricate, 8 k",
|
23 |
+
"a girl with short blue hair and blue eyes is sitting on a cloud, anime style, light effect, anime style hyper detailed, illustration, bloody, intricate, elegant, digital painting, artstation, smooth, sharp focus, art by artgerm and greg rutkowski and alphonse mucha.",
|
24 |
+
"totem aztek tribal deepdream intricate, elegant, sharp focus, illustration, highly detailed, digital painting, concept art, matte, art by WLOP and Artgerm and Greg Rutkowski and Alphonse Mucha, masterpiece",
|
25 |
+
"painting of dark muscular oiled indian woman back, ultra realistic, concept art, intricate details, eerie, highly detailed, photorealistic, octane render, 8 k, unreal engine. art by artgerm and greg rutkowski and alphonse mucha",
|
26 |
+
"ultra realistic illustration of taco cat, intricate, elegant, highly detailed, digital painting, artstation, concept art, smooth, sharp focus, illustration, art by artgerm and greg rutkowski and alphonse mucha",
|
27 |
+
"kyoto animation girl wearing cyberpunk intricate streetwear riding dirt bike, respirator, detailed portrait, cell shaded, 4 k, concept art, by wlop, ilya kuvshinov, artgerm, krenz cushart, greg rutkowski, pixiv. cinematic dramatic atmosphere, sharp focus, volumetric lighting, cinematic lighting, studio quality",
|
28 |
+
"office secretary anime, d & d, fantasy, portrait, highly detailed, headshot, digital painting, trending on artstation, concept art, sharp focus, illustration, art by artgerm and greg rutkowski and magali villeneuve",
|
29 |
+
"beautiful, young woman, cybernetic, cyberpunk, detailed gorgeous face, flowing hair, vaporwave aesthetic, synthwave , digital painting, artstation, concept art, smooth, sharp focus, illustration, art by artgerm and greg rutkowski and alphonse mucha",
|
30 |
+
"isometric chubby 3 d game cannon, with detailed, clean, cartoon, octane render, unreal engine, artgerm, artstation",
|
31 |
+
"kylie minogue making pancakes, animation pixar style, by pendleton ward, magali villeneuve, artgerm, rob rey and kentaro miura style, golden ratio, trending on art station",
|
32 |
+
"portrait knights of zodiac girl, golden and copper shining armor, karate pose, in ruined agora of athens sunrise, ssci - fi and fantasy, intricate and very very beautiful and elegant, highly detailed, digital painting, artstation, concept art, smooth and sharp focus, illustration, art by tian zi and wlop and alphonse mucha and z - - ed",
|
33 |
+
"a gladiator in roman times, intricate, elegant, volumetric lighting, scenery, digital painting, highly detailed, artstation, sharp focus, illustration, concept art,ruan jia, steve mccurry",
|
34 |
+
"Short, elf, grey skin with a green undertone, orange/red hair, ears are 3 inches long ending at a point, their eyes are like a pale yellow light all iris (no black or white), uhhh they have deer like legs that bend backwards to allow for faster movement, and they are both masc and femme equally so I don�t have to choose a gender dramatic lighting, illustration by Greg rutkowski, yoji shinkawa, 4k, digital art, concept art, trending on artstation",
|
35 |
+
"young glitchy woman, beautiful girl, vaporwave aesthetic, realistic, serov, surikov, vasnetsov, repin, kramskoi, uplight, insanely detailed, charlie bowater, tom bagshaw, octane rendered, 8 k, unreal engine, illustration, trending on artstation, masterpiece",
|
36 |
+
"painting of the figure of a pin up girl posing, high contrast, poster, clothes in the fashion of 6 0's, concept art, black and white, dramatic lighting, digital art, 8 k, drawn by arnold armitage",
|
37 |
+
"hyperdetailed portrait of kristen schaal as delirium of the endless, colourful make up, the sandman, made by caravaggio stanley artgerm lau wlop rossdraws artstation cgsociety concept art cgsociety octane render",
|
38 |
+
"a melting Roman numeral clock in the style of the painting the persistence of memory by Salvador Dali, dynamic lighting, photorealistic fantasy concept art, trending on art station, stunning visuals, creative, cinematic, ultra detailed",
|
39 |
+
"portrait of 1 2 yo emma watson at hogwarts, olive skin, long dark hair, beautiful bone structure, shiny gold background, intricate, elegant, highly detailed, digital painting, artstation, concept art, smooth, sharp focus, illustration, artgerm, rutkowski, mucha",
|
40 |
+
"this human has no soul, cinematic shot, 8 k, art by artgerm and greg rutkowski and alphonse muchav",
|
41 |
+
"a high contrast painting of a flooded ancient tower at night by ralph mcquarrie simon stalenhag carl spitzweg rene magritte roger dean, full-length view, highly detailed, vibrant colors, extremely high contrast!, symmetry, great composition, high detail, cinematic lighting, award winning masterpiece, trending on artstation",
|
42 |
+
"3 d goddess of death close - up profile portrait with ram skull. beautiful intricately detailed japanese crow kitsune mask and clasical japanese kimono. betta fish, jellyfish phoenix, bio luminescent, plasma, ice, water, wind, creature, artwork by tooth wu and wlop and beeple and greg rutkowski",
|
43 |
+
"painting of hybrid between butterfly!!!!!!!! & dragon, intercrossed animal, mixture animal, by tiffany bozic, by zdzislaw beksinski, biomorphic, cold hue's, warm tone gradient background, concept art, beautiful composition, digital painting",
|
44 |
+
"the beautiful scene render that a beautiful girl lies in the arms of a huge white dragon in the fairyland surrounded by white clouds, in the style of makoto shinkai victo ngai and peter mohrbacher studio ghibli artgerm karol bak beeple, animation style, 8 k hd, dream, trending on cgsociety, trending on artstation, ultra wide angle, animation style, hyperrealism, 3 d render, hyper detailed",
|
45 |
+
"a police car driving through shallow water, flooded city, raining, people walking through shallow water, muted colors, hyperrealistic, oil painting, intricate, cgsociety, artstation, 8 k, cinematic, soft lighting, by greg rutkowski, by wlop, by artgerm",
|
46 |
+
"fullbody!! dynamic movement pose, beautiful ethnic woman with flowing hair, big natural horns on her head, gold jewellery, dnd, face, fantasy, intricate, elegant, highly detailed, digital painting, artstation, concept art, smooth, sharp focus, illustration, art by artgerm and greg rutkowski and alphonse mucha",
|
47 |
+
"close up of hyper - realistic spongebob, photorealistic, mesmerizing, fantastical, concept art, highly detailed, artstation, trending, feng zhu, shaddy safadi, noah bradley, tyler edlin, jordan grimmer, darek zabrocki, neil blevins, tuomas korpi",
|
48 |
+
"marisol pepa flores, face portrait, elegant, fantasy, hd shot, digital portrait, beautiful, artstation, comic style, by artgerm, guy denning, jakub rozalski, magali villeneuve and charlie bowater",
|
49 |
+
"modern city, Parisian buildings, billboards, advertisements, small buildings, dark, matte painting, concept art, digital painting, style of Ian Hubert, warm lighting, futuristic, volumetric lighting, street view, daytime, godrays , high detail, no sky scrapers"
|
50 |
+
]
|
app/api/bulk-create/route.ts
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { NextRequest } from "next/server";
|
2 |
+
import { PrismaClient } from '@prisma/client'
|
3 |
+
|
4 |
+
import { generateImages } from "@/utils/generation/images";
|
5 |
+
|
6 |
+
const prisma = new PrismaClient()
|
7 |
+
|
8 |
+
export async function POST(request: NextRequest,) {
|
9 |
+
|
10 |
+
const { headers } = request
|
11 |
+
|
12 |
+
if (headers.get("x-hf-token") !== process.env.HF_TOKEN) {
|
13 |
+
return Response.json({
|
14 |
+
message: "Wrong castle fam :^)"
|
15 |
+
}, { status: 401 });
|
16 |
+
}
|
17 |
+
|
18 |
+
const req_headers = {
|
19 |
+
Authorization: `Bearer ${process.env.HF_TOKEN}`,
|
20 |
+
'Content-Type': 'application/json',
|
21 |
+
['x-use-cache']: "0"
|
22 |
+
}
|
23 |
+
|
24 |
+
const start_time = Date.now()
|
25 |
+
|
26 |
+
const { prompts } = await request.json()
|
27 |
+
const generated_prompts = await generateImages(req_headers, prompts);
|
28 |
+
|
29 |
+
for (
|
30 |
+
const prompt of generated_prompts
|
31 |
+
) {
|
32 |
+
await prisma.prompt.create({
|
33 |
+
data: prompt
|
34 |
+
})
|
35 |
+
}
|
36 |
+
|
37 |
+
const count = await prisma.prompt.count()
|
38 |
+
const end_time = Date.now()
|
39 |
+
|
40 |
+
return Response.json({ message: `${count} prompts has been created in a total of ${(end_time - start_time) / 1000} seconds`, ok: true, status: 200 });
|
41 |
+
}
|
app/api/start/route.ts
CHANGED
@@ -1,27 +1,29 @@
|
|
1 |
import { NextRequest } from "next/server";
|
|
|
2 |
|
3 |
-
|
4 |
-
import { getPrompts } from "@/utils/generation/prompt";
|
5 |
-
import { generateImages } from "@/utils/generation/images";
|
6 |
|
7 |
-
export async function
|
8 |
-
const
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
}
|
13 |
|
14 |
-
const {
|
15 |
-
|
16 |
-
return Response.json({}, { statusText: error, status: 500 });
|
17 |
-
}
|
18 |
-
if (prompts?.length !== 3) {
|
19 |
-
return Response.json({}, { statusText: "Not enough prompts. Try again.", status: 500 });
|
20 |
-
}
|
21 |
|
22 |
-
const
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
-
|
|
|
27 |
}
|
|
|
1 |
import { NextRequest } from "next/server";
|
2 |
+
import { PrismaClient } from '@prisma/client'
|
3 |
|
4 |
+
const prisma = new PrismaClient()
|
|
|
|
|
5 |
|
6 |
+
export async function GET(request: NextRequest,) {
|
7 |
+
const all_prompts = await prisma.prompt.findMany({
|
8 |
+
orderBy: {
|
9 |
+
id: 'desc'
|
10 |
+
}
|
11 |
+
})
|
12 |
|
13 |
+
const prompts: Array<{ prompt: string, file_name: string, id: number, is_correct?: boolean }> = []
|
14 |
+
const prompts_ids: Set<number> = new Set()
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
const is_correct = Math.floor(Math.random() * 3)
|
17 |
+
while (prompts.length < 3) {
|
18 |
+
const random_prompt = all_prompts[Math.floor(Math.random() * all_prompts.length)]
|
19 |
+
if (!prompts_ids.has(random_prompt.id)) {
|
20 |
+
prompts.push({
|
21 |
+
...random_prompt,
|
22 |
+
is_correct: prompts.length === is_correct
|
23 |
+
})
|
24 |
+
prompts_ids.add(random_prompt.id)
|
25 |
+
}
|
26 |
}
|
27 |
+
|
28 |
+
return Response.json({ prompts, ok: true, status: 200 });
|
29 |
}
|
app/layout.tsx
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import type { Metadata } from "next";
|
2 |
import { Inter } from "next/font/google";
|
3 |
-
import "@/assets/globals.css";
|
4 |
|
5 |
const inter = Inter({ subsets: ["latin"] });
|
6 |
|
@@ -16,7 +16,10 @@ export default function RootLayout({
|
|
16 |
}) {
|
17 |
return (
|
18 |
<html lang="en">
|
19 |
-
<body
|
|
|
|
|
|
|
20 |
</html>
|
21 |
);
|
22 |
}
|
|
|
1 |
import type { Metadata } from "next";
|
2 |
import { Inter } from "next/font/google";
|
3 |
+
import "@/assets/css/globals.css";
|
4 |
|
5 |
const inter = Inter({ subsets: ["latin"] });
|
6 |
|
|
|
16 |
}) {
|
17 |
return (
|
18 |
<html lang="en">
|
19 |
+
<body>
|
20 |
+
{children}
|
21 |
+
<div id="background__noisy" />
|
22 |
+
</body>
|
23 |
</html>
|
24 |
);
|
25 |
}
|
app/page.tsx
CHANGED
@@ -1,12 +1,31 @@
|
|
|
|
1 |
import { Quizz } from "@/components/quizz";
|
|
|
2 |
|
3 |
export default function Home() {
|
4 |
return (
|
5 |
-
<div className="w-full min-h-screen mx-auto max-w-
|
6 |
-
<
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
</div>
|
11 |
);
|
12 |
}
|
|
|
1 |
+
import { Button } from "@/components/button/button";
|
2 |
import { Quizz } from "@/components/quizz";
|
3 |
+
import Link from "next/link";
|
4 |
|
5 |
export default function Home() {
|
6 |
return (
|
7 |
+
<div className="w-full min-h-screen mx-auto max-w-4xl relative flex items-center justify-center">
|
8 |
+
<div className="relative grid grid-cols-1 gap-8 py-12 px-6">
|
9 |
+
<h1 className="text-center text-5xl md:text-7xl font-extrabold bg-clip-text text-transparent bg-gradient-to-b from-white to-white/80">
|
10 |
+
Which image is the <br />
|
11 |
+
<span className="bg-gradient-to-tr from-green to-cyan bg-clip-text">
|
12 |
+
good
|
13 |
+
</span>{" "}
|
14 |
+
one?
|
15 |
+
</h1>
|
16 |
+
<h2 className="text-white text-xl md:text-2xl text-center font-light">
|
17 |
+
Time to test if you now how to compose the perfect prompt. <br />
|
18 |
+
Try it now!
|
19 |
+
</h2>
|
20 |
+
<div className="w-full max-w-xs mx-auto">
|
21 |
+
<Link href="/quizz">
|
22 |
+
<Button theme="primary" className="mx-auto">
|
23 |
+
Start a quizz
|
24 |
+
</Button>
|
25 |
+
</Link>
|
26 |
+
</div>
|
27 |
+
<div className="absolute top-1/2 left-1/2 will-transform -translate-x-1/2 -translate-y-1/2 bg-gradient-to-br from-green to-cyan blur-[120px] md:blur-[140px] w-full h-full rounded-full z-[-1] opacity-30"></div>
|
28 |
+
</div>
|
29 |
</div>
|
30 |
);
|
31 |
}
|
assets/css/fonts.css
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@font-face {
|
2 |
+
font-family: 'Trap';
|
3 |
+
src: url('./../fonts/trap/Trap-Light.otf') format('truetype');
|
4 |
+
font-weight: 400;
|
5 |
+
font-style: normal;
|
6 |
+
}
|
7 |
+
|
8 |
+
@font-face {
|
9 |
+
font-family: 'Trap';
|
10 |
+
src: url('./../fonts/trap/Trap-Regular.otf') format('truetype');
|
11 |
+
font-weight: normal;
|
12 |
+
font-style: normal;
|
13 |
+
}
|
14 |
+
|
15 |
+
@font-face {
|
16 |
+
font-family: 'Trap';
|
17 |
+
src: url('./../fonts/trap/Trap-Medium.otf') format('truetype');
|
18 |
+
font-weight: 500;
|
19 |
+
font-style: normal;
|
20 |
+
}
|
21 |
+
|
22 |
+
@font-face {
|
23 |
+
font-family: 'Trap';
|
24 |
+
src: url('./../fonts/trap/Trap-SemiBold.otf') format('truetype');
|
25 |
+
font-weight: 600;
|
26 |
+
font-style: normal;
|
27 |
+
}
|
28 |
+
|
29 |
+
@font-face {
|
30 |
+
font-family: 'Trap';
|
31 |
+
src: url('./../fonts/trap/Trap-Bold.otf') format('truetype');
|
32 |
+
font-weight: 700;
|
33 |
+
font-style: normal;
|
34 |
+
}
|
35 |
+
|
36 |
+
@font-face {
|
37 |
+
font-family: 'Trap';
|
38 |
+
src: url('./../fonts/trap/Trap-ExtraBold.otf') format('truetype');
|
39 |
+
font-weight: 800;
|
40 |
+
font-style: normal;
|
41 |
+
}
|
42 |
+
|
43 |
+
@font-face {
|
44 |
+
font-family: 'Trap';
|
45 |
+
src: url('./../fonts/trap/Trap-Black.otf') format('truetype');
|
46 |
+
font-weight: 900;
|
47 |
+
font-style: normal;
|
48 |
+
}
|
assets/css/globals.css
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@tailwind base;
|
2 |
+
@tailwind components;
|
3 |
+
@tailwind utilities;
|
4 |
+
|
5 |
+
body {
|
6 |
+
@apply z-[1] relative bg-black min-h-screen;
|
7 |
+
font-family: 'Trap', sans-serif;
|
8 |
+
}
|
9 |
+
|
10 |
+
#background__noisy {
|
11 |
+
@apply bg-blend-normal pointer-events-none opacity-90;
|
12 |
+
background-size: 25ww auto;
|
13 |
+
background-image: url('/background_noisy.webp');
|
14 |
+
@apply fixed w-screen h-screen -z-[1] top-0 left-0;
|
15 |
+
}
|
16 |
+
|
17 |
+
@media (max-width: 768px) {
|
18 |
+
.will-transform {
|
19 |
+
will-change: transform;
|
20 |
+
}
|
21 |
+
}
|
assets/fonts/trap/Trap-Black.otf
ADDED
Binary file (11 kB). View file
|
|
assets/fonts/trap/Trap-Bold.otf
ADDED
Binary file (10.8 kB). View file
|
|
assets/fonts/trap/Trap-ExtraBold.otf
ADDED
Binary file (10.3 kB). View file
|
|
assets/fonts/trap/Trap-Light.otf
ADDED
Binary file (10.5 kB). View file
|
|
assets/fonts/trap/Trap-Medium.otf
ADDED
Binary file (10.5 kB). View file
|
|
assets/fonts/trap/Trap-Regular.otf
ADDED
Binary file (10.2 kB). View file
|
|
assets/fonts/trap/Trap-SemiBold.otf
ADDED
Binary file (10.6 kB). View file
|
|
assets/globals.css
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
@tailwind base;
|
2 |
-
@tailwind components;
|
3 |
-
@tailwind utilities;
|
4 |
-
|
5 |
-
:root {
|
6 |
-
--foreground-rgb: 0, 0, 0;
|
7 |
-
--background-start-rgb: 214, 219, 220;
|
8 |
-
--background-end-rgb: 255, 255, 255;
|
9 |
-
}
|
10 |
-
|
11 |
-
@media (prefers-color-scheme: dark) {
|
12 |
-
:root {
|
13 |
-
--foreground-rgb: 255, 255, 255;
|
14 |
-
--background-start-rgb: 0, 0, 0;
|
15 |
-
--background-end-rgb: 0, 0, 0;
|
16 |
-
}
|
17 |
-
}
|
18 |
-
|
19 |
-
body {
|
20 |
-
color: rgb(var(--foreground-rgb));
|
21 |
-
background: linear-gradient(
|
22 |
-
to bottom,
|
23 |
-
transparent,
|
24 |
-
rgb(var(--background-end-rgb))
|
25 |
-
)
|
26 |
-
rgb(var(--background-start-rgb));
|
27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
components/button/button.tsx
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import classNames from "classnames";
|
2 |
+
import { MouseEvent } from "react";
|
3 |
+
|
4 |
+
interface Props {
|
5 |
+
children: React.ReactNode;
|
6 |
+
disabled?: boolean;
|
7 |
+
className?: string;
|
8 |
+
theme?: "primary";
|
9 |
+
onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
|
10 |
+
}
|
11 |
+
export const Button: React.FC<Props> = ({
|
12 |
+
children,
|
13 |
+
disabled,
|
14 |
+
theme = "primary",
|
15 |
+
className,
|
16 |
+
onClick,
|
17 |
+
...props
|
18 |
+
}) => {
|
19 |
+
return (
|
20 |
+
<button
|
21 |
+
className={classNames(
|
22 |
+
`font-action px-6 w-full sm:w-auto py-3 sm:px-7 sm:py-4 text-sm sm:text-base uppercase font-semibold flex items-center justify-center gap-2.5 transition-all duration-200 tracking-widest ${className}`,
|
23 |
+
{
|
24 |
+
"bg-white text-[#0F110F]": theme === "primary",
|
25 |
+
disabled,
|
26 |
+
}
|
27 |
+
)}
|
28 |
+
{...props}
|
29 |
+
onClick={
|
30 |
+
onClick
|
31 |
+
? (e) => {
|
32 |
+
e.stopPropagation();
|
33 |
+
e.preventDefault();
|
34 |
+
onClick(e);
|
35 |
+
}
|
36 |
+
: undefined
|
37 |
+
}
|
38 |
+
>
|
39 |
+
{children}
|
40 |
+
</button>
|
41 |
+
);
|
42 |
+
};
|
components/quizz/hooks/useQuizz.ts
CHANGED
@@ -9,7 +9,7 @@ export const useQuizz = () => {
|
|
9 |
|
10 |
const generate = async () => {
|
11 |
setLoading(true);
|
12 |
-
const response = await fetch(`/api/start`, { method: '
|
13 |
const res = await response.json();
|
14 |
|
15 |
if (res.error) {
|
@@ -19,13 +19,15 @@ export const useQuizz = () => {
|
|
19 |
}
|
20 |
|
21 |
setError(undefined);
|
22 |
-
setQuizz(res.
|
23 |
setLoading(false);
|
24 |
}
|
25 |
|
|
|
|
|
26 |
const correctPrompt = useMemo(() => {
|
27 |
if (!quizz) return undefined;
|
28 |
-
return quizz?.find((prompt) => prompt.is_correct)?.
|
29 |
}, [quizz]);
|
30 |
|
31 |
return {
|
|
|
9 |
|
10 |
const generate = async () => {
|
11 |
setLoading(true);
|
12 |
+
const response = await fetch(`/api/start`, { method: 'GET' });
|
13 |
const res = await response.json();
|
14 |
|
15 |
if (res.error) {
|
|
|
19 |
}
|
20 |
|
21 |
setError(undefined);
|
22 |
+
setQuizz(res.prompts);
|
23 |
setLoading(false);
|
24 |
}
|
25 |
|
26 |
+
console.log(quizz);
|
27 |
+
|
28 |
const correctPrompt = useMemo(() => {
|
29 |
if (!quizz) return undefined;
|
30 |
+
return quizz?.find((prompt) => prompt.is_correct)?.prompt;
|
31 |
}, [quizz]);
|
32 |
|
33 |
return {
|
components/quizz/index.tsx
CHANGED
@@ -22,15 +22,19 @@ export const Quizz = () => {
|
|
22 |
</h1>
|
23 |
)}
|
24 |
<div className="grid grid-cols-3 gap-6">
|
25 |
-
{quizz?.map((item) => (
|
26 |
-
<
|
27 |
-
key={
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
))}
|
35 |
</div>
|
36 |
{/* <div className="bg-gray-600 p-4 rounded-lg text-sm text-white">
|
|
|
22 |
</h1>
|
23 |
)}
|
24 |
<div className="grid grid-cols-3 gap-6">
|
25 |
+
{quizz?.map((item, i) => (
|
26 |
+
<div
|
27 |
+
key={i}
|
28 |
+
className="w-full h-[450px] rounded-lg overflow-hidden"
|
29 |
+
>
|
30 |
+
<Image
|
31 |
+
src={`https://huggingface.co/datasets/enzostvs/what-is-the-prompt/resolve/main/${item?.file_name}?expose=true`}
|
32 |
+
alt="Generated image"
|
33 |
+
className="object-center object-cover w-full h-full"
|
34 |
+
width={250}
|
35 |
+
height={250}
|
36 |
+
/>
|
37 |
+
</div>
|
38 |
))}
|
39 |
</div>
|
40 |
{/* <div className="bg-gray-600 p-4 rounded-lg text-sm text-white">
|
data/dev.db
ADDED
Binary file (41 kB). View file
|
|
next.config.js
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
/** @type {import('next').NextConfig} */
|
2 |
const nextConfig = {
|
3 |
experimental: {
|
4 |
-
serverActions:
|
|
|
|
|
5 |
serverComponentsExternalPackages: ['sharp', 'onnxruntime-node'],
|
6 |
},
|
7 |
images: {
|
|
|
1 |
/** @type {import('next').NextConfig} */
|
2 |
const nextConfig = {
|
3 |
experimental: {
|
4 |
+
serverActions: {
|
5 |
+
basePath: "/api",
|
6 |
+
},
|
7 |
serverComponentsExternalPackages: ['sharp', 'onnxruntime-node'],
|
8 |
},
|
9 |
images: {
|
prisma/schema.prisma
CHANGED
@@ -7,17 +7,8 @@ datasource db {
|
|
7 |
url = "file:../data/dev.db"
|
8 |
}
|
9 |
|
10 |
-
model Quizz {
|
11 |
-
id Int @id @default(autoincrement())
|
12 |
-
prompts Prompt[]
|
13 |
-
file_name String
|
14 |
-
is Boolean @default(false)
|
15 |
-
}
|
16 |
-
|
17 |
model Prompt {
|
18 |
-
id
|
19 |
-
|
20 |
-
|
21 |
-
Collection Quizz? @relation(fields: [quizzId], references: [id])
|
22 |
-
quizzId Int?
|
23 |
}
|
|
|
7 |
url = "file:../data/dev.db"
|
8 |
}
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
model Prompt {
|
11 |
+
id Int @id @default(autoincrement())
|
12 |
+
prompt String
|
13 |
+
file_name String
|
|
|
|
|
14 |
}
|
public/background_noisy.webp
ADDED
![]() |
public/next.svg
DELETED
public/vercel.svg
DELETED
tailwind.config.ts
CHANGED
@@ -8,11 +8,19 @@ const config: Config = {
|
|
8 |
],
|
9 |
theme: {
|
10 |
extend: {
|
|
|
|
|
|
|
|
|
11 |
backgroundImage: {
|
12 |
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
|
13 |
'gradient-conic':
|
14 |
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
|
15 |
},
|
|
|
|
|
|
|
|
|
16 |
},
|
17 |
},
|
18 |
plugins: [],
|
|
|
8 |
],
|
9 |
theme: {
|
10 |
extend: {
|
11 |
+
fontFamily: {
|
12 |
+
sans: ["Trap", "serif"],
|
13 |
+
action: ["Inter", "sans-serif"]
|
14 |
+
},
|
15 |
backgroundImage: {
|
16 |
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
|
17 |
'gradient-conic':
|
18 |
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
|
19 |
},
|
20 |
+
colors: {
|
21 |
+
green: "#03FF2C",
|
22 |
+
cyan: "#03F0FF",
|
23 |
+
}
|
24 |
},
|
25 |
},
|
26 |
plugins: [],
|
utils/generation/images.ts
CHANGED
@@ -1,11 +1,7 @@
|
|
1 |
import { UploaderDataset } from "@/utils/uploader";
|
2 |
import { PromptType } from "@/utils/type";
|
3 |
|
4 |
-
export const generateImages = async (headers: any, prompts: Array<string>): Promise<{
|
5 |
-
error?: string,
|
6 |
-
status?: number,
|
7 |
-
quizz?: PromptType[],
|
8 |
-
}> => {
|
9 |
const promises = prompts.map(async (prompt: string): Promise<{
|
10 |
error?: string,
|
11 |
status?: number,
|
@@ -31,29 +27,23 @@ export const generateImages = async (headers: any, prompts: Array<string>): Prom
|
|
31 |
})
|
32 |
|
33 |
const results = await Promise.all(promises);
|
34 |
-
const hasError: any = results?.find((result: any) => result.error);
|
35 |
-
if (hasError) return { status: hasError.status, error: hasError.error };
|
36 |
-
|
37 |
-
const is_correct = Math.floor(Math.random() * 3);
|
38 |
|
39 |
const formatted_results: {
|
40 |
-
|
41 |
-
|
42 |
-
path: string,
|
43 |
}[] = [];
|
44 |
const blobs: Array<Blob> = [];
|
45 |
|
46 |
-
results.forEach((result: any
|
47 |
formatted_results.push({
|
48 |
-
|
49 |
-
|
50 |
-
path: `${Date.now()}-${result.prompt.replace(/[^a-zA-Z0-9]/g, '-').toLowerCase()}.png`,
|
51 |
});
|
52 |
blobs.push(result.blob);
|
53 |
});
|
54 |
|
55 |
const { ok, error } = await UploaderDataset(formatted_results, blobs);
|
56 |
-
if (!ok)
|
57 |
|
58 |
-
return
|
59 |
}
|
|
|
1 |
import { UploaderDataset } from "@/utils/uploader";
|
2 |
import { PromptType } from "@/utils/type";
|
3 |
|
4 |
+
export const generateImages = async (headers: any, prompts: Array<string>): Promise<{ file_name: string, prompt: string }[]> => {
|
|
|
|
|
|
|
|
|
5 |
const promises = prompts.map(async (prompt: string): Promise<{
|
6 |
error?: string,
|
7 |
status?: number,
|
|
|
27 |
})
|
28 |
|
29 |
const results = await Promise.all(promises);
|
|
|
|
|
|
|
|
|
30 |
|
31 |
const formatted_results: {
|
32 |
+
prompt: string,
|
33 |
+
file_name: string,
|
|
|
34 |
}[] = [];
|
35 |
const blobs: Array<Blob> = [];
|
36 |
|
37 |
+
results.forEach((result: any) => {
|
38 |
formatted_results.push({
|
39 |
+
prompt: result.prompt,
|
40 |
+
file_name: `${Date.now()}-${result.prompt.replace(/[^a-zA-Z0-9]/g, '-').toLowerCase()}.png`,
|
|
|
41 |
});
|
42 |
blobs.push(result.blob);
|
43 |
});
|
44 |
|
45 |
const { ok, error } = await UploaderDataset(formatted_results, blobs);
|
46 |
+
if (!ok) Response.json({}, { status: 500, statusText: error });
|
47 |
|
48 |
+
return formatted_results
|
49 |
}
|
utils/type.ts
CHANGED
@@ -3,7 +3,7 @@ export interface QuizzType {
|
|
3 |
}
|
4 |
|
5 |
export interface PromptType {
|
6 |
-
|
7 |
is_correct: boolean,
|
8 |
-
|
9 |
}
|
|
|
3 |
}
|
4 |
|
5 |
export interface PromptType {
|
6 |
+
prompt: string,
|
7 |
is_correct: boolean,
|
8 |
+
file_name?: string,
|
9 |
}
|
utils/uploader.ts
CHANGED
@@ -1,9 +1,8 @@
|
|
1 |
import { uploadFiles, RepoDesignation, Credentials } from "@huggingface/hub"
|
2 |
|
3 |
export const UploaderDataset = async (results: Array<{
|
4 |
-
|
5 |
-
|
6 |
-
is_correct: boolean;
|
7 |
}>, blobs: Array<Blob>) => {
|
8 |
const repo: RepoDesignation = { type: "dataset", name: "enzostvs/what-is-the-prompt" };
|
9 |
const credentials: Credentials = { accessToken: process.env.HF_TOKEN as string };
|
@@ -13,7 +12,7 @@ export const UploaderDataset = async (results: Array<{
|
|
13 |
credentials,
|
14 |
files: results.map((result, i) => {
|
15 |
return {
|
16 |
-
path: result.
|
17 |
content: blobs[i],
|
18 |
}
|
19 |
})
|
|
|
1 |
import { uploadFiles, RepoDesignation, Credentials } from "@huggingface/hub"
|
2 |
|
3 |
export const UploaderDataset = async (results: Array<{
|
4 |
+
file_name: string;
|
5 |
+
prompt: string;
|
|
|
6 |
}>, blobs: Array<Blob>) => {
|
7 |
const repo: RepoDesignation = { type: "dataset", name: "enzostvs/what-is-the-prompt" };
|
8 |
const credentials: Credentials = { accessToken: process.env.HF_TOKEN as string };
|
|
|
12 |
credentials,
|
13 |
files: results.map((result, i) => {
|
14 |
return {
|
15 |
+
path: result.file_name,
|
16 |
content: blobs[i],
|
17 |
}
|
18 |
})
|