Virtual-Try-On-Flask
Virtual-Try-On-Flask copied to clipboard
Exception on /upload [POST], RuntimeError
After running the /web app I am getting the following error. Please see the following errors to check if you can help me on it.
Virtual-Try-On-Flask amishra$ python main.py
/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:529: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:530: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:535: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
2020-02-17 16:00:16.796608: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
WARNING:tensorflow:From /Users/amishra/github/Virtual-Try-On-Flask/JPPNet.py:24: FastGFile.__init__ (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.gfile.GFile.
initialization method [normal]
initialization method [normal]
* Serving Flask app "main" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [17/Feb/2020 16:00:44] "GET /web HTTP/1.1" 200 -
ImmutableMultiDict([('optionsRadios', 'option0')])
ImmutableMultiDict([('person_image', <FileStorage: 'example_person.jpg' ('image/jpeg')>), ('cloth_image', <FileStorage: '' ('application/octet-stream')>)])
<FileStorage: 'example_person.jpg' ('image/jpeg')> <FileStorage: '' ('application/octet-stream')>
upper:0,bounder:251,left:0,right:191
after crop shape:(251, 191, 3)
[2020-02-17 16:01:12,048] ERROR in app: Exception on /upload [POST]
Traceback (most recent call last):
File "/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "main.py", line 82, in upload_image
person_image, cloth_list[index][0].split("\\")[-1], cloth_image)
File "main.py", line 118, in run_model_web
out, v = model.predict(human_img, c_img, need_bright=False, keep_back=True)
File "/Users/amishra/github/Virtual-Try-On-Flask/Model.py", line 83, in predict
pose_map = self.__getPoseMap__(pose_data)
File "/Users/amishra/github/Virtual-Try-On-Flask/Model.py", line 179, in __getPoseMap__
one_map = Model.transformer(one_map)
File "/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 70, in __call__
img = t(img)
File "/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 175, in __call__
return F.normalize(tensor, self.mean, self.std, self.inplace)
File "/Users/amishra/anaconda3/envs/myenv/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 217, in normalize
tensor.sub_(mean[:, None, None]).div_(std[:, None, None])
RuntimeError: output with shape [1, 256, 192] doesn't match the broadcast shape [3, 256, 192]
127.0.0.1 - - [17/Feb/2020 16:01:12] "POST /upload HTTP/1.1" 500 -
I am using the CPU mode execution. Did all the necessary changes recommended by you.
Sry, I haven't test codes on CPU enviroments, which is on my to-do list, but I'll check it soon...
Hi, after tests on my machine, removing all cuda()
can use CPU mode normally.
Can you tell your enviroments? I only tested them on torch==1.2.0 torchvision==0.2.0
Hi @GrayXu I did exactly same for CPU mode, but still I get following erros:
RuntimeError: output with shape [1, 256, 192] doesn't match the broadcast shape [3, 256, 192]
127.0.0.1 - - [17/Feb/2020 16:01:12] "POST /upload HTTP/1.1" 500 -
What's your pytorch version?
pip3 list | grep torch
Also I update codes to change running modes easily here
Thanks @GrayXu I installed exact version of torch
and torchvision
. And it is working fine.
Unfortunately, Cloth transfer results are not satisfactory. :(
Hi @GrayXu When I am clicking the radio button for selecting the cloth, it throws an error on submitting. We are saving them in static/img folder right?