OlafenwaMoses / FireNET

A deep learning model for detecting fire in video and camera streams
MIT License
287 stars 99 forks source link

problem with loadmodel #1

Open hpexeph opened 4 years ago

hpexeph commented 4 years ago

First of all, I want to thank you for sharing this code. When I compile the code, I face 2 errors in detector.loadModel()

The main function is this : detection_model_json = json.load(open(self.detection_config_json_path)) Lines 911 and 642 in _init.py file

what is the reason for this error?

I changed the lines in detect_from_video() function like this :

detector.setModelPath(detection_model_path=os.path.join("F:\PROJECTS\fire detection python\FireNET-master\pretrained-yolov3.h5", "detection_model-ex-33--loss-4.97.h5"))

detector.setJsonPath(configuration_json=os.path.join("F:\PROJECTS\fire detection python\FireNET-master\detection_config.json", "detection_config.json"))

OlafenwaMoses commented 4 years ago

What errors did you face?

hpexeph commented 4 years ago

Thank you for your reply. Your program contains 3 functions. First of all, I run train_detection_model() and I got these :

Using TensorFlow backend. Generating anchor boxes for training images and annotation... Traceback (most recent call last): File "fire_net.py", line 45, in train_detection_model() File "fire_net.py", line 15, in train_detection_model train_from_pretrained_model="pretrained-yolov3.h5") File "C:\Users\Hamed\AppData\Local\Programs\Python\Python36\lib\site-packages\imageai\Detection\Custom__init.py", line 171, in setTrainConfig self.train_cache_file, self.__model_labels) File "C:\Users\Hamed\AppData\Local\Programs\Python\Python36\lib\site-packages\imageai\Detection\Custom\gen_anchors.py", line 82, in generateAnchors model_labels File "C:\Users\Hamed\AppData\Local\Programs\Python\Python36\lib\site-packages\imageai\Detection\Custom\voc.py", line 15, in parse_voc_annotation for ann in sorted(os.listdir(ann_dir)): FileNotFoundError: [WinError 3] The system cannot find the path specified: 'fire-dataset\train\annotations'

As I understand from the code, first I have to tun train_detection_model() and after that, I can use one of two other functions. Am I right?

This is the code I use : from imageai.Detection.Custom import CustomObjectDetection, CustomVideoObjectDetection

import os

execution_path = os.getcwd()
from imageai.Detection.Custom import DetectionModelTrainer

trainer = DetectionModelTrainer()
trainer.setModelTypeAsYOLOv3()
trainer.setDataDirectory(data_directory="fire-dataset")
trainer.setTrainConfig(object_names_array=["fire"], batch_size=8, num_experiments=100,
                       train_from_pretrained_model="pretrained-yolov3.h5")
# download 'pretrained-yolov3.h5' from the link below
# https://github.com/OlafenwaMoses/ImageAI/releases/download/essential-v4/pretrained-yolov3.h5
trainer.trainModel()
OlafenwaMoses commented 4 years ago

Please visit the article linked below and ensure your organize your dataset folder as specified in the article.

https://medium.com/deepquestai/train-object-detection-ai-with-6-lines-of-code-6d087063f6ff

hpexeph commented 4 years ago

Hi again Sorry, one of my friends passed away and I wasn't in a good mood. Today I started reading the link you posted. I read the article. in the codes, I don't know how to change this line :

trainer.setDataDirectory(data_directory="hololens")

I have datasets for fire as you mentioned in the article, and what I have to write instead of "hololens"? I will appreciate if you help me in changing these two lines :

trainer.setDataDirectory(data_directory="hololens")

trainer.setTrainConfig(object_names_array=["hololens"], batch_size=4, num_experiments=100, train_from_pretrained_model="pretrained-yolov3.h5")

VictoriaNavarrete commented 4 years ago

Hello. I also found your code interesting for a project I'm involved into, I am trying to recognize fire from the data obtained from a infrared-camera.

But I tried to compile the first function and this error surged:

File "D:\Anaconda\lib\site-packages\imageai\Detection\Custom\yolo.py", line 24, in init cell_x = tf.to_float(tf.reshape(tf.tile(tf.range(max_grid_w), [max_grid_h]), (1, max_grid_h, max_grid_w, 1, 1)))

AttributeError: module 'tensorflow' has no attribute 'to_float'

I´m working from Anaconda, and I tried to downgrade tensorflow but it doesn't seem to work. Someone could help me understand what is happening please?

harisbitsakou commented 4 years ago

@VictoriaNavarrete I am having the same issue.. did you manage to solve it??

hpexeph commented 4 years ago

@VictoriaNavarrete I am having the same issue.. did you manage to solve it??

Unfortunately no

VictoriaNavarrete commented 4 years ago

Hi. I think the problem was that I had to downgrade my Tensorflow version to 1.15.2. Also I installed ImageAI with pip comand and upgraded.

El jue., 12 mar. 2020 17:18, Hamed notifications@github.com escribió:

@VictoriaNavarrete https://github.com/VictoriaNavarrete I am having the same issue.. did you manage to solve it??

Unfortunately no

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OlafenwaMoses/FireNET/issues/1#issuecomment-598278053, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANF3G4RULW6GHRCFR5HAISTRHEDPDANCNFSM4JAFTEPQ .

hpexeph commented 4 years ago

Does the problem solved with that?

VictoriaNavarrete commented 4 years ago

This one specificaly for me at least.

El jue., 12 mar. 2020 17:27, Hamed notifications@github.com escribió:

Does the problem solved with that?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OlafenwaMoses/FireNET/issues/1#issuecomment-598282337, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANF3G4VSXWDD7VWQHDMDTMDRHEENVANCNFSM4JAFTEPQ .

hpexeph commented 4 years ago

You mean by downgrading tensorflow and installing imageai the problem will solve?