SumantBobade commited on
Commit
f295f8c
·
verified ·
1 Parent(s): ab0bffd

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -34
app.py DELETED
@@ -1,34 +0,0 @@
1
- import gradio as gr
2
- from transformers import BlipProcessor, BlipForConditionalGeneration
3
- from PIL import Image
4
-
5
- # Load BLIP model and processor
6
- processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
7
- model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
8
-
9
- def caption_image(image):
10
- """
11
- Generates a caption for the given image.
12
- """
13
- try:
14
- # Prepare inputs for image captioning
15
- inputs = processor(images=image, return_tensors="pt")
16
-
17
- # Generate caption
18
- outputs = model.generate(**inputs)
19
- caption = processor.decode(outputs[0], skip_special_tokens=True)
20
-
21
- return caption
22
- except Exception as e:
23
- return f"An error occurred: {str(e)}"
24
-
25
- # Gradio Interface
26
- iface = gr.Interface(
27
- fn=caption_image,
28
- inputs=gr.Image(type="pil"),
29
- outputs="text",
30
- title="Image Captioning with BLIP",
31
- description="Upload an image to generate a descriptive caption."
32
- )
33
-
34
- iface.launch()