Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Foodimg2Ing/modules/multihead_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions Foodimg2Ing/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ 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)
return render_template('predict.html',title=title,ingredients=ingredients,recipe=recipe,img=img)

@app.route('/<samplefoodname>')
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)
return render_template('predict.html',title=title,ingredients=ingredients,recipe=recipe,img=img)