22ds2000101 commited on
Commit
5810183
·
verified ·
1 Parent(s): 00f5136

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py.txt +21 -0
  2. requirements.txt +3 -0
app.py.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ captioner = pipeline(
5
+ "image-to-text",
6
+ model="Salesforce/blip-image-captioning-base"
7
+ )
8
+
9
+ def generate_caption(image):
10
+ result = captioner(image)
11
+ return result[0]["generated_text"]
12
+
13
+ demo = gr.Interface(
14
+ fn=generate_caption,
15
+ inputs=gr.Image(type="pil", label="Upload an Image"),
16
+ outputs=gr.Textbox(label="Generated Caption"),
17
+ title="AI Image Captioning App",
18
+ description="Upload an image and generate a caption using a Hugging Face vision-language model."
19
+ )
20
+
21
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch