arssite commited on
Commit
68e4877
·
verified ·
1 Parent(s): 8e3c985

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -1,20 +1,20 @@
1
- import torch
2
- import gradio as gr
3
- from PIL import Image
4
- import scipy.io.wavfile as wavfile
5
-
6
- # Use a pipeline as a high-level helper
7
- from transformers import pipeline
8
-
9
- device = "cuda" if torch.cuda.is_available() else "cpu"
10
- caption_image = pipeline("image-to-text",
11
- model="Salesforce/blip-image-captioning-large", device=device)
12
- def caption_my_image(pil_image):
13
- semantics = caption_image(images=pil_image)[0]['generated_text']
14
- return semantics
15
- demo = gr.Interface(fn=caption_my_image,
16
- inputs=[gr.Image(label="Select Image",type="pil")],
17
- outputs=[gr.Textbox(label="Image Caption")],
18
- title="@GenAILearniverse Project 8: Image Captioning",
19
- description="THIS APPLICATION WILL BE USED TO CAPTION THE IMAGE.")
20
  demo.launch()
 
1
+ import torch
2
+ import gradio as gr
3
+ from PIL import Image
4
+ import scipy.io.wavfile as wavfile
5
+
6
+ # Use a pipeline as a high-level helper
7
+ from transformers import pipeline
8
+
9
+ device = "cuda" if torch.cuda.is_available() else "cpu"
10
+ caption_image = pipeline("image-to-text",
11
+ model="Salesforce/blip-image-captioning-large", device=device)
12
+ def caption_my_image(pil_image):
13
+ semantics = caption_image(images=pil_image)[0]['generated_text']
14
+ return semantics
15
+ demo = gr.Interface(fn=caption_my_image,
16
+ inputs=[gr.Image(label="Select Image",type="pil")],
17
+ outputs=[gr.Textbox(label="Image Caption")],
18
+ title="Image Captioning",
19
+ description="THIS APPLICATION WILL BE USED TO CAPTION THE IMAGE.")
20
  demo.launch()