amnakhan1122 commited on
Commit
5aa1ec3
·
verified ·
1 Parent(s): d9523cf

Delete image_caption.py

Browse files
Files changed (1) hide show
  1. image_caption.py +0 -25
image_caption.py DELETED
@@ -1,25 +0,0 @@
1
- # app.py
2
- import streamlit as st
3
- from transformers import BlipProcessor, BlipForConditionalGeneration
4
- from PIL import Image
5
- import torch
6
-
7
- st.title("AI Image Caption Generator")
8
- st.write("Upload an image and get a caption generated by an AI model!")
9
-
10
- uploaded_file = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
11
-
12
- if uploaded_file:
13
- image = Image.open(uploaded_file).convert('RGB')
14
- st.image(image, caption="Uploaded Image", use_column_width=True)
15
-
16
- st.write("Generating caption...")
17
-
18
- processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
19
- model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
20
-
21
- inputs = processor(image, return_tensors="pt")
22
- out = model.generate(**inputs)
23
- caption = processor.decode(out[0], skip_special_tokens=True)
24
-
25
- st.success(f"📝 Caption: {caption}")