ashutosh commited on
Commit
64b5e95
1 Parent(s): 8d463c7

Image-Caption

Browse files
__pycache__/app.cpython-311.pyc ADDED
Binary file (1.35 kB). View file
 
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import io
3
+ import IPython.display
4
+ from PIL import Image
5
+ import base64
6
+
7
+ from transformers import pipeline
8
+ import gradio as gr
9
+
10
+ get_completion = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
11
+
12
+ def captioner(image):
13
+ result = get_completion(image)
14
+ return result[0]['generated_text']
15
+
16
+ gr.close_all()
17
+
18
+ demo = gr.Interface(
19
+ fn=captioner,
20
+ inputs=[gr.Image(label="Upload image", type="pil")],
21
+ outputs=[gr.Textbox(label="Caption")],
22
+ title="Image Captioning with BLIP",
23
+ description="Caption any image using the BLIP model",
24
+ allow_flagging="never",
25
+ )
26
+
27
+ demo.launch()
28
+
29
+ gr.close_all()
env/conda-meta/history ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ ==> 2023-08-24 13:54:48 <==
2
+ # cmd: /home/ashutosh/anaconda3/bin/conda create --prefix ./env
3
+ # conda version: 23.7.2
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ gradio
3
+ torch