Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with loadmodel #1

Open
hpexeph opened this issue Oct 13, 2019 · 11 comments
Open

problem with loadmodel #1

hpexeph opened this issue Oct 13, 2019 · 11 comments

Comments

@hpexeph
Copy link

hpexeph commented Oct 13, 2019

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
Copy link
Owner

What errors did you face?

@hpexeph
Copy link
Author

hpexeph commented Oct 14, 2019

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
Copy link
Owner

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
Copy link
Author

hpexeph commented Oct 20, 2019

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
Copy link

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
Copy link

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

@hpexeph
Copy link
Author

hpexeph commented Mar 12, 2020

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

Unfortunately no

@VictoriaNavarrete
Copy link

VictoriaNavarrete commented Mar 12, 2020 via email

@hpexeph
Copy link
Author

hpexeph commented Mar 12, 2020

Does the problem solved with that?

@VictoriaNavarrete
Copy link

VictoriaNavarrete commented Mar 12, 2020 via email

@hpexeph
Copy link
Author

hpexeph commented Mar 12, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants