Kornel: added neural web
1
.idea/.name
Normal file
@ -0,0 +1 @@
|
||||
main.py
|
@ -2,7 +2,7 @@
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
1
TSP.py
@ -81,6 +81,7 @@ def tsp(x, y):
|
||||
|
||||
if solution:
|
||||
sol = print_solution(manager, routing, solution)
|
||||
|
||||
return sol
|
||||
|
||||
def tspmove(order, truck, Ltrash):
|
||||
|
BIN
__pycache__/TSP.cpython-37.pyc
Normal file
BIN
__pycache__/TSP.cpython-38.pyc
Normal file
BIN
__pycache__/bfs.cpython-37.pyc
Normal file
BIN
__pycache__/bfs.cpython-38.pyc
Normal file
BIN
__pycache__/colors.cpython-37.pyc
Normal file
BIN
__pycache__/colors.cpython-38.pyc
Normal file
BIN
__pycache__/house.cpython-37.pyc
Normal file
BIN
__pycache__/house.cpython-38.pyc
Normal file
BIN
__pycache__/trash.cpython-37.pyc
Normal file
BIN
__pycache__/trash.cpython-38.pyc
Normal file
BIN
__pycache__/truck.cpython-37.pyc
Normal file
BIN
__pycache__/truck.cpython-38.pyc
Normal file
1
bfs.py
@ -57,6 +57,7 @@ def bfs(pos, direction, end_pos, houses):
|
||||
neighbour_node = Node(n_pos, n_direction, curr_node, action)
|
||||
if neighbour_node not in visited and neighbour_node not in queue:
|
||||
queue.append(neighbour_node)
|
||||
|
||||
return actions
|
||||
|
||||
def distance(pos, endpos):
|
||||
|
75
catOrNotTest/catOrNotTest.py
Normal file
@ -0,0 +1,75 @@
|
||||
|
||||
from keras.models import Sequential
|
||||
from keras.layers import Dense, Dropout, Flatten
|
||||
from keras.layers import Conv2D, MaxPooling2D
|
||||
from keras.layers.normalization import BatchNormalization
|
||||
from PIL import Image
|
||||
from random import shuffle, choice
|
||||
import numpy as np
|
||||
import os
|
||||
|
||||
IMAGE_SIZE = 256
|
||||
IMAGE_DIRECTORY = './data/training_set'
|
||||
|
||||
def label_img(name):
|
||||
if name == 'cats': return np.array([1, 0])
|
||||
elif name == 'notcats' : return np.array([0, 1])
|
||||
|
||||
|
||||
def load_data():
|
||||
print("Loading images...")
|
||||
train_data = []
|
||||
directories = next(os.walk(IMAGE_DIRECTORY))[1]
|
||||
|
||||
for dirname in directories:
|
||||
print("Loading {0}".format(dirname))
|
||||
file_names = next(os.walk(os.path.join(IMAGE_DIRECTORY, dirname)))[2]
|
||||
for i in range(200):
|
||||
image_name = choice(file_names)
|
||||
image_path = os.path.join(IMAGE_DIRECTORY, dirname, image_name)
|
||||
label = label_img(dirname)
|
||||
if "DS_Store" not in image_path:
|
||||
img = Image.open(image_path)
|
||||
img = img.convert('L')
|
||||
img = img.resize((IMAGE_SIZE, IMAGE_SIZE), Image.ANTIALIAS)
|
||||
train_data.append([np.array(img), label])
|
||||
|
||||
return train_data
|
||||
|
||||
def create_model():
|
||||
model = Sequential()
|
||||
model.add(Conv2D(32, kernel_size = (3, 3), activation='relu', input_shape=(IMAGE_SIZE, IMAGE_SIZE, 1)))
|
||||
model.add(MaxPooling2D(pool_size=(2,2)))
|
||||
model.add(BatchNormalization())
|
||||
model.add(Conv2D(64, kernel_size=(3,3), activation='relu'))
|
||||
model.add(MaxPooling2D(pool_size=(2,2)))
|
||||
model.add(BatchNormalization())
|
||||
model.add(Conv2D(128, kernel_size=(3,3), activation='relu'))
|
||||
model.add(MaxPooling2D(pool_size=(2,2)))
|
||||
model.add(BatchNormalization())
|
||||
model.add(Conv2D(256, kernel_size=(3,3), activation='relu'))
|
||||
model.add(MaxPooling2D(pool_size=(2,2)))
|
||||
model.add(BatchNormalization())
|
||||
model.add(Conv2D(64, kernel_size=(3,3), activation='relu'))
|
||||
model.add(MaxPooling2D(pool_size=(2,2)))
|
||||
model.add(BatchNormalization())
|
||||
model.add(Dropout(0.2))
|
||||
model.add(Flatten())
|
||||
model.add(Dense(256, activation='relu'))
|
||||
model.add(Dropout(0.2))
|
||||
model.add(Dense(128, activation='relu'))
|
||||
model.add(Dense(2, activation = 'softmax'))
|
||||
|
||||
return model
|
||||
|
||||
|
||||
training_data = load_data()
|
||||
training_images = np.array([i[0] for i in training_data]).reshape(-1, IMAGE_SIZE, IMAGE_SIZE, 1)
|
||||
training_labels = np.array([i[1] for i in training_data])
|
||||
|
||||
print('creating model')
|
||||
model = create_model()
|
||||
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
|
||||
print('training model')
|
||||
model.fit(training_images, training_labels, batch_size=50, epochs=10, verbose=1)
|
||||
model.save("model2.h5")
|
65
catOrNotTest/catOrNotTest.pyproj
Normal file
@ -0,0 +1,65 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>909f8871-bfd4-48ea-bee8-31c07b881648</ProjectGuid>
|
||||
<ProjectHome>.</ProjectHome>
|
||||
<StartupFile>catOrNotTest.py</StartupFile>
|
||||
<SearchPath>
|
||||
</SearchPath>
|
||||
<WorkingDirectory>.</WorkingDirectory>
|
||||
<OutputPath>.</OutputPath>
|
||||
<Name>catOrNotTest</Name>
|
||||
<RootNamespace>catOrNotTest</RootNamespace>
|
||||
<InterpreterId>MSBuild|env2|$(MSBuildProjectFullPath)</InterpreterId>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="catOrNotTest.py" />
|
||||
<Compile Include="kopiamain.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="retrain.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="test.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Interpreter Include="env2\">
|
||||
<Id>env2</Id>
|
||||
<Version>3.7</Version>
|
||||
<Description>env2 (Python 3.7 (64-bit))</Description>
|
||||
<InterpreterPath>Scripts\python.exe</InterpreterPath>
|
||||
<WindowsInterpreterPath>Scripts\pythonw.exe</WindowsInterpreterPath>
|
||||
<PathEnvironmentVariable>PYTHONPATH</PathEnvironmentVariable>
|
||||
<Architecture>X64</Architecture>
|
||||
</Interpreter>
|
||||
<Interpreter Include="env\">
|
||||
<Id>env</Id>
|
||||
<Version>3.7</Version>
|
||||
<Description>env (Python 3.7 (64-bit))</Description>
|
||||
<InterpreterPath>Scripts\python.exe</InterpreterPath>
|
||||
<WindowsInterpreterPath>Scripts\pythonw.exe</WindowsInterpreterPath>
|
||||
<PathEnvironmentVariable>PYTHONPATH</PathEnvironmentVariable>
|
||||
<Architecture>X64</Architecture>
|
||||
</Interpreter>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
||||
<!-- Uncomment the CoreCompile target to enable the Build command in
|
||||
Visual Studio and specify your pre- and post-build commands in
|
||||
the BeforeBuild and AfterBuild targets below. -->
|
||||
<!--<Target Name="CoreCompile" />-->
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
</Project>
|
BIN
catOrNotTest/data/test_set/.DS_Store
vendored
Normal file
BIN
catOrNotTest/data/test_set/cats/.DS_Store
vendored
Normal file
BIN
catOrNotTest/data/test_set/cats/cat.4001.jpg
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4002.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4003.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4004.jpg
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4005.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4006.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4007.jpg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4008.jpg
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4009.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4010.jpg
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4011.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4012.jpg
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4013.jpg
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4014.jpg
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4015.jpg
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4016.jpg
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4017.jpg
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4018.jpg
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4019.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4020.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4021.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4022.jpg
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4023.jpg
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4024.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4025.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4026.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4027.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4028.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4029.jpg
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4030.jpg
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4031.jpg
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4032.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4033.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4034.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4035.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4036.jpg
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4037.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4038.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4039.jpg
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4040.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4041.jpg
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4042.jpg
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4043.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4044.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4045.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4046.jpg
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4047.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4048.jpg
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4049.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4050.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4051.jpg
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4052.jpg
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4053.jpg
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4054.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4055.jpg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4056.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4057.jpg
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4058.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4059.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4060.jpg
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4061.jpg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4062.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4063.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4064.jpg
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4065.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4066.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4067.jpg
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4068.jpg
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4069.jpg
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4070.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4071.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4072.jpg
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4073.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
catOrNotTest/data/test_set/cats/cat.4074.jpg
Normal file
After Width: | Height: | Size: 14 KiB |