mouaddb commited on
Commit
8517128
·
1 Parent(s): da5c214

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  from transformers import AutoProcessor, AutoTokenizer, AutoImageProcessor, AutoModelForCausalLM, BlipForConditionalGeneration, VisionEncoderDecoderModel
3
  import torch
 
4
 
5
  git_processor_base = AutoProcessor.from_pretrained("microsoft/git-base-coco")
6
  git_model_base = AutoModelForCausalLM.from_pretrained("microsoft/git-base-coco")
@@ -24,15 +25,16 @@ def generate_caption(processor, model, image, tokenizer=None):
24
 
25
 
26
  def generate_captions(image):
 
 
27
  caption_git_base = generate_caption(git_processor_base, git_model_base, image)
28
-
29
- print(caption_git_base)
30
-
31
- return caption_git_base
32
 
33
 
34
  examples = [["test-1.jpeg"], ["test-2.jpeg"], ["test-3.jpeg"], ["test-4.jpeg"], ["test-5.jpeg"], ["test-6.jpg"]]
35
- outputs = [gr.outputs.Textbox(label="Caption generated by GIT-base")]
36
 
37
 
38
  interface = gr.Interface(fn=generate_captions,
 
1
  import gradio as gr
2
  from transformers import AutoProcessor, AutoTokenizer, AutoImageProcessor, AutoModelForCausalLM, BlipForConditionalGeneration, VisionEncoderDecoderModel
3
  import torch
4
+ import time
5
 
6
  git_processor_base = AutoProcessor.from_pretrained("microsoft/git-base-coco")
7
  git_model_base = AutoModelForCausalLM.from_pretrained("microsoft/git-base-coco")
 
25
 
26
 
27
  def generate_captions(image):
28
+ start = time.time()
29
+
30
  caption_git_base = generate_caption(git_processor_base, git_model_base, image)
31
+ end = time.time()
32
+ print(end - start)
33
+ return caption_git_base, end - start
 
34
 
35
 
36
  examples = [["test-1.jpeg"], ["test-2.jpeg"], ["test-3.jpeg"], ["test-4.jpeg"], ["test-5.jpeg"], ["test-6.jpg"]]
37
+ outputs = [gr.outputs.Textbox(label="Caption generated by GIT-base"), gr.outputs.Textbox(label="Time Elapsed")]
38
 
39
 
40
  interface = gr.Interface(fn=generate_captions,