This repository contains a neural network that generates and adjusts images based on color activations. The application combines computer vision, deep learning, and GUI elements to provide an interactive environment for image processing.
multiprocessing
.Make sure you have the following installed:
customtkinter
Pillow
torch
numpy
opencv-python
Install dependencies using:
pip install customtkinter pillow torch numpy opencv-python
python main.py
File > Load Image
and select an image.File > Generate Image
.kunst.png
.Each node represents a color (e.g., red, green, blue). Activations are based on color brightness and influence image processing.
class Node: def __init__(self, label): self.label = label self.connections = [] self.activation = 0.0 def add_connection(self, target_node, weight=None): self.connections.append(Connection(target_node, weight)) def propagate_signal(self, input_signal): self.activation = max(0, input_signal) # ReLU activation for connection in self.connections: connection.target_node.activation += self.activation * connection.weight
def extract_main_colors(image): image_array = np.array(image) colors = {} for i in range(image_array.shape[0]): for j in range(image_array.shape[1]): color = tuple(image_array[i, j]) if sum(color) > 30: # Ignore very dark colors colors[color] = colors.get(color, 0) + 1 sorted_colors = sorted(colors.items(), key=lambda item: item[1], reverse=True) return [color for color, _ in sorted_colors[:6]] # Top 6 colors
https://github.com/kruemmel-python/Neural-Network-Image-Generator/blob/main/analyse/bild4.jpg
def process_chunk(args): image_tensor, start_row, chunk_size, category_nodes, brightness_factor, contrast_factor = args modified_chunk = image_tensor[:, start_row:start_row + chunk_size, :].clone() for x in range(modified_chunk.shape[1]): for y in range(modified_chunk.shape[2]): pixel = modified_chunk[:, x, y] brightness = float(brightness_factor) contrast = float(contrast_factor) for node in category_nodes: brightness += node.activation * 0.1 contrast += node.activation * 0.1 pixel = torch.clamp((pixel - 0.5) * contrast + 0.5 + brightness, 0, 1) modified_chunk[:, x, y] = pixel return start_row, modified_chunk
This project is licensed under the MIT License. See LICENSE for details.
Developed by [Ralf Krümmel].
There are no models linked
There are no models linked