diff --git a/Foodimg2Ing/modules/multihead_attention.py b/Foodimg2Ing/modules/multihead_attention.py index 0abd969..447913b 100644 --- a/Foodimg2Ing/modules/multihead_attention.py +++ b/Foodimg2Ing/modules/multihead_attention.py @@ -124,7 +124,7 @@ def forward(self, query, key, value, mask_future_timesteps=False, # don't attend to padding symbols attn_weights = attn_weights.view(bsz, self.num_heads, tgt_len, src_len) attn_weights = attn_weights.float().masked_fill( - key_padding_mask.unsqueeze(1).unsqueeze(2), + key_padding_mask.unsqueeze(1).unsqueeze(2).bool(), float('-inf'), ).type_as(attn_weights) # FP16 support: cast to float and back attn_weights = attn_weights.view(bsz * self.num_heads, tgt_len, src_len) diff --git a/Foodimg2Ing/routes.py b/Foodimg2Ing/routes.py index 136f107..707dc57 100644 --- a/Foodimg2Ing/routes.py +++ b/Foodimg2Ing/routes.py @@ -15,7 +15,7 @@ def about(): @app.route('/',methods=['POST','GET']) def predict(): imagefile=request.files['imagefile'] - image_path=os.path.join(app.root_path,'static\\images\\demo_imgs',imagefile.filename) + image_path=os.path.join(app.root_path,'static/images/demo_imgs',imagefile.filename) imagefile.save(image_path) img="/images/demo_imgs/"+imagefile.filename title,ingredients,recipe = output(image_path) @@ -23,7 +23,7 @@ def predict(): @app.route('/') def predictsample(samplefoodname): - imagefile=os.path.join(app.root_path,'static\\images',str(samplefoodname)+".jpg") + imagefile=os.path.join(app.root_path,'static/images',str(samplefoodname)+".jpg") img="/images/"+str(samplefoodname)+".jpg" title,ingredients,recipe = output(imagefile) - return render_template('predict.html',title=title,ingredients=ingredients,recipe=recipe,img=img) \ No newline at end of file + return render_template('predict.html',title=title,ingredients=ingredients,recipe=recipe,img=img)