GeoffVague
commited on
Commit
Β·
9bad642
1
Parent(s):
ec44a4c
Add 4 files
Browse files
README.md
CHANGED
@@ -1,11 +1,8 @@
|
|
1 |
---
|
|
|
2 |
title: Crazy Hip Hop Christmas AI Image Prompt Generator
|
3 |
-
emoji: π¦
|
4 |
-
colorFrom: purple
|
5 |
-
colorTo: blue
|
6 |
sdk: static
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
license: apache-2.0
|
3 |
title: Crazy Hip Hop Christmas AI Image Prompt Generator
|
|
|
|
|
|
|
4 |
sdk: static
|
5 |
+
emoji: π¨βπ»
|
6 |
+
colorFrom: yellow
|
7 |
+
colorTo: green
|
8 |
+
---
|
|
app.js
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { createApp, ref, onMounted } from "alpinejs";
|
2 |
+
import { gsap } from "gsap";
|
3 |
+
import { VisualRecognitionV3 } from "@WatsonService/watson-vision-combined";
|
4 |
+
import * as Three from "three";
|
5 |
+
import "../style/index.css";
|
6 |
+
|
7 |
+
const App = {
|
8 |
+
setup() {
|
9 |
+
const image = ref(null);
|
10 |
+
const camera = ref(null);
|
11 |
+
const renderer = ref(null);
|
12 |
+
const scene = ref(null);
|
13 |
+
|
14 |
+
onMounted(() => {
|
15 |
+
const ctx = setupCanvas();
|
16 |
+
init();
|
17 |
+
animate();
|
18 |
+
});
|
19 |
+
|
20 |
+
function setupCanvas() {
|
21 |
+
const ctx = document.createElement("canvas").getContext("2d");
|
22 |
+
ctx.canvas.width = window.innerWidth;
|
23 |
+
ctx.canvas.height = window.innerHeight;
|
24 |
+
ctx.imageSmoothingEnabled = true;
|
25 |
+
return ctx;
|
26 |
+
}
|
27 |
+
|
28 |
+
function init() {
|
29 |
+
camera = Three.PerspectiveCamera(
|
30 |
+
30,
|
31 |
+
window.innerWidth / window.innerHeight,
|
32 |
+
0.1,
|
33 |
+
1000
|
34 |
+
);
|
35 |
+
|
36 |
+
scene = new Three.Scene();
|
37 |
+
|
38 |
+
const geometry = new Three.BoxGeometry(0.1, 0.1, 0.1);
|
39 |
+
const material = new Three.MeshBasicMaterial({
|
40 |
+
color: 0x000000,
|
41 |
+
wireframe: true,
|
42 |
+
});
|
43 |
+
const cube = new Three.Mesh(geometry, material);
|
44 |
+
scene.add(cube);
|
45 |
+
|
46 |
+
renderer = new Three.WebGLRenderer({
|
47 |
+
canvas: ctx.canvas,
|
48 |
+
});
|
49 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
50 |
+
renderer.setClearColor(0x000000, 1);
|
51 |
+
|
52 |
+
document.body.appendChild(renderer.domElement);
|
53 |
+
}
|
54 |
+
|
55 |
+
function animate() {
|
56 |
+
requestAnimationFrame(animate);
|
57 |
+
|
58 |
+
const time = performance.now() * 0.3;
|
59 |
+
camera.position.x = Math.sin(time) * 1;
|
60 |
+
camera.position.y = Math.sin(time) * 1;
|
61 |
+
camera.position.z = Math.sin(time) * 1;
|
62 |
+
camera.lookAt(scene.position);
|
63 |
+
|
64 |
+
renderer.render(scene, camera);
|
65 |
+
}
|
66 |
+
},
|
67 |
+
methods: {
|
68 |
+
generateImage() {
|
69 |
+
image.value = new FormData();
|
70 |
+
const request = new XMLHttpRequest();
|
71 |
+
request.open("POST", "/api/generate", true);
|
72 |
+
request.send(image.value);
|
73 |
+
request.onload = () => {
|
74 |
+
let img = new Image();
|
75 |
+
img.src = URL.createObjectURL(request.response.image);
|
76 |
+
document.body.appendChild(img);
|
77 |
+
};
|
78 |
+
},
|
79 |
+
},
|
80 |
+
};
|
81 |
+
|
82 |
+
createApp(App);
|
index.html
CHANGED
@@ -1,19 +1 @@
|
|
1 |
-
|
2 |
-
<html>
|
3 |
-
<head>
|
4 |
-
<meta charset="utf-8" />
|
5 |
-
<meta name="viewport" content="width=device-width" />
|
6 |
-
<title>My static Space</title>
|
7 |
-
<link rel="stylesheet" href="style.css" />
|
8 |
-
</head>
|
9 |
-
<body>
|
10 |
-
<div class="card">
|
11 |
-
<h1>Welcome to your static Space!</h1>
|
12 |
-
<p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
|
13 |
-
<p>
|
14 |
-
Also don't forget to check the
|
15 |
-
<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
|
16 |
-
</p>
|
17 |
-
</div>
|
18 |
-
</body>
|
19 |
-
</html>
|
|
|
1 |
+
<html><head><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.css" rel="stylesheet" type="text/css" /><script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script><script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"></script><script defer src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.156.1/three.min.js"></script><script type="module" src="main.js"></script><title>Crazy Hip Hop Christmas AI Image Prompt Generator</title></head><body><main class="prose" data-path="/app/index.js"></main><footer class="footer text-sm gray-600"><button type="button" class="py-3 px-4 border border-gray-500 font-medium text-sm rounded text-gray-700 bg-gray-200 hover:bg-gray-300 active:bg-gray-300 transition duration-150 ease-in-out">Generate Image</button></footer></body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
style.css
CHANGED
@@ -1,28 +1,31 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
h1 {
|
7 |
-
font-size: 16px;
|
8 |
-
margin-top: 0;
|
9 |
}
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
margin-top: 5px;
|
16 |
}
|
17 |
|
18 |
-
.
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
}
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
* {
|
2 |
+
box-sizing: border-box;
|
3 |
+
margin: 0;
|
4 |
+
padding: 0;
|
|
|
|
|
|
|
|
|
5 |
}
|
6 |
|
7 |
+
body {
|
8 |
+
background-color: #f0f0f0;
|
9 |
+
padding: 20px;
|
10 |
+
font-family: Arial, sans-serif;
|
|
|
11 |
}
|
12 |
|
13 |
+
.prose {
|
14 |
+
margin: 20px auto;
|
15 |
+
padding: 10px;
|
16 |
+
background-color: #fafafa;
|
17 |
+
border: 1px solid #ddd;
|
18 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
19 |
}
|
20 |
|
21 |
+
footer {
|
22 |
+
position: fixed;
|
23 |
+
bottom: 0;
|
24 |
+
left: 0;
|
25 |
+
right: 0;
|
26 |
+
height: 60px;
|
27 |
+
background-color: #333;
|
28 |
+
color: #fff;
|
29 |
+
text-align: center;
|
30 |
+
font-size: 24px;
|
31 |
+
}
|