Commit ac84e5ca authored by Diego André Sant'Ana's avatar Diego André Sant'Ana 🤞

Merge branch 'alterPythonVersionSuportFixBugs'

parents 1582b5f7 0e123bf4
......@@ -64,6 +64,18 @@
<option value="E501" />
<option value="W29" />
<option value="E501" />
<option value="W29" />
<option value="E501" />
<option value="W29" />
<option value="E501" />
<option value="W29" />
<option value="E501" />
<option value="W29" />
<option value="E501" />
<option value="W29" />
<option value="E501" />
<option value="W29" />
<option value="E501" />
</list>
</option>
</inspection_tool>
......
This diff is collapsed.
......@@ -6,6 +6,8 @@ YELLOW='\033[0;33m'
NC='\033[0m'
echo "[PYNOVISAO INSTALLER] Installing PYNOVISAO... Please wait!"
export OMP_NUM_THREADS=4
export KMP_AFFINITY="verbose,explicit,proclist=[0,3,5,9],granularity=core"
#check if is root
if [ "$EUID" -ne 0 ]
......
......@@ -242,6 +242,7 @@ Se você deseja as funcionalidades gráficas você precisa instalar matplotlib t
- http://pythonhosted.org/python-weka-wrapper/troubleshooting.html
### Como instalar o caffe ( Opcional )
#### Ubuntu / Windows
......@@ -352,3 +353,8 @@ Após a implementação de seu classificador, você deve configurá-lo no pynovi
Caso você necessite de classes utilitárias, os arquivos delas devem ser criados no diretório src/util/. Além disso, as classes utilitárias devem ser registradas como módulos no arquivo src/util/__init__.py
Caso dê problema relacionado ao número de processos, adicione as duas váriaveis de ambiente,
sendo que deve adicionar no número de threads que o seu processador permite:
export OMP_NUM_THREADS=8
export KMP_AFFINITY="verbose,explicit,proclist=[0,3,5,9,12,15,18,21],granularity=core"
......@@ -12,7 +12,7 @@ python-weka-wrapper
cycler==0.10
cython
h5py
scikit-learn
scikit-learn==0.20.1
statistics
pandas_ml
pyxdg
......
......@@ -28,7 +28,7 @@ import threading
#
#from util.utils import TimeUtils
from util.utils import TimeUtils
......@@ -40,15 +40,16 @@ class ExtractFM(object):
pass
#Method Run, you can passa tkParent to manipulate objet to tk parent, this code use to console to print process extract frame movies.
def run(self,tkParent):
self.tk=tkParent
self.folder_a=None
self.folder_b=None
#window
self.window = Tk()
self.window.mainloop()
self.window = Toplevel()
self.window.title("Extract frames from videos")
self.window.attributes('-zoomed', False)
self.window.geometry("450x250+300+300")
self.window.geometry("450x275+300+300")
self.frame = Frame(self.window )
self.frame.pack(fill=X, expand=False)
#find a folder with videos
......@@ -67,24 +68,23 @@ class ExtractFM(object):
self.label_b =Label(self.frame, text="Folder no selected", padx=5, pady=5)
self.label_b.pack(padx=5, pady=5, expand=True, fill=X)
self.label_c =Label(self.frame, text="Enter in how many frames a frame will be extracted ", padx=5, pady=5)
self.label_c =Label(self.frame, text="Each of the N frames draws a frame ", padx=5, pady=5)
self.label_c.pack(padx=5, pady=5, expand=True, fill=X)
#number de frame by extract one picture
self.val_frame=IntVar()
self.val_frame.set(1)
self.val_frame.set(30)
self.spinbox = Spinbox(self.frame, from_=1.0, to=100.0)
self.spinbox = Spinbox(self.frame, from_=1.0, to=100.0, textvariable=self.val_frame)
self.spinbox.configure(activebackground="#f9f9f9")
self.spinbox.configure(background="white")
self.spinbox.configure(buttonbackground="wheat")
self.spinbox.configure(disabledforeground="#b8a786")
self.spinbox.configure(from_="1.0")
self.spinbox.configure(highlightbackground="black")
self.spinbox.configure(selectbackground="#c4c4c4")
self.spinbox.configure(textvariable=self.val_frame)
self.spinbox.configure(to="100.0")
self.spinbox.pack(padx=5, pady=5, expand=True, fill=X)
#ToolTip(self.spinbox , "Select between 1 an 100 to extract frame each the number selected!Example: Select 30 to extract 1 frame each 30 fps!")
......@@ -140,7 +140,7 @@ class ExtractFM(object):
self.tk.write_log("Init process:"+ str(listaArquivo))
lista_thread=[]
#start_time = TimeUtils.get_time()
start_time = TimeUtils.get_time()
for r, d, f in os.walk(dir):
for file in f:
......@@ -155,7 +155,7 @@ class ExtractFM(object):
t.join()
#end_time = TimeUtils.get_time()
end_time = TimeUtils.get_time()
self.tk.append_log("Finish process:"+str(end_time - start_time))
def select_folder_source(self):
......
......@@ -14,6 +14,7 @@ import os
import gc
import multiprocessing
from multiprocessing import Process, Manager
import threading
from interface.interface import InterfaceException as IException
from util.file_utils import File
......@@ -43,12 +44,20 @@ class FeatureExtractor(object):
self.extractors = extractors
self.tkParent=tkParent
def extract_all(self, dataset, output_file=None, dirs=None, overwrite=True):
self.data = Manager().list() #is a necessary because have a problem with use Process and normaly declaration
def extract_all(self, dataset, output_file=None, dirs=None, overwrite=True, processor_amd=False):
self.processor_amd=processor_amd
self.threads = []
self.labels = Manager().list()
self.types = Manager().list()
if self.processor_amd == True :
self.data = Manager().list() #is a necessary because have a problem with use Process and normaly declaration
self.labels = Manager().list()
self.types = Manager().list()
else:
self.data = [] #is a necessary because have a problem with use Process and normaly declaration
self.labels = []
self.types = []
"""Runs the feature extraction algorithms on all images of dataset.
Parameters
......@@ -98,14 +107,9 @@ class FeatureExtractor(object):
self.job_extractor(dataset, cl, classes)
self.print_console("Wait a moment, the threads are processing "+str(len(self.threads)) +" images, it may be delayed depending on the size or quantity of the images!")
print("Number of Cores: "+str(multiprocessing.cpu_count()))
#Start threads
with tqdm(total=len(self.threads)) as pbar:
for t in self.threads:
t.start()
if(len(multiprocessing.active_children())>10):
t.join()
gc.collect()
pbar.update(1)
pbar.close()
......@@ -113,13 +117,14 @@ class FeatureExtractor(object):
with tqdm(total=len(self.threads)) as ppbar:
for t in self.threads:
t.join()
del t
ppbar.update(1)
ppbar.close()
self.print_console("The process was completed with "+str(len(self.threads))+" images!")
if len(self.data) == 0:
raise IException("There are no images in dataset: %s" % dataset)
del self.threads
gc.collect()
# Save the output file in ARFF format
# self._save_output(File.get_filename(dataset), classes, self.labels, self.types, self.data, output_file)
self._save_output(File.get_filename(dataset), classes, self.labels[0], self.types[0], self.data, output_file)
......@@ -136,8 +141,11 @@ class FeatureExtractor(object):
for item in items :
if item.startswith('.'):
continue
#th = threading.Thread(target=self.sub_job_extractor,args=(item, dataset, cl, classes))
th = multiprocessing.Process(target=self.sub_job_extractor,args=(item, dataset, cl, classes))
if self.processor_amd==True :
th = multiprocessing.Process(target=self.sub_job_extractor,args=(item, dataset, cl, classes))
else:
th = threading.Thread(target=self.sub_job_extractor,args=(item, dataset, cl, classes))
self.threads.append(th)
......
......@@ -58,7 +58,7 @@ class RawCentralMoments(Extractor):
values_mu = [mu[p, q] for (p, q) in self._moments_order]
labels_mu = [M+str(p)+str(q) for M,(p,q) in zip(['Mu_'] * len(self._moments_order), self._moments_order)]
print(values_mu)
#print(values_mu)
labels = labels_m + labels_mu
types = [Extractor.NUMERIC] * len(labels)
values = values_m + values_mu
......
......@@ -87,7 +87,9 @@ class KCURVATURE(Extractor):
#ret, thresh = cv2.threshold(np.copy(gray), 127, 255, 0)
edges = self.auto_canny(gray, 1)
if cv2.getVersionMajor() in [2, 4]:
(major, minor, _) = cv2.__version__.split(".")
if int(major) in [2, 4]:
# OpenCV 2, OpenCV 4 case
contour, hier = cv2.findContours(edges.copy(), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)
#print(contours)
......
......@@ -161,7 +161,8 @@ class Image(object):
self._toolbar.configure(background='white', borderwidth=0)
for child in self._toolbar.winfo_children():
if sys.version_info[0] < 3:
child.configure(background='white', foreground='black')
#child.configure(background='white', foreground='black')
child.configure(background='white')
else:
child.configure(background='white')
#self._toolbar.update()
......
......@@ -68,7 +68,7 @@ class TkInterface(Interface):
self._root = Tk.Tk()
self._root.wm_title(self.title)
self._root.geometry('%dx%d+%d+%d' % (800, 600, 0, 0))
self._root.geometry('%dx%d+%d+%d' % (800, 800, 0, 0))
self._menus = []
......
......@@ -140,6 +140,7 @@ class Act(object):
def onclick(event):
"""Binds dataset generator event to click on image."""
print(event)
if event.xdata != None and event.ydata != None and int(event.ydata) != 0 and self._dataset_generator == True:
x = int(event.xdata)
y = int(event.ydata)
......@@ -562,7 +563,7 @@ class Act(object):
pppbar.update(1)
pppbar.close()
gc.collect()
# Perform the feature extraction of all segments in image ( not applied to ConvNets ).
if self.classifier.must_extract_features():
self.tk.append_log("Running extractors on test images... (%0.3f seconds)", (TimeUtils.get_time() - start_time))
......@@ -624,6 +625,7 @@ class Act(object):
self.tk.append_log("\nClassification finished")
self.tk.append_log("Time elapsed: %0.3f seconds", (end_time - start_time))
gc.collect()
def run_training(self):
start_time = TimeUtils.get_time()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment