Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
cbed5f176b | ||
|
827a105f17 | ||
|
89d1aa7802 | ||
|
80e6c700cb | ||
|
cdf155d8ca | ||
|
d0f80d2072 | ||
|
0d0b1c6d43 | ||
|
3bfa94344b | ||
|
1302fdaaf6 | ||
|
66dfb94548 | ||
|
40b2b178f3 | ||
|
5289c48fe2 | ||
|
15757a16a1 | ||
|
cabc8b2a75 | ||
4372b2edfc | |||
c27c678270 | |||
7d0416f130 | |||
5399d5309c | |||
|
f79a2d91d9 |
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
1
.idea/.name
Normal file
@ -0,0 +1 @@
|
||||
astar.py
|
8
.idea/SI_projekt_smieciarka.iml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
29
.idea/inspectionProfiles/Project_Default.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<value>
|
||||
<list size="16">
|
||||
<item index="0" class="java.lang.String" itemvalue="scipy" />
|
||||
<item index="1" class="java.lang.String" itemvalue="pygame" />
|
||||
<item index="2" class="java.lang.String" itemvalue="opencv-python" />
|
||||
<item index="3" class="java.lang.String" itemvalue="scikit-learn" />
|
||||
<item index="4" class="java.lang.String" itemvalue="h5py" />
|
||||
<item index="5" class="java.lang.String" itemvalue="kiwisolver" />
|
||||
<item index="6" class="java.lang.String" itemvalue="torch" />
|
||||
<item index="7" class="java.lang.String" itemvalue="numpy" />
|
||||
<item index="8" class="java.lang.String" itemvalue="torchvision" />
|
||||
<item index="9" class="java.lang.String" itemvalue="mahotas" />
|
||||
<item index="10" class="java.lang.String" itemvalue="tensorflow" />
|
||||
<item index="11" class="java.lang.String" itemvalue="PyQt5" />
|
||||
<item index="12" class="java.lang.String" itemvalue="matplotlib" />
|
||||
<item index="13" class="java.lang.String" itemvalue="grpcio" />
|
||||
<item index="14" class="java.lang.String" itemvalue="sip" />
|
||||
<item index="15" class="java.lang.String" itemvalue="Pillow" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
4
.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
||||
</project>
|
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/SI_projekt_smieciarka.iml" filepath="$PROJECT_DIR$/.idea/SI_projekt_smieciarka.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
115
TSP.py
Normal file
@ -0,0 +1,115 @@
|
||||
|
||||
from ortools.constraint_solver import routing_enums_pb2
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
from bfs import distance, bfs
|
||||
from house import create_houses
|
||||
|
||||
|
||||
def create_data_model(multi_trash, truck):
|
||||
data = {}
|
||||
graphrow = []
|
||||
graph = []
|
||||
lista = multi_trash
|
||||
for i in range(8):
|
||||
list1=multi_trash
|
||||
if (i == 0):
|
||||
pos = truck.pos
|
||||
else:
|
||||
pos = lista[i-1].pos
|
||||
for j in range(8):
|
||||
if(j==0):
|
||||
endpos = truck.pos
|
||||
else:
|
||||
endpos = list1[j-1].pos
|
||||
if(i==j):
|
||||
graphrow.append(0)
|
||||
else:
|
||||
dist=distance(pos, endpos)
|
||||
graphrow.append(dist)
|
||||
|
||||
graph.append(graphrow.copy())
|
||||
graphrow.clear()
|
||||
data['distance_matrix'] = graph.copy()
|
||||
data['num_vehicles'] = 1
|
||||
data['depot'] = 0
|
||||
print(data['distance_matrix'])
|
||||
return data
|
||||
|
||||
|
||||
def print_solution(manager, routing, solution):
|
||||
index = routing.Start(0)
|
||||
plan_output = []
|
||||
route_distance = 0
|
||||
while not routing.IsEnd(index):
|
||||
plan_output.append(manager.IndexToNode(index))
|
||||
previous_index = index
|
||||
index = solution.Value(routing.NextVar(index))
|
||||
route_distance += routing.GetArcCostForVehicle(previous_index, index, 0)
|
||||
plan_output.append(manager.IndexToNode(index))
|
||||
print(plan_output)
|
||||
return plan_output
|
||||
|
||||
|
||||
def tsp(x, y):
|
||||
data = create_data_model(x, y)
|
||||
|
||||
manager = pywrapcp.RoutingIndexManager(len(data['distance_matrix']),
|
||||
data['num_vehicles'], data['depot'])
|
||||
|
||||
routing = pywrapcp.RoutingModel(manager)
|
||||
|
||||
|
||||
def distance_callback(from_index, to_index):
|
||||
from_node = manager.IndexToNode(from_index)
|
||||
to_node = manager.IndexToNode(to_index)
|
||||
return data['distance_matrix'][from_node][to_node]
|
||||
|
||||
transit_callback_index = routing.RegisterTransitCallback(distance_callback)
|
||||
|
||||
routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)
|
||||
|
||||
#search_parameters = pywrapcp.DefaultRoutingSearchParameters()
|
||||
# search_parameters.first_solution_strategy = (
|
||||
# routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)
|
||||
search_parameters = pywrapcp.DefaultRoutingSearchParameters()
|
||||
search_parameters.local_search_metaheuristic = (
|
||||
routing_enums_pb2.LocalSearchMetaheuristic.GUIDED_LOCAL_SEARCH)
|
||||
search_parameters.time_limit.seconds = 30
|
||||
search_parameters.log_search = True
|
||||
|
||||
solution = routing.SolveWithParameters(search_parameters)
|
||||
|
||||
if solution:
|
||||
sol = print_solution(manager, routing, solution)
|
||||
|
||||
return sol
|
||||
|
||||
def tspmove(order, truck, Ltrash):
|
||||
houses = create_houses(40)
|
||||
path = []
|
||||
endpos=truck.pos
|
||||
for i in range(1, 8):
|
||||
startpos = endpos
|
||||
endpos = Ltrash[order[i]-1].pos
|
||||
#print(i,startpos,endpos)
|
||||
x = bfs(startpos, truck.dir_control, endpos, houses)
|
||||
#print("$$$$",x)
|
||||
for i in x:
|
||||
if(i==97):
|
||||
truck.rotate(-1)
|
||||
elif(i==100):
|
||||
truck.rotate(1)
|
||||
path.append(x)
|
||||
x = bfs(endpos, truck.dir_control, truck.pos, houses)
|
||||
for i in x:
|
||||
if (i == 97):
|
||||
truck.rotate(-1)
|
||||
elif (i == 100):
|
||||
truck.rotate(1)
|
||||
path.append(x)
|
||||
#print("###############################\n", path)
|
||||
truck.dir_control=0
|
||||
truck.direction = [1, 0]
|
||||
return path
|
||||
|
||||
|
BIN
__pycache__/TSP.cpython-37.pyc
Normal file
BIN
__pycache__/TSP.cpython-38.pyc
Normal file
BIN
__pycache__/TSP.cpython-39.pyc
Normal file
BIN
__pycache__/bfs.cpython-37.pyc
Normal file
BIN
__pycache__/bfs.cpython-38.pyc
Normal file
BIN
__pycache__/bfs.cpython-39.pyc
Normal file
BIN
__pycache__/colors.cpython-37.pyc
Normal file
BIN
__pycache__/colors.cpython-38.pyc
Normal file
BIN
__pycache__/colors.cpython-39.pyc
Normal file
BIN
__pycache__/granny.cpython-39.pyc
Normal file
BIN
__pycache__/house.cpython-37.pyc
Normal file
BIN
__pycache__/house.cpython-38.pyc
Normal file
BIN
__pycache__/house.cpython-39.pyc
Normal file
BIN
__pycache__/main.cpython-39.pyc
Normal file
BIN
__pycache__/pool.cpython-39.pyc
Normal file
BIN
__pycache__/text.cpython-39.pyc
Normal file
BIN
__pycache__/trash.cpython-37.pyc
Normal file
BIN
__pycache__/trash.cpython-38.pyc
Normal file
BIN
__pycache__/trash.cpython-39.pyc
Normal file
BIN
__pycache__/tree.cpython-39.pyc
Normal file
BIN
__pycache__/truck.cpython-37.pyc
Normal file
BIN
__pycache__/truck.cpython-38.pyc
Normal file
BIN
__pycache__/truck.cpython-39.pyc
Normal file
150
astar.py
Normal file
@ -0,0 +1,150 @@
|
||||
from truck import Truck
|
||||
|
||||
class Node():
|
||||
def __init__(self, parent=None, position=None):
|
||||
self.parent = parent
|
||||
self.position = position
|
||||
|
||||
self.g = 0
|
||||
self.h = 0
|
||||
self.f = 0
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.position == other.position
|
||||
|
||||
|
||||
def astar(maze, start, end):
|
||||
start_node = Node(position=start)
|
||||
end_node = Node(position=end)
|
||||
x=0
|
||||
open_list = []
|
||||
closed_list = []
|
||||
|
||||
open_list.append(start_node)
|
||||
|
||||
while len(open_list) > 0:
|
||||
|
||||
current_node = open_list[0]
|
||||
current_index = 0
|
||||
for index, item in enumerate(open_list):
|
||||
if item.f < current_node.f:
|
||||
current_node = item
|
||||
current_index = index
|
||||
|
||||
open_list.pop(current_index)
|
||||
closed_list.append(current_node)
|
||||
|
||||
if current_node == end_node:
|
||||
path = []
|
||||
|
||||
current = current_node
|
||||
while current is not None:
|
||||
path.append(current.position)
|
||||
if (maze[current.position[0]][current.position[1]] == 1):
|
||||
x = x + 1
|
||||
if (maze[current.position[0]][current.position[1]] == 2):
|
||||
x = x + 3
|
||||
if (maze[current.position[0]][current.position[1]] == 6):
|
||||
x = x + 20
|
||||
if (maze[current.position[0]][current.position[1]] == 7):
|
||||
x = x + 5
|
||||
if (maze[current.position[0]][current.position[1]] == 8):
|
||||
x = x + 1
|
||||
|
||||
current = current.parent
|
||||
return path[::-1]
|
||||
#return x
|
||||
|
||||
children = []
|
||||
for new_position in [(0, -1), (0, 1), (-1, 0), (1, 0)]:
|
||||
|
||||
node_position = (
|
||||
current_node.position[0] + new_position[0], current_node.position[1] + new_position[1])
|
||||
|
||||
if node_position[0] > (len(maze) - 1) or node_position[0] < 0 or node_position[1] > (len(maze[len(maze)-1]) - 1) or node_position[1] < 0:
|
||||
continue
|
||||
|
||||
if Node(current_node, node_position) in closed_list:
|
||||
continue
|
||||
|
||||
if maze[node_position[0]][node_position[1]] == 9:
|
||||
continue
|
||||
|
||||
new_node = Node(current_node, node_position)
|
||||
|
||||
children.append(new_node)
|
||||
|
||||
for child in children:
|
||||
|
||||
for closed_child in closed_list:
|
||||
if child == closed_child:
|
||||
continue
|
||||
|
||||
if(maze[child.position[0]][child.position[1]]==1):
|
||||
child.g = 1
|
||||
if(maze[child.position[0]][child.position[1]]==2):
|
||||
child.g = 3
|
||||
if(maze[child.position[0]][child.position[1]]==6):
|
||||
child.g = 20
|
||||
if(maze[child.position[0]][child.position[1]]==7):
|
||||
child.g = 5
|
||||
if(maze[child.position[0]][child.position[1]]==8):
|
||||
child.g = 1
|
||||
child.h = ((child.position[0] - end_node.position[0]) **
|
||||
2) + ((child.position[1] - end_node.position[1]) ** 2)
|
||||
child.f = child.g + child.h
|
||||
|
||||
for open_node in open_list:
|
||||
if child == open_node and child.g > open_node.g:
|
||||
continue
|
||||
|
||||
open_list.append(child)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
maze = [[9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],
|
||||
[9, 9, 9, 9, 9, 1, 1, 9, 9, 9, 1, 1, 1, 9, 9, 9, 1,
|
||||
1, 9, 9, 1, 1, 1, 9, 9, 1, 1, 9, 1, 1, 9, 9],
|
||||
[9, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1,
|
||||
8, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 9],
|
||||
[9, 1, 1, 1, 2, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 9,
|
||||
1, 0, 1, 7, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 9],
|
||||
[9, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 1, 1, 1, 1, 9, 9,
|
||||
9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9],
|
||||
[9, 9, 9, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 2, 1,
|
||||
1, 1, 1, 9, 6, 6, 9, 1, 1, 2, 1, 1, 9, 1, 9],
|
||||
[9, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9],
|
||||
[9, 1, 1, 1, 9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 9, 9, 9,
|
||||
9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9],
|
||||
[9, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 1, 1, 1, 1,
|
||||
1, 9, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 9],
|
||||
[9, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 9,
|
||||
9, 9, 7, 6, 9, 9, 9, 9, 6, 2, 1, 9, 9, 9, 9],
|
||||
[9, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 9, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 9],
|
||||
[9, 1, 1, 1, 9, 9, 9, 9, 9, 1, 1, 9, 9, 9, 1, 1, 9,
|
||||
9, 9, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 9],
|
||||
[9, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 2, 1, 1, 9, 9, 1, 9, 1, 1, 7, 1, 1, 9],
|
||||
[9, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9],
|
||||
[9, 1, 1, 9, 1, 1, 9, 9, 9, 1, 9, 1, 1, 1, 9, 9, 9,
|
||||
1, 1, 1, 1, 1, 9, 1, 1, 1, 9, 9, 1, 1, 1, 9],
|
||||
[9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 2, 1,
|
||||
1, 1, 1, 9, 9, 9, 9, 1, 1, 1, 2, 1, 1, 9, 9],
|
||||
[9, 1, 1, 1, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 9, 1, 1,
|
||||
1, 9, 1, 1, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 9],
|
||||
[9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]]
|
||||
|
||||
start = (13, 7)
|
||||
end = (3, 18)
|
||||
|
||||
path = astar(maze, start, end)
|
||||
print(path)
|
||||
return path
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
67
bfs.py
Normal file
@ -0,0 +1,67 @@
|
||||
from house import *
|
||||
import pygame
|
||||
|
||||
|
||||
class Node:
|
||||
def __init__(self, pos, direction, parent=None, action=None):
|
||||
self.pos = pos
|
||||
self.direction = direction
|
||||
self.parent = parent
|
||||
self.action = action
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, Node):
|
||||
return self.pos == other.pos and self.direction == other.direction
|
||||
return False
|
||||
|
||||
|
||||
def successor(pos, direction, houses):
|
||||
neighbours = []
|
||||
axis = 0 if direction in [0, 2] else 1
|
||||
move = 1 if direction in [0, 1] else -1
|
||||
|
||||
neighbours.append([pos, (direction - 1) % 4, pygame.K_a])
|
||||
neighbours.append([pos, (direction + 1) % 4, pygame.K_d])
|
||||
|
||||
if not axis: # x
|
||||
new_pos = [pos[0] + (move * 40), pos[1]]
|
||||
if not is_house(new_pos, houses):
|
||||
neighbours.append([new_pos, direction, pygame.K_w])
|
||||
|
||||
else: # y
|
||||
new_pos = [pos[0], pos[1] + (move * 40)]
|
||||
if not is_house(new_pos, houses):
|
||||
neighbours.append([new_pos, direction, pygame.K_w])
|
||||
return neighbours
|
||||
|
||||
|
||||
def bfs(pos, direction, end_pos, houses):
|
||||
visited = []
|
||||
queue = []
|
||||
actions = []
|
||||
queue.append(Node(pos, direction))
|
||||
|
||||
while queue:
|
||||
curr_node = queue.pop(0)
|
||||
|
||||
if not is_house(curr_node.pos, houses) and curr_node.pos == end_pos:
|
||||
while curr_node.parent:
|
||||
|
||||
# print(curr_node.pos, end_pos)
|
||||
actions.append(curr_node.action)
|
||||
curr_node = curr_node.parent
|
||||
return actions
|
||||
|
||||
visited.append(curr_node)
|
||||
for n_pos, n_direction, action in successor(curr_node.pos, curr_node.direction, 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):
|
||||
houses = create_houses(40)
|
||||
actions = bfs(pos, 0, endpos, houses)
|
||||
return len(actions)
|
||||
|
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 |