chhetri123 commited on
Commit
0d579e3
1 Parent(s): cd357b0

Update app.py

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