Lasur123 commited on
Commit
5d90d05
·
verified ·
1 Parent(s): 7d5356e

Make it text yo omage from promote given connecting to all the huggingface sfw and nsfw api

Browse files
Files changed (7) hide show
  1. README.md +7 -4
  2. components/footer.js +70 -0
  3. components/navbar.js +48 -0
  4. components/toast.js +61 -0
  5. index.html +166 -19
  6. script.js +192 -0
  7. style.css +81 -18
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Pixelweave Ai Text To Image Alchemy Studio
3
- emoji: 😻
4
  colorFrom: pink
5
- colorTo: red
 
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: PixelWeave AI | Text-to-Image Alchemy Studio
 
3
  colorFrom: pink
4
+ colorTo: pink
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://huggingface.co/deepsite).
components/footer.js ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomFooter extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ footer {
7
+ border-top: 1px solid #1e293b;
8
+ }
9
+
10
+ .footer-link:hover {
11
+ color: #8b5cf6;
12
+ }
13
+ </style>
14
+ <footer class="bg-secondary-600 mt-16">
15
+ <div class="container mx-auto px-4 py-12">
16
+ <div class="grid grid-cols-1 md:grid-cols-4 gap-8">
17
+ <div>
18
+ <h3 class="text-lg font-semibold mb-4">ShadowWeave AI</h3>
19
+ <p class="text-gray-400 text-sm">Pixel Alchemy Studio for the digital age.</p>
20
+ </div>
21
+
22
+ <div>
23
+ <h4 class="font-medium mb-4">Product</h4>
24
+ <ul class="space-y-2">
25
+ <li><a href="#" class="footer-link text-gray-400 text-sm">Features</a></li>
26
+ <li><a href="#" class="footer-link text-gray-400 text-sm">Pricing</a></li>
27
+ <li><a href="#" class="footer-link text-gray-400 text-sm">API</a></li>
28
+ </ul>
29
+ </div>
30
+
31
+ <div>
32
+ <h4 class="font-medium mb-4">Resources</h4>
33
+ <ul class="space-y-2">
34
+ <li><a href="#" class="footer-link text-gray-400 text-sm">Documentation</a></li>
35
+ <li><a href="#" class="footer-link text-gray-400 text-sm">Tutorials</a></li>
36
+ <li><a href="#" class="footer-link text-gray-400 text-sm">Community</a></li>
37
+ </ul>
38
+ </div>
39
+
40
+ <div>
41
+ <h4 class="font-medium mb-4">Company</h4>
42
+ <ul class="space-y-2">
43
+ <li><a href="#" class="footer-link text-gray-400 text-sm">About</a></li>
44
+ <li><a href="#" class="footer-link text-gray-400 text-sm">Blog</a></li>
45
+ <li><a href="#" class="footer-link text-gray-400 text-sm">Contact</a></li>
46
+ </ul>
47
+ </div>
48
+ </div>
49
+
50
+ <div class="border-t border-gray-800 mt-12 pt-8 flex flex-col md:flex-row justify-between items-center">
51
+ <p class="text-gray-400 text-sm">© 2024 ShadowWeave AI. All rights reserved.</p>
52
+ <div class="flex gap-4 mt-4 md:mt-0">
53
+ <a href="#" class="text-gray-400 hover:text-primary-500">
54
+ <i data-feather="twitter"></i>
55
+ </a>
56
+ <a href="#" class="text-gray-400 hover:text-primary-500">
57
+ <i data-feather="discord"></i>
58
+ </a>
59
+ <a href="#" class="text-gray-400 hover:text-primary-500">
60
+ <i data-feather="github"></i>
61
+ </a>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ </footer>
66
+ `;
67
+ }
68
+ }
69
+
70
+ customElements.define('custom-footer', CustomFooter);
components/navbar.js ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomNavbar extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ nav {
7
+ background-color: rgba(15, 23, 42, 0.8);
8
+ backdrop-filter: blur(10px);
9
+ }
10
+
11
+ .nav-link:hover {
12
+ color: #8b5cf6;
13
+ }
14
+
15
+ .nav-link.active {
16
+ color: #8b5cf6;
17
+ border-bottom: 2px solid #8b5cf6;
18
+ }
19
+ </style>
20
+ <nav class="border-b border-gray-800 sticky top-0 z-50">
21
+ <div class="container mx-auto px-4 py-4 flex justify-between items-center">
22
+ <a href="/" class="flex items-center gap-2">
23
+ <i data-feather="hexagon" class="text-primary-500"></i>
24
+ <span class="text-xl font-bold bg-gradient-to-r from-primary-500 to-purple-400 bg-clip-text text-transparent">ShadowWeave</span>
25
+ </a>
26
+
27
+ <div class="hidden md:flex items-center gap-8">
28
+ <a href="#generate" class="nav-link active">Create</a>
29
+ <a href="#gallery" class="nav-link">Gallery</a>
30
+ <a href="#models" class="nav-link">Models</a>
31
+ <a href="#spells" class="nav-link">Spells</a>
32
+ </div>
33
+
34
+ <div class="flex items-center gap-4">
35
+ <button class="md:hidden">
36
+ <i data-feather="menu"></i>
37
+ </button>
38
+ <a href="#" class="hidden md:block bg-primary-500 hover:bg-primary-600 text-white px-4 py-2 rounded-lg text-sm font-medium transition-all">
39
+ Sign In
40
+ </a>
41
+ </div>
42
+ </div>
43
+ </nav>
44
+ `;
45
+ }
46
+ }
47
+
48
+ customElements.define('custom-navbar', CustomNavbar);
components/toast.js ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomToast extends HTMLElement {
2
+ constructor() {
3
+ super();
4
+ this.attachShadow({ mode: 'open' });
5
+ this.shadowRoot.innerHTML = `
6
+ <style>
7
+ :host {
8
+ position: fixed;
9
+ bottom: 1rem;
10
+ right: 1rem;
11
+ z-index: 1000;
12
+ }
13
+ .toast {
14
+ padding: 0.75rem 1.5rem;
15
+ border-radius: 0.5rem;
16
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
17
+ color: white;
18
+ display: flex;
19
+ align-items: center;
20
+ gap: 0.5rem;
21
+ transition: all 0.3s ease;
22
+ opacity: 0;
23
+ transform: translateY(20px);
24
+ }
25
+ .toast.visible {
26
+ opacity: 1;
27
+ transform: translateY(0);
28
+ }
29
+ .toast.info {
30
+ background-color: #8b5cf6;
31
+ }
32
+ .toast.success {
33
+ background-color: #10b981;
34
+ }
35
+ .toast.warning {
36
+ background-color: #f59e0b;
37
+ }
38
+ .toast.error {
39
+ background-color: #ef4444;
40
+ }
41
+ </style>
42
+ <div class="toast">
43
+ <slot></slot>
44
+ </div>
45
+ `;
46
+ }
47
+
48
+ show(message, type = 'info', duration = 3000) {
49
+ const toast = this.shadowRoot.querySelector('.toast');
50
+ toast.textContent = message;
51
+ toast.className = 'toast ' + type;
52
+ toast.classList.add('visible');
53
+
54
+ setTimeout(() => {
55
+ toast.classList.remove('visible');
56
+ setTimeout(() => this.remove(), 300);
57
+ }, duration);
58
+ }
59
+ }
60
+
61
+ customElements.define('custom-toast', CustomToast);
index.html CHANGED
@@ -1,19 +1,166 @@
1
- <!doctype html>
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
+ <!DOCTYPE html>
2
+ <html lang="en" class="dark">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>ShadowWeave AI | Pixel Alchemy Studio</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ <script>
12
+ tailwind.config = {
13
+ darkMode: 'class',
14
+ theme: {
15
+ extend: {
16
+ colors: {
17
+ primary: {
18
+ 500: '#8b5cf6',
19
+ 600: '#7c3aed',
20
+ },
21
+ secondary: {
22
+ 500: '#1e293b',
23
+ 600: '#0f172a',
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }
29
+ </script>
30
+ </head>
31
+ <body class="bg-secondary-600 text-gray-100 min-h-screen">
32
+ <custom-navbar></custom-navbar>
33
+
34
+ <main class="container mx-auto px-4 py-8">
35
+ <!-- Hero Section -->
36
+ <section class="flex flex-col md:flex-row items-center justify-between gap-8 mb-16">
37
+ <div class="md:w-1/2 space-y-6">
38
+ <h1 class="text-5xl font-bold bg-gradient-to-r from-primary-500 to-purple-400 bg-clip-text text-transparent">
39
+ Weave Your Digital Dreams
40
+ </h1>
41
+ <p class="text-xl text-gray-300">
42
+ Transform ideas into stunning visuals with our AI-powered pixel alchemy. No skills required - just imagination.
43
+ </p>
44
+ <div class="flex gap-4">
45
+ <a href="#generate" class="bg-primary-500 hover:bg-primary-600 text-white px-6 py-3 rounded-lg font-medium transition-all flex items-center gap-2">
46
+ <i data-feather="sparkles"></i> Start Creating
47
+ </a>
48
+ <a href="#gallery" class="border border-primary-500 text-primary-500 hover:bg-primary-500/10 px-6 py-3 rounded-lg font-medium transition-all">
49
+ Explore Gallery
50
+ </a>
51
+ </div>
52
+ </div>
53
+ <div class="md:w-1/2">
54
+ <img src="http://static.photos/technology/1024x576/42" alt="AI Generated Art" class="rounded-xl shadow-2xl border border-gray-700">
55
+ </div>
56
+ </section>
57
+
58
+ <!-- Generation Section -->
59
+ <section id="generate" class="mb-16">
60
+ <h2 class="text-3xl font-bold mb-8 text-center">Pixel Alchemy Studio</h2>
61
+
62
+ <div class="bg-secondary-500 rounded-xl p-6 shadow-lg">
63
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
64
+ <!-- Prompt Input -->
65
+ <div class="lg:col-span-2 space-y-4">
66
+ <div>
67
+ <label class="block text-sm font-medium mb-2">Your Creative Vision</label>
68
+ <textarea class="w-full bg-secondary-600 border border-gray-700 rounded-lg p-4 focus:ring-2 focus:ring-primary-500 focus:border-transparent" rows="4" placeholder="Describe what you want to create..."></textarea>
69
+ </div>
70
+
71
+ <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
72
+ <div>
73
+ <label class="block text-sm font-medium mb-2">Style</label>
74
+ <select class="w-full bg-secondary-600 border border-gray-700 rounded-lg p-2">
75
+ <option>Anime</option>
76
+ <option>Cyberpunk</option>
77
+ <option>3D Render</option>
78
+ <option>Pixel Art</option>
79
+ </select>
80
+ </div>
81
+ <div>
82
+ <label class="block text-sm font-medium mb-2">Model</label>
83
+ <select class="w-full bg-secondary-600 border border-gray-700 rounded-lg p-2">
84
+ <option value="stabilityai/stable-diffusion-xl-base-1.0">Stable Diffusion</option>
85
+ <option value="lykon/dreamshaper-8">DreamShaper</option>
86
+ <option value="cagliostrolab/animagine-xl-3.0">Anime</option>
87
+ <option value="DGSpitzer/Cyberpunk-Anime-Diffusion">Cyberpunk</option>
88
+ </select>
89
+ </div>
90
+ <div>
91
+ <label class="block text-sm font-medium mb-2">Quality</label>
92
+ <select class="w-full bg-secondary-600 border border-gray-700 rounded-lg p-2">
93
+ <option>Standard</option>
94
+ <option>HD</option>
95
+ <option selected>Premium</option>
96
+ </select>
97
+ </div>
98
+ <div>
99
+ <label class="block text-sm font-medium mb-2">Aspect</label>
100
+ <select class="w-full bg-secondary-600 border border-gray-700 rounded-lg p-2">
101
+ <option>Square</option>
102
+ <option>Portrait</option>
103
+ <option>Landscape</option>
104
+ </select>
105
+ </div>
106
+ </div>
107
+ </div>
108
+
109
+ <!-- Preview & Generate -->
110
+ <div class="space-y-4">
111
+ <div class="aspect-square bg-secondary-700 rounded-lg border-2 border-dashed border-gray-600 flex items-center justify-center">
112
+ <div class="text-center p-4">
113
+ <i data-feather="image" class="w-12 h-12 mx-auto text-gray-500 mb-2"></i>
114
+ <p class="text-gray-400">Your creation will appear here</p>
115
+ </div>
116
+ </div>
117
+ <button class="w-full bg-primary-500 hover:bg-primary-600 text-white py-3 rounded-lg font-medium transition-all flex items-center justify-center gap-2">
118
+ <i data-feather="zap"></i> Generate Magic
119
+ </button>
120
+ <div class="text-xs text-gray-400 text-center">
121
+ <p>By generating, you agree to our Terms of Service</p>
122
+ <p class="mt-1">Premium generations: 5 remaining</p>
123
+ </div>
124
+ </div>
125
+ </div>
126
+ </div>
127
+ </section>
128
+
129
+ <!-- Model Showcase -->
130
+ <section class="mb-16">
131
+ <h2 class="text-3xl font-bold mb-8 text-center">Alchemy Models</h2>
132
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
133
+ <div class="bg-secondary-500 rounded-xl overflow-hidden shadow-lg hover:shadow-xl transition-all">
134
+ <img src="http://static.photos/abstract/640x360/1" alt="Dream Model" class="w-full h-48 object-cover">
135
+ <div class="p-4">
136
+ <h3 class="font-bold text-lg mb-2">Dream Weaver</h3>
137
+ <p class="text-gray-300 text-sm">Ethereal beauty with a touch of darkness</p>
138
+ <div class="mt-4 flex justify-between items-center">
139
+ <span class="text-primary-500 font-medium">Free</span>
140
+ <button class="text-xs bg-primary-500/20 text-primary-500 px-3 py-1 rounded-full">Select</button>
141
+ </div>
142
+ </div>
143
+ </div>
144
+ <!-- Repeat similar blocks for other models -->
145
+ </div>
146
+ </section>
147
+
148
+ <!-- Gallery Section -->
149
+ <section id="gallery" class="mb-16">
150
+ <h2 class="text-3xl font-bold mb-8 text-center">Pixel Gallery</h2>
151
+ <div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
152
+ <img src="http://static.photos/abstract/320x240/2" alt="Gallery item" class="rounded-lg hover:scale-105 transition-transform cursor-pointer">
153
+ <!-- Repeat similar img tags for gallery items -->
154
+ </div>
155
+ </section>
156
+ </main>
157
+
158
+ <custom-footer></custom-footer>
159
+ <script src="components/navbar.js"></script>
160
+ <script src="components/footer.js"></script>
161
+ <script src="components/toast.js"></script>
162
+ <script src="script.js"></script>
163
+ <script>feather.replace();</script>
164
+ <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
165
+ </body>
166
+ </html>
script.js ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ // HuggingFace API Configuration
3
+ const HF_API_KEY = 'YOUR_HF_API_KEY';
4
+ const SFW_MODELS = {
5
+ 'Stable Diffusion XL': 'stabilityai/stable-diffusion-xl-base-1.0',
6
+ 'DreamShaper XL': 'lykon/dreamshaper-xl',
7
+ 'Anime XL': 'cagliostrolab/animagine-xl-3.0',
8
+ 'Cyberpunk Anime': 'DGSpitzer/Cyberpunk-Anime-Diffusion',
9
+ 'Realistic Vision': 'SG161222/Realistic_Vision_V5.1',
10
+ 'Juggernaut XL': 'stabilityai/stable-diffusion-xl-base-1.0',
11
+ 'Epic Realism': 'epicrealism/epicrealism-natural-sin',
12
+ 'Pixel Art': 'nerijs/pixel-art-xl'
13
+ };
14
+
15
+ const NSFW_MODELS = {
16
+ 'Erotica XL': 'gsdf/Counterfeit-V3.0',
17
+ 'Hentai XL': 'nitrosocke/henmixReal',
18
+ 'Adult XL': 'gsdf/Erotica',
19
+ 'NSFW Anime': 'cagliostro/hentai-diffusion',
20
+ 'Lewd Realism': 'gsdf/lewd-diffusion',
21
+ 'Boudoir': 'gsdf/boudoir-diffusion',
22
+ 'Kinky Art': 'gsdf/kinky-diffusion'
23
+ };
24
+
25
+ let currentModel = SFW_MODELS['Stable Diffusion XL'];
26
+ let isNSFW = false;
27
+ // DOM Elements
28
+ const promptInput = document.querySelector('textarea');
29
+ const styleSelect = document.querySelector('select:nth-of-type(1)');
30
+ const modelSelect = document.querySelector('select:nth-of-type(2)');
31
+ const generateBtn = document.querySelector('button');
32
+ const previewBox = document.querySelector('.aspect-square');
33
+ const gallerySection = document.getElementById('gallery');
34
+ const nsfwToggle = document.createElement('div');
35
+
36
+ // Initialize NSFW Toggle
37
+ function initNSFWToggle() {
38
+ nsfwToggle.className = 'flex items-center gap-2 mb-4';
39
+ nsfwToggle.innerHTML = `
40
+ <span class="text-sm font-medium">Content Filter</span>
41
+ <label class="relative inline-flex items-center cursor-pointer">
42
+ <input type="checkbox" class="sr-only peer" ${isNSFW ? 'checked' : ''}>
43
+ <div class="w-11 h-6 bg-gray-700 rounded-full peer peer-checked:bg-primary-500 peer-focus:ring-2 peer-focus:ring-primary-500">
44
+ <div class="absolute top-0.5 left-[2px] bg-white w-5 h-5 rounded-full transition-transform peer-checked:translate-x-5"></div>
45
+ </div>
46
+ <span class="ml-2 text-sm">${isNSFW ? 'NSFW' : 'SFW'}</span>
47
+ </label>
48
+ `;
49
+ document.querySelector('#generate .space-y-4').prepend(nsfwToggle);
50
+ nsfwToggle.querySelector('input').addEventListener('change', toggleNSFW);
51
+ }
52
+
53
+ // Toggle NSFW/SFW mode
54
+ function toggleNSFW(e) {
55
+ isNSFW = e.target.checked;
56
+ updateModelOptions();
57
+ nsfwToggle.querySelector('span:last-child').textContent = isNSFW ? 'NSFW' : 'SFW';
58
+ }
59
+
60
+ // Update model options based on SFW/NSFW mode
61
+ function updateModelOptions() {
62
+ modelSelect.innerHTML = '';
63
+ const models = isNSFW ? NSFW_MODELS : SFW_MODELS;
64
+
65
+ for (const [name, modelId] of Object.entries(models)) {
66
+ const option = document.createElement('option');
67
+ option.value = modelId;
68
+ option.textContent = name;
69
+ if (modelId === currentModel) option.selected = true;
70
+ modelSelect.appendChild(option);
71
+ }
72
+ }
73
+ // Enhanced image generation with error handling and model status checks
74
+ async function generateImage() {
75
+ const prompt = promptInput.value.trim();
76
+ if (!prompt) {
77
+ showToast('Please enter a prompt', 'error');
78
+ return;
79
+ }
80
+
81
+ generateBtn.disabled = true;
82
+ generateBtn.innerHTML = '<i data-feather="loader" class="animate-spin"></i> Weaving Pixels...';
83
+ feather.replace();
84
+
85
+ try {
86
+ // First check if model is loaded
87
+ const modelStatus = await fetch(`https://api-inference.huggingface.co/status/${currentModel}`, {
88
+ headers: { 'Authorization': `Bearer ${HF_API_KEY}` }
89
+ });
90
+
91
+ if (!modelStatus.ok) throw new Error('Model status check failed');
92
+
93
+ const statusData = await modelStatus.json();
94
+ if (statusData.loaded !== true) {
95
+ showToast('Model is loading, please wait...', 'warning');
96
+ return;
97
+ }
98
+
99
+ // Generate image
100
+ const response = await fetch(`https://api-inference.huggingface.co/models/${currentModel}`, {
101
+ method: 'POST',
102
+ headers: {
103
+ 'Authorization': `Bearer ${HF_API_KEY}`,
104
+ 'Content-Type': 'application/json'
105
+ },
106
+ body: JSON.stringify({
107
+ inputs: prompt,
108
+ parameters: {
109
+ width: 1024,
110
+ height: 1024,
111
+ num_inference_steps: 50,
112
+ guidance_scale: 7.5
113
+ },
114
+ options: { wait_for_model: true }
115
+ })
116
+ });
117
+
118
+ if (!response.ok) {
119
+ const error = await response.json();
120
+ throw new Error(error.error || 'Generation failed');
121
+ }
122
+
123
+ const imageBlob = await response.blob();
124
+ const imageUrl = URL.createObjectURL(imageBlob);
125
+
126
+ // Update preview
127
+ previewBox.innerHTML = `
128
+ <div class="relative w-full h-full">
129
+ <img src="${imageUrl}" alt="Generated image" class="w-full h-full object-cover rounded-lg">
130
+ <div class="absolute bottom-0 left-0 right-0 bg-black/70 text-white p-2 text-xs">
131
+ ${prompt.substring(0, 100)}${prompt.length > 100 ? '...' : ''}
132
+ </div>
133
+ </div>
134
+ `;
135
+
136
+ // Add to gallery
137
+ addToGallery(imageUrl, prompt);
138
+ showToast('Image generated successfully!', 'success');
139
+
140
+ } catch (error) {
141
+ console.error('Error:', error);
142
+ showToast(error.message || 'Generation failed. Please try again.', 'error');
143
+ } finally {
144
+ generateBtn.disabled = false;
145
+ generateBtn.innerHTML = '<i data-feather="zap"></i> Generate Magic';
146
+ feather.replace();
147
+ }
148
+ }
149
+
150
+ // Show toast notification
151
+ function showToast(message, type = 'info') {
152
+ const toast = document.createElement('div');
153
+ toast.className = `fixed bottom-4 right-4 px-4 py-2 rounded-lg shadow-lg text-white ${
154
+ type === 'error' ? 'bg-red-500' :
155
+ type === 'success' ? 'bg-green-500' :
156
+ type === 'warning' ? 'bg-yellow-500' : 'bg-primary-500'
157
+ }`;
158
+ toast.textContent = message;
159
+ document.body.appendChild(toast);
160
+
161
+ setTimeout(() => {
162
+ toast.classList.add('opacity-0', 'transition-opacity', 'duration-300');
163
+ setTimeout(() => toast.remove(), 300);
164
+ }, 3000);
165
+ }
166
+ // Add generated image to gallery
167
+ function addToGallery(imageUrl, prompt) {
168
+ const galleryItem = document.createElement('div');
169
+ galleryItem.className = 'relative group rounded-lg overflow-hidden';
170
+ galleryItem.innerHTML = `
171
+ <img src="${imageUrl}" alt="${prompt}" class="w-full h-48 object-cover rounded-lg hover:scale-105 transition-transform cursor-pointer">
172
+ <div class="absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center p-4">
173
+ <p class="text-white text-sm text-center">${prompt}</p>
174
+ </div>
175
+ `;
176
+ gallerySection.querySelector('.grid').prepend(galleryItem);
177
+ }
178
+
179
+ // Initialize
180
+ document.addEventListener('DOMContentLoaded', () => {
181
+ initNSFWToggle();
182
+ updateModelOptions();
183
+
184
+ // Event listeners
185
+ generateBtn.addEventListener('click', generateImage);
186
+ modelSelect.addEventListener('change', (e) => {
187
+ currentModel = e.target.value;
188
+ });
189
+
190
+ // Load feather icons
191
+ feather.replace();
192
+ });
style.css CHANGED
@@ -1,28 +1,91 @@
 
 
1
  body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
 
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
 
 
 
 
 
 
 
 
 
 
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
2
+
3
  body {
4
+ font-family: 'Inter', sans-serif;
5
+ }
6
+
7
+ /* Custom scrollbar */
8
+ ::-webkit-scrollbar {
9
+ width: 8px;
10
+ }
11
+
12
+ ::-webkit-scrollbar-track {
13
+ background: #0f172a;
14
+ }
15
+
16
+ ::-webkit-scrollbar-thumb {
17
+ background: #8b5cf6;
18
+ border-radius: 4px;
19
+ }
20
+
21
+ ::-webkit-scrollbar-thumb:hover {
22
+ background: #7c3aed;
23
+ }
24
+ /* Animation for generate button */
25
+ @keyframes pulse {
26
+ 0% {
27
+ box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7);
28
+ }
29
+ 70% {
30
+ box-shadow: 0 0 0 10px rgba(139, 92, 246, 0);
31
+ }
32
+ 100% {
33
+ box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
34
+ }
35
+ }
36
+
37
+ @keyframes spin {
38
+ from { transform: rotate(0deg); }
39
+ to { transform: rotate(360deg); }
40
+ }
41
+
42
+ .animate-pulse {
43
+ animation: pulse 2s infinite;
44
+ }
45
+
46
+ .animate-spin {
47
+ animation: spin 1s linear infinite;
48
+ }
49
+ /* Gallery hover effects */
50
+ .gallery-item {
51
+ transition: all 0.3s ease;
52
  }
53
 
54
+ .gallery-item:hover {
55
+ transform: scale(1.05);
56
+ z-index: 10;
57
  }
58
 
59
+ .gallery-caption {
60
+ transition: opacity 0.3s ease;
 
 
 
61
  }
62
 
63
+ /* Generation preview enhancements */
64
+ .preview-container {
65
+ position: relative;
 
 
 
66
  }
67
 
68
+ .prompt-overlay {
69
+ position: absolute;
70
+ bottom: 0;
71
+ left: 0;
72
+ right: 0;
73
+ background: rgba(0,0,0,0.7);
74
+ color: white;
75
+ padding: 0.5rem;
76
+ font-size: 0.75rem;
77
+ line-height: 1.2;
78
+ border-bottom-left-radius: 0.5rem;
79
+ border-bottom-right-radius: 0.5rem;
80
  }
81
+
82
+ /* Loading state */
83
+ .loading-spinner {
84
+ animation: spin 1s linear infinite;
85
+ }
86
+
87
+ @keyframes spin {
88
+ from { transform: rotate(0deg); }
89
+ to { transform: rotate(360deg); }
90
+ }
91
+