Andre commited on
Commit
6420441
·
1 Parent(s): 5496988

“Update”

Browse files
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
index_old.php → gallery_content.php RENAMED
@@ -1,22 +1,3 @@
1
- <?php
2
- // Function to get supported image files
3
- function getImages($directory) {
4
- $allowedTypes = array('jpg', 'jpeg', 'png', 'gif');
5
- $files = array();
6
-
7
- if (is_dir($directory)) {
8
- $dirContent = scandir($directory);
9
- foreach ($dirContent as $file) {
10
- $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
11
- if (in_array($extension, $allowedTypes)) {
12
- $files[] = $file;
13
- }
14
- }
15
- }
16
- return $files;
17
- }
18
- ?>
19
-
20
  <!DOCTYPE html>
21
  <html lang="en">
22
  <head>
@@ -132,8 +113,8 @@ function getImages($directory) {
132
  <div class="gallery">
133
  <?php
134
  // Specify your images directory
135
- $imageDirectory = 'images/';
136
- $images = getImages($imageDirectory);
137
 
138
  foreach ($images as $image) {
139
  echo '<div class="gallery-item" onclick="openLightbox(\'' . $imageDirectory . $image . '\')">';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
 
113
  <div class="gallery">
114
  <?php
115
  // Specify your images directory
116
+ //$imageDirectory = 'images/';
117
+ //$images = getImages($imageDirectory);
118
 
119
  foreach ($images as $image) {
120
  echo '<div class="gallery-item" onclick="openLightbox(\'' . $imageDirectory . $image . '\')">';
gallery_functions.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function getImages($directory, $imageOrder = 'desc') {
4
+ $allowedTypes = array('jpg', 'jpeg', 'png', 'gif');
5
+ $files = array();
6
+
7
+ if (is_dir($directory)) {
8
+ $dirContent = scandir($directory);
9
+ foreach ($dirContent as $file) {
10
+ $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
11
+ if (in_array($extension, $allowedTypes)) {
12
+ $files[] = $file;
13
+ }
14
+ }
15
+
16
+ // Use strtolower for case-insensitive comparison
17
+ $order = strtolower($imageOrder); // Normalize the input
18
+
19
+ if ($order == 'desc') {
20
+ rsort($files);
21
+ } elseif ($order == 'asc') {
22
+ sort($files);
23
+ } // Add other sorting options if needed
24
+ }
25
+ return $files;
26
+ }
27
+
28
+ ?>
index.php CHANGED
@@ -1,190 +1,8 @@
1
  <?php
2
- // Function to get supported image files
3
- function getImages($directory) {
4
- $allowedTypes = array('jpg', 'jpeg', 'png', 'gif');
5
- $files = array();
6
-
7
- if (is_dir($directory)) {
8
- $dirContent = scandir($directory);
9
- foreach ($dirContent as $file) {
10
- $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
11
- if (in_array($extension, $allowedTypes)) {
12
- $files[] = $file;
13
- }
14
- }
15
- // Sort files in reverse order
16
- rsort($files);
17
- }
18
- return $files;
19
- }
20
- ?>
21
-
22
- <!DOCTYPE html>
23
- <html lang="en">
24
- <head>
25
- <meta charset="UTF-8">
26
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
27
- <title>Dark Theme Image Gallery</title>
28
- <style>
29
- body {
30
- background-color: #1a1a1a;
31
- color: #ffffff;
32
- font-family: Arial, sans-serif;
33
- margin: 0;
34
- padding: 20px;
35
- }
36
-
37
- .gallery-container {
38
- max-width: 1200px;
39
- margin: 0 auto;
40
- }
41
-
42
- h1 {
43
- text-align: center;
44
- color: #ffffff;
45
- margin-bottom: 30px;
46
- }
47
-
48
- .gallery {
49
- display: grid;
50
- grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
51
- gap: 20px;
52
- padding: 20px;
53
- }
54
-
55
- .gallery-item {
56
- position: relative;
57
- overflow: hidden;
58
- border-radius: 8px;
59
- background-color: #2d2d2d;
60
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
61
- transition: transform 0.3s ease;
62
- cursor: pointer;
63
- }
64
-
65
- .gallery-item:hover {
66
- transform: scale(1.02);
67
- }
68
-
69
- .gallery-item img {
70
- width: 100%;
71
- height: 200px;
72
- object-fit: cover;
73
- display: block;
74
- }
75
-
76
- .image-caption {
77
- padding: 10px;
78
- background-color: rgba(0, 0, 0, 0.7);
79
- color: #ffffff;
80
- font-size: 0.9em;
81
- text-align: center;
82
- }
83
-
84
- /* Lightbox styles */
85
- .lightbox {
86
- display: none;
87
- position: fixed;
88
- top: 0;
89
- left: 0;
90
- width: 100%;
91
- height: 100%;
92
- background-color: rgba(0, 0, 0, 0.9);
93
- z-index: 1000;
94
- justify-content: center;
95
- align-items: center;
96
- cursor: pointer;
97
- }
98
-
99
- .lightbox.active {
100
- display: flex;
101
- }
102
 
103
- .lightbox img {
104
- max-width: 90%;
105
- max-height: 90vh;
106
- object-fit: contain;
107
- border: 2px solid #ffffff;
108
- box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
109
- }
110
-
111
- .close-button {
112
- position: fixed;
113
- top: 20px;
114
- right: 20px;
115
- color: #ffffff;
116
- font-size: 30px;
117
- cursor: pointer;
118
- background: none;
119
- border: none;
120
- padding: 10px;
121
- z-index: 1001;
122
- }
123
-
124
- @media (max-width: 768px) {
125
- .gallery {
126
- grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
127
- }
128
- }
129
- </style>
130
- </head>
131
- <body>
132
- <div class="gallery-container">
133
- <h1>========== LS-AI-img-gen - Image Gallery ==========</h1>
134
- <div class="gallery">
135
- <?php
136
- // Specify your images directory
137
- $imageDirectory = 'images/';
138
- $images = getImages($imageDirectory);
139
-
140
- foreach ($images as $image) {
141
- echo '<div class="gallery-item" onclick="openLightbox(\'' . $imageDirectory . $image . '\')">';
142
- echo '<img src="' . $imageDirectory . $image . '" alt="' . pathinfo($image, PATHINFO_FILENAME) . '">';
143
- echo '<div class="image-caption">' . pathinfo($image, PATHINFO_FILENAME) . '</div>';
144
- echo '</div>';
145
- }
146
-
147
- if (empty($images)) {
148
- echo '<p style="text-align: center; grid-column: 1/-1;">No images found in the gallery.</p>';
149
- }
150
- ?>
151
- </div>
152
- </div>
153
-
154
- <!-- Lightbox container -->
155
- <div class="lightbox" id="lightbox" onclick="closeLightbox()">
156
- <button class="close-button" onclick="closeLightbox()">&times;</button>
157
- <img id="lightbox-img" src="" alt="Lightbox image">
158
- </div>
159
-
160
- <script>
161
- function openLightbox(imageSrc) {
162
- const lightbox = document.getElementById('lightbox');
163
- const lightboxImg = document.getElementById('lightbox-img');
164
- lightboxImg.src = imageSrc;
165
- lightbox.classList.add('active');
166
- // Prevent scrolling when lightbox is open
167
- document.body.style.overflow = 'hidden';
168
- }
169
-
170
- function closeLightbox() {
171
- const lightbox = document.getElementById('lightbox');
172
- lightbox.classList.remove('active');
173
- // Restore scrolling
174
- document.body.style.overflow = 'auto';
175
- }
176
-
177
- // Close lightbox with Escape key
178
- document.addEventListener('keydown', function(event) {
179
- if (event.key === 'Escape') {
180
- closeLightbox();
181
- }
182
- });
183
-
184
- // Prevent lightbox from closing when clicking on the image
185
- document.getElementById('lightbox-img').addEventListener('click', function(event) {
186
- event.stopPropagation();
187
- });
188
- </script>
189
- </body>
190
- </html>
 
1
  <?php
2
+ include 'functions.php';
3
+ $imageDirectory = 'images/';
4
+ $imageOrder = 'desc';
5
+ $images = getImages($imageDirectory, $imageOrder); // 'asc' or 'desc'
6
+ include 'gallery_content.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
index_asc.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include 'gallery_functions.php';
3
+ $imageDirectory = 'images/';
4
+ $imageOrder = 'asc';
5
+ $images = getImages($imageDirectory, $imageOrder); // 'asc' or 'desc'
6
+ include 'gallery_content.php';
7
+
8
+ ?>
src/img_gen copy.py DELETED
@@ -1,96 +0,0 @@
1
- # img_gen.py
2
- import sys
3
- import os
4
- import random
5
- from huggingface_hub import InferenceClient, login
6
- from datetime import datetime
7
- from config.config import models, prompts, api_token # Direct import
8
-
9
- def generate_image(
10
- prompt_alias,
11
- custom_prompt,
12
- characer_dropdown,
13
- model_alias,
14
- height=360,
15
- width=640,
16
- num_inference_steps=20,
17
- guidance_scale=2.0,
18
- seed=-1):
19
- # Find the selected prompt and model
20
- try:
21
- prompt = next(p for p in prompts if p["alias"] == prompt_alias)["text"]
22
- model_name = next(m for m in models if m["alias"] == model_alias)["name"]
23
-
24
- except StopIteration:
25
- return None, "ERROR: Invalid prompt or model selected."
26
-
27
- # Print the original prompt and dynamic values for debugging
28
- print("Original Prompt:")
29
- print(prompt)
30
-
31
- # Append the custom character (if provided)
32
- if characer_dropdown == "Wizard":
33
- prompt += " A wizard dressed in tunic figths against the beast"
34
- elif characer_dropdown == "Warrior":
35
- prompt += " A medieval warrior in armor figths against the beast"
36
- else:
37
- pass
38
-
39
- # Append the custom prompt (if provided)
40
- if custom_prompt and len(custom_prompt.strip()) > 0:
41
- prompt += " " + custom_prompt.strip()
42
-
43
- # Print the formatted prompt for debugging
44
- print("\nFormatted Prompt:")
45
- print(prompt)
46
-
47
- # Randomize the seed if needed
48
- if seed == -1:
49
- seed = random.randint(0, 1000000)
50
-
51
- # HF LOGIN
52
- print("Initializing HF TOKEN")
53
- print (api_token)
54
- # login(token=api_token)
55
- # print("model_name:")
56
- # print(model_name)
57
-
58
-
59
- # Initialize the InferenceClient
60
- try:
61
- print("-----INITIALIZING INFERENCE-----")
62
- client = InferenceClient(model_name, token=api_token)
63
- print("Inference activated")
64
- except Exception as e:
65
- return None, f"ERROR: Failed to initialize InferenceClient. Details: {e}"
66
-
67
- #Generate the image
68
- try:
69
- print("-----GENERATING IMAGE-----")
70
- print("-----HOLD ON-----")
71
- image = client.text_to_image(
72
- prompt,
73
- guidance_scale=guidance_scale,
74
- num_inference_steps=num_inference_steps,
75
- width=width,
76
- height=height,
77
- seed=seed
78
- )
79
- print("-----IMAGE GENERATED SUCCESSFULLY!-----")
80
- except Exception as e:
81
- return None, f"ERROR: Failed to generate image. Details: {e}"
82
-
83
- # Save the image with a timestamped filename
84
- print("-----SAVING-----", image)
85
- path = "images"
86
-
87
- timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
88
- output_filename = f"{path}/{timestamp}_{model_alias.replace(' ', '_').lower()}_{prompt_alias.replace(' ', '_').lower()}_{characer_dropdown.replace(' ', '_').lower()}.png"
89
- try:
90
- image.save(output_filename)
91
- except Exception as e:
92
- return None, f"ERROR: Failed to save image. Details: {e}"
93
- print("-----DONE!-----")
94
- print("-----CALL THE BANNERS!-----")
95
-
96
- return output_filename, "Image generated successfully!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/img_gen.py CHANGED
@@ -30,9 +30,9 @@ def generate_image(
30
 
31
  # Append the custom character (if provided)
32
  if characer_dropdown == "Wizard":
33
- prompt += f" A wizard figths against the {prompt_alias}"
34
  elif characer_dropdown == "Warrior":
35
- prompt += f" A warrior figths against the {prompt_alias}"
36
  else:
37
  pass
38
 
 
30
 
31
  # Append the custom character (if provided)
32
  if characer_dropdown == "Wizard":
33
+ prompt += f" A human wizard combat against the {prompt_alias}"
34
  elif characer_dropdown == "Warrior":
35
+ prompt += f" A human warrior figths against the {prompt_alias}"
36
  else:
37
  pass
38