Giter Club home page Giter Club logo

synapsecraft's People

Contributors

daniil200707 avatar

Watchers

 avatar  avatar

synapsecraft's Issues

Progress Box

I upgrade progress box

Added to code progress box with 0 value

CV2_ERROR

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())

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.