Я пытаюсь загрузить файл рассола model_vgg_config2.pickle
на свой колб-сервер, но продолжаю сталкиваться со следующей ошибкой:
Traceback (most recent call last):
File "/Users/sleepyotter/anaconda3/envs/project/lib/python3.7/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/Users/sleepyotter/anaconda3/envs/project/lib/python3.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/sleepyotter/anaconda3/envs/project/lib/python3.7/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/sleepyotter/anaconda3/envs/project/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/Users/sleepyotter/anaconda3/envs/project/lib/python3.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/sleepyotter/anaconda3/envs/project/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/sleepyotter/Desktop/Product_Analytics/project/code/app/routes_2.py", line 66, in index
detector.load_model(detector_weights, detector_config)
File "/Users/sleepyotter/Desktop/Product_Analytics/project/code/app/models/frcnn_detector/frcnn.py", line 89, in load_model
config = pickle.load(f_in)
AttributeError: Can't get attribute 'Config' on <module '__main__' from '/Users/sleepyotter/anaconda3/envs/project/bin/flask'>
127.0.0.1 - - [27/Apr/2019 11:25:56] "POST / HTTP/1.1" 500 -
Файл pickle - это объект Config
, который я определил в файле с именем config.py
file:
Вот config.py :
class Config:
def __init__(self):
# Print the process or not
self.verbose = True
# Name of base network
self.network = 'vgg'
# Setting for data augmentation
self.use_horizontal_flips = False
self.use_vertical_flips = False
self.rot_90 = False
# Anchor box scales
# Note that if im_size is smaller, anchor_box_scales should be scaled
# Original anchor_box_scales in the paper is [128, 256, 512]
self.anchor_box_scales = [64, 128, 256]
# Anchor box ratios
self.anchor_box_ratios = [[1, 1], [1./math.sqrt(2), 2./math.sqrt(2)], [2./math.sqrt(2), 1./math.sqrt(2)]]
# Size to resize the smallest side of the image
# Original setting in paper is 600. Set to 300 in here to save training time
self.im_size = 300
# image channel-wise mean to subtract
self.img_channel_mean = [103.939, 116.779, 123.68]
self.img_scaling_factor = 1.0
# number of ROIs at once
self.num_rois = 4
# stride at the RPN (this depends on the network configuration)
self.rpn_stride = 16
self.balanced_classes = False
# scaling the stdev
self.std_scaling = 4.0
self.classifier_regr_std = [8.0, 8.0, 4.0, 4.0]
# overlaps for RPN
self.rpn_min_overlap = 0.3
self.rpn_max_overlap = 0.7
# overlaps for classifier ROIs
self.classifier_min_overlap = 0.1
self.classifier_max_overlap = 0.5
# placeholder for the class mapping, automatically generated by the parser
self.class_mapping = None
self.model_path = None
Я пытаюсь загрузить файл конфигурации из файла routes.py
, но всегда получаю ошибку этого атрибута.
Вот некоторые вещи, которые я уже пробовал:
from config import Config
в файле routes.py
- определил сам
class Config
в файле rout.py
Похоже, что он ищет только класс Config в '/Users/sleepyotter/anaconda3/envs/project/bin/flask'
... почему он не находит класс Config, который я импортировал в файл rout.py?