daniil200707 / synapsecraft Goto Github PK
View Code? Open in Web Editor NEWA program that turns pictures into weights and biases for neural networks
A program that turns pictures into weights and biases for neural networks
I upgrade brightness service
Added to code progress box with 0 value
I want to convert pictures changed on my application into weights and biases, but it gives an error:
[ WARN:[email protected]] global loadsave.cpp:248 cv::findDecoder imread_('C:/Users/Валюша/Downloads/udyqmktvm3.png'): can't open/read file: check file path/integrity
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Валюша\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 1948, in __call__
return self.func(*args)
^^^^^^^^^^^^^^^^
File "C:\Users\Валюша\PycharmProject\SynapseCraft\SynapseCraft.py", line 118, in <lambda>
generate_button = Button(root, text="Генерувати", command=lambda: naming(name_entry, load_canvas, out_dim_entry,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Валюша\PycharmProject\SynapseCraft\SynapseCraft.py", line 152, in naming
learning(out_dim.get(), h_dim.get(), alpha.get(), num_epochs.get(), batch_size.get(), name_path,
File "C:\Users\Валюша\PycharmProject\SynapseCraft\learning_images.py", line 27, in learning
img = cv2.resize(img, (200, 100))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.9.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
Here's my cod:
from data import *
import cv2
import time
from pathlib import Path
from shutil import rmtree
import csv
import Learning as Lg
def learning(out_dim, h_dim, alpha, num_epochs, batch_size, file_name="resource/csv/new_data.csv", progress_bar=None):
for path in Path('resource/images').glob('*'):
if path.is_dir():
rmtree(path)
else:
path.unlink()
i = 0
path_dict = {}
for element in y_dict.items():
percent = 25
expected_value = percent / len(element[1])
i += expected_value
path_list = []
for filename in element[1]:
img = cv2.imread(filename)
img = cv2.resize(img, (200, 100))
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
img = cv2.Canny(img, 90, 90)
file_path = f"resource/images/{time.time()}.png"
cv2.imwrite(file_path, img)
path_list.append(file_path)
if progress_bar:
progress_bar.configure(value=i)
progress_bar.update()
time.sleep(1)
path_dict[element[0]] = path_list
binary_list, data_counter = create_bin_list(path_dict, i, progress_bar)
with open(file_name, "w", newline="") as file:
writer = csv.writer(file)
writer.writerow(["x", "y"])
counter2 = write_csv(file_name, progress_bar, binary_list, data_counter)
Lg.new_learn(int(out_dim), int(h_dim), float(alpha), int(num_epochs), int(batch_size), progress_bar, counter2,
file_name)
def upload_images(new_list, image_listbox):
"""
New list export to filename. File name insert to image listbox
:param new_list: export to file name
:param image_listbox: import file name
:return: None
"""
for filename in new_list:
image_listbox.insert(END, filename)
def write_csv(csv_name: str, csv_progress_bar, data: dict, count2: int):
for element in data.items():
data_percent = 25
data_value = data_percent / len(data)
count2 += data_value
for float_number in element[1]:
data_row = [float_number, element[0][1:]]
with open(csv_name, "a", newline="") as data_file:
csv_writer = csv.writer(data_file)
csv_writer.writerow(data_row)
if csv_progress_bar:
csv_progress_bar.configure(value=count2)
csv_progress_bar.update()
return count2
if __name__ == "__main__":
upload_images('0', Listbox())
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.