File size: 582 Bytes
dd04c5e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#Filter the warnings
import warnings
warnings.filterwarnings('ignore')
from transformers import logging
logging.set_verbosity_error()

#Import the necessary
import gradio as gr
from transformers import pipeline

#Perform Image Captioning
get_completion = pipeline("image-to-text",model="Salesforce/blip-image-captioning-base")

#Launch the input
def launch(input):
  out=get_completion(input)
  return out[0]['generated_text']

#Define an interface
interface=gr.Interface(fn=launch,inputs=gr.Image(type="pil"),outputs="text",title="Image Captioning with BLIP")

interface.launch()