chhetri123 commited on
Commit
cd357b0
1 Parent(s): 08b2760

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -43,14 +43,14 @@ with open('transformer/tokenizer.pickle', 'rb') as handle:
43
  print("Tokenizer loaded successfully")
44
 
45
 
46
- def tranformer(image):
47
- image = Image.fromarray(image)
48
  print(image)
49
  temp_file, temp_file_path = tempfile.mkstemp(suffix=".jpg")
50
  os.close(temp_file)
51
  image.save(temp_file_path)
52
- caption=evaluate_single_image(temp_file_path,tokenizer,loaded_transformer)
53
  return caption
54
 
55
- interface = gr.Interface(fn=tranformer, inputs=gr.Image(), outputs="text",api_name="predict")
56
  interface.launch(debug=True)
 
43
  print("Tokenizer loaded successfully")
44
 
45
 
46
+ def transformer(image_file):
47
+ image = Image.open(image_file)
48
  print(image)
49
  temp_file, temp_file_path = tempfile.mkstemp(suffix=".jpg")
50
  os.close(temp_file)
51
  image.save(temp_file_path)
52
+ caption = evaluate_single_image(temp_file_path, tokenizer, loaded_transformer)
53
  return caption
54
 
55
+ interface = gr.Interface(fn=transformer, inputs=gr.Image(type="file"), outputs="text", api_name="predict")
56
  interface.launch(debug=True)