我正在尝试在我的烧瓶服务器上加载一个pickle文件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 -
泡菜文件是一个Config
对象,我在名为config.py
的文件中定义了该对象:
这里是 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
本身似乎只在'/Users/sleepyotter/anaconda3/envs/project/bin/flask'
中寻找Config类……为什么找不到我导入到route.py文件中的Config类?