Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,9 +6,12 @@ from keras.models import Model
|
|
6 |
import matplotlib.pyplot as plt
|
7 |
import logging
|
8 |
from skimage.transform import resize
|
9 |
-
from PIL import Image, ImageEnhance
|
10 |
from tqdm import tqdm
|
11 |
|
|
|
|
|
|
|
12 |
class SwarmAgent:
|
13 |
def __init__(self, position, velocity):
|
14 |
self.position = position
|
@@ -102,6 +105,12 @@ class SwarmNeuralNetwork:
|
|
102 |
# Normalize to [0, 1] range for display
|
103 |
self.generated_image = (self.generated_image + 1) / 2
|
104 |
self.generated_image = np.clip(self.generated_image, 0, 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
def train(self, epochs):
|
107 |
logging.basicConfig(filename='training.log', level=logging.INFO)
|
|
|
6 |
import matplotlib.pyplot as plt
|
7 |
import logging
|
8 |
from skimage.transform import resize
|
9 |
+
from PIL import Image, ImageEnhance, ImageFilter
|
10 |
from tqdm import tqdm
|
11 |
|
12 |
+
# Ensure TensorFlow runs on CPU
|
13 |
+
tf.config.set_visible_devices([], 'GPU')
|
14 |
+
|
15 |
class SwarmAgent:
|
16 |
def __init__(self, position, velocity):
|
17 |
self.position = position
|
|
|
105 |
# Normalize to [0, 1] range for display
|
106 |
self.generated_image = (self.generated_image + 1) / 2
|
107 |
self.generated_image = np.clip(self.generated_image, 0, 1)
|
108 |
+
|
109 |
+
# Apply sharpening filter
|
110 |
+
image_pil = Image.fromarray((self.generated_image * 255).astype(np.uint8))
|
111 |
+
image_pil = image_pil.filter(ImageFilter.SHARPEN)
|
112 |
+
image_pil = image_pil.filter(ImageFilter.DETAIL)
|
113 |
+
self.generated_image = np.array(image_pil) / 255.0
|
114 |
|
115 |
def train(self, epochs):
|
116 |
logging.basicConfig(filename='training.log', level=logging.INFO)
|